Wednesday, 23 January 2019

What is the effect of parent.insertBefore(child,child) -- in other words, of trying to insert a node before itself

What is the effect of parent.insertBefore(child,child) -- in other words, of trying to insert a node before itself?

Answer:


The child node should be removed from its parent, then reinserted in the same place, as if the call had actually beenparent.insertBefore(child,child.getNextSibling()). Note that this is not considered a usage error; no DOMexception is thrown. Nor is it necessarily a "no-op" even though the document is left unchanged, since the removal and reinsertion may have side effects -- for example, MutationEvents may be fired, andNodeIterator and Range fixups may occur.

No comments:

Post a Comment