-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Adoption and DocumentFragment #16348
Conversation
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.
This comment has been minimized.
This comment has been minimized.
|
||
calls = []; | ||
doc.documentElement.appendChild(shadowRoot); | ||
if (documentName === "the document of the template elements") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rniwa this seems a little ugly btw, but I wasn't sure how to avoid it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about doc === host.content.ownerDocument
?
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).
5bf98d8
to
1b02a0b
Compare
@foolip care to review this? |
@tkent-google could you maybe review this given that you reviewed the corresponding spec PR? |
return getDocument().then(function (doc) { | ||
var instance = document.createElement('my-custom-element'); | ||
var host = document.createElement('template'); | ||
var shadowRoot = host.content; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name shadowRoot
is very confusing. It should be documentFragment
or something.
|
||
calls = []; | ||
doc.documentElement.appendChild(shadowRoot); | ||
if (documentName === "the document of the template elements") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about doc === host.content.ownerDocument
?
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.
Sorry, still getting used to new email filtering setup. I'll not review given that @tkent-google started doing so. |
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).