This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Range.surroundContents() method[1] checks "partially-contained"[2] pre-check without using host-inclusive, but then in later step when to append[3], its pre-check is host-inclusive. This should be consistent. Propose to change "partially contained" to use "host-including inclusive ancestor". [1] http://w3c.github.io/dom/#dom-range-surroundcontents https://dom.spec.whatwg.org/#dom-range-surroundcontents [2] http://w3c.github.io/dom/#partially-contained https://dom.spec.whatwg.org/#dom-range-surroundcontents [3] http://w3c.github.io/dom/#concept-node-append https://dom.spec.whatwg.org/#concept-node-append [4] http://w3c.github.io/dom/#partially-contained https://dom.spec.whatwg.org/#partially-contained
As far as I can tell you hit the host-including check as part of the insertion operation of step 5. The problematic scenario appears to be that you have a range that contains a <template> and that <template> contains a node that you use as newParent argument. That would argue for a new step I think, as step 1 does not care about newParent. Also, how can newParent ever be a Text, Comment, or ProcessingInstruction node? Is that for when the range is collapsed? But if it's not collapsed it seems those nodes would be problematic...
> As far as I can tell you hit the host-including check as part of the insertion operation of step 5. Right, and in step 4, the spec "replace all with null within newParent", so failing in step 5 means that UA deletes all children of newParent. Shouldn't we fail in step 1 instead?
Demo: http://jsbin.com/secuxo/edit?html,output
Sorry for getting back to you so late, I'm still a bit at a loss as to what to do here. It seems browsers don't throw for this scenario... I guess they didn't update their implementation...
I think I'm fine with this behaving the way it is. Range mutations are already a little weird as they perform many DOM mutations each of which can have side effects. If you still think this should be fixed, please file a new issue over at https://github.com/whatwg/dom/issues/new.