According to the documentation surroundContents() surrounds a selected node. The docu mentions
An exception will be thrown, however, if the Range splits a non-Text node with only one of its boundary points. That is, unlike the alternative above, if there are partially selected nodes, they will not be cloned and instead the operation will fail.
What I didn't find is if there is a way to check before if the exception would occur or not. i.e. How to check before executing the operation if the action is possible?
Use case: The user shouldn't be able to perform the action if its not possible.
I know that I can try catch the action and prevent that to be happen. But checking before would be great.
Initially I thought about checking if the elements in the Range.startContainer and Range.endContainer have some block element - but this won't help much. Especially since checking block element sounds tricky. range.cloneRange() doesn't help much either. Any other ideas?