-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't allow adopting DocumentFragment of a template element #744
Comments
I suspect throwing is probably not web compatible at this point so I'd suggest silently returning early. |
I'm not sure it's that simple. E.g., replace all can be passed a I think the problem is with |
Ah great, Firefox throws on test(() => {
const doc1 = new Document(),
doc2 = new Document(),
div1 = doc1.appendChild(document.createElement("div")),
div2 = doc2.appendChild(document.createElement("div")),
shadow = div1.attachShadow({mode: "closed"}),
shadowChild = shadow.appendChild(new Text());
div2.appendChild(shadow);
assert_equals(div2.firstChild, shadowChild);
assert_equals(shadow.ownerDocument, doc2);
}); (My replace all example is a little misleading as currently that can only be invoked with newly created nodes at the moment, but append/pre-insert has the same issue.) |
We definitely don't implement such a semantic for |
It's not "just" a specification bug if implementations are doing different things. As far as I know this wasn't fully considered either so it's not clear to me what the resolution ought to be. |
Well, we clearly don't have any implementation that just adopts the node, and I don't think we ever want that anyway. So it's an oversight that we never spec'ed this behavior. So I agree there is a disagreement as to what exactly happens when a ShadowRoot gets adopted but I don't think the answer to that can never be it gets successfully adopted. That would make no sense. |
If I insert a node that has an attached I suppose what we need to do is that when you adopt a node that has a host, that needs to be handled in a special way. But if you hit such a node due to recursion, that should not be handled in a special way. |
Obviously, we should adopt
That might be a neat idea to handle both document fragment types. But really, the only place we need a check is https://dom.spec.whatwg.org/#dom-document-adoptnode because all other public DOM APIs would adopt a node either throws on On a completely unrelated note, I wish DOM / HTML spec had spec assertions like ECMA. That would clarify a lot of subtle conditions like this. |
I don't follow. We can use assertions and you are free to add them via PRs (or request them to be added during review of a PR): https://infra.spec.whatwg.org/#assertions. |
@annevk : The case I'm concerned about is the content |
Adopt entry points:
|
Maybe in part the misunderstanding here is that the specification is wrong for |
Tests for whatwg/dom#744. The assumption here is an early return for DocumentFragment that has a host by adoptNode() and that adoption generally doesn't affect DocumentFragment otherwise (only its children).
And do not allow non-null host DocumentFragment nodes to be adopted. This means that a DocumentFragment is no longer implicitly adopted and a DocumentFragment with a non-null host cannot be put in a "weird" state. Tests: web-platform-tests/wpt#16348. Fixes #744.
And do not allow non-null host DocumentFragment nodes to be adopted. This means that a DocumentFragment is no longer implicitly adopted and a DocumentFragment with a non-null host cannot be put in a "weird" state. Tests: web-platform-tests/wpt#16348. Fixes #744.
Tests for whatwg/dom#744. The assumption here is an early return for DocumentFragment that has a host by adoptNode() and that adoption generally doesn't affect DocumentFragment otherwise (only its children).
Also do not allow DocumentFragment nodes with host to be adopted. This means that a DocumentFragment is no longer implicitly adopted and a DocumentFragment with a (non-null) host cannot be put in a "weird" state. Tests: web-platform-tests/wpt#16348. Fixes #744.
Tests for whatwg/dom#744. The assumption here is an early return for DocumentFragment that has a host by adoptNode() and that adoption generally doesn't affect DocumentFragment otherwise (only its children).
Automatic update from web-platform-tests Adoption and DocumentFragment (#16348) Tests for whatwg/dom#744. The assumption here is an early return for DocumentFragment that has a host by adoptNode() and that adoption generally doesn't affect DocumentFragment otherwise (only its children). -- wpt-commits: cca4170a0c8a6a9b8398eb53364ec0bba7ead7cb wpt-pr: 16348
Automatic update from web-platform-tests Adoption and DocumentFragment (#16348) Tests for whatwg/dom#744. The assumption here is an early return for DocumentFragment that has a host by adoptNode() and that adoption generally doesn't affect DocumentFragment otherwise (only its children). -- wpt-commits: cca4170a0c8a6a9b8398eb53364ec0bba7ead7cb wpt-pr: 16348 UltraBlame original commit: 766599c3407c7c86a9b858a0f5e2403d9a8a98c9
Automatic update from web-platform-tests Adoption and DocumentFragment (#16348) Tests for whatwg/dom#744. The assumption here is an early return for DocumentFragment that has a host by adoptNode() and that adoption generally doesn't affect DocumentFragment otherwise (only its children). -- wpt-commits: cca4170a0c8a6a9b8398eb53364ec0bba7ead7cb wpt-pr: 16348 UltraBlame original commit: 766599c3407c7c86a9b858a0f5e2403d9a8a98c9
Automatic update from web-platform-tests Adoption and DocumentFragment (#16348) Tests for whatwg/dom#744. The assumption here is an early return for DocumentFragment that has a host by adoptNode() and that adoption generally doesn't affect DocumentFragment otherwise (only its children). -- wpt-commits: cca4170a0c8a6a9b8398eb53364ec0bba7ead7cb wpt-pr: 16348 UltraBlame original commit: 766599c3407c7c86a9b858a0f5e2403d9a8a98c9
Automatic update from web-platform-tests Adoption and DocumentFragment (#16348) Tests for whatwg/dom#744. The assumption here is an early return for DocumentFragment that has a host by adoptNode() and that adoption generally doesn't affect DocumentFragment otherwise (only its children). -- wpt-commits: cca4170a0c8a6a9b8398eb53364ec0bba7ead7cb wpt-pr: 16348
Right now, we allow adopting a
DocumentFragment
of a template element becauseDocumentFragment
never have a parent.The subtree of such a
DocumentFragment
is still associated with the template element yet its owner document is of the adopted document. As far as I know, this is only case in which such an oddity arises becauseShadowRoot
is forbidden from being adopted into another tree, and every other node type would have a parent as long as it's part of a document and therefore will be removed before the adoption.I don't think we should allow this. https://github.com/web-platform-tests/wpt/blob/master/html/semantics/scripting-1/the-template-element/template-element/template-content-hierarcy.html explicitly tests this.
The text was updated successfully, but these errors were encountered: