Re: [dom] Consider banning insertNode() of the Range's start node (#63)

Bah, I tried to search in the W3C bugs but didn't do it properly.  Thanks for the pointer.  Those changes improved things, but I don't think it fixed it fully.

On reflection, a couple of principles:

1) We should never split a text node if we're not going to put anything in between the two nodes.  It's pointless and messy.  insertNode is supposed to move nodes around, possibly splitting if necessary.  It's not meant to split a node if not necessary for inserting something in between the halves.  This rules out the behavior of IE and Firefox.  If we're going to do anything here, we shouldn't split the text node.

2) Inserting a text node into the middle of itself doesn't make sense.  We already throw if you try to insert an element if the start of the range is inside the element, so it makes sense to do the same for a text node.  What sensible meaning does it have to insert a text node into itself?  This argues in favor of Chrome's behavior.  Although it's true that "insertBefore() works fine to move a node to its current position", that means if you try inserting it before or after itself, not inside itself!

So I've come to the conclusion that we should match Chrome here.  @annevk @Ms2ger, what do you think?

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/63#issuecomment-130264227

Received on Wednesday, 12 August 2015 11:20:50 UTC