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
fix: children and childNodes not returning top-level slotted children #4098
Changes from 1 commit
9843b5a
6166bbe
316f47a
f902276
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,8 @@ export function getNodeNearestOwnerKey(node: Node): number | undefined { | |
} | ||
host = parentNodeGetter.call(host) as ShadowedNode | null; | ||
|
||
// Elements slotted from top level light DOM into synthetic shadow | ||
// reach the slot tag from the shadow element first | ||
Comment on lines
+61
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't understand this comment. Are we short-circuiting here so that we don't need to traverse to the root? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
if (!isNull(host) && isSyntheticSlotElement(host)) { | ||
return undefined; | ||
} | ||
|
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.
Not so sure about this logic. If the owner is
null
butownerKey
is defined, thenisNodeOwnedBy()
returnstrue
. By relaxing the input constraints, it seems that we're muddying the job of this function. Maybe this is a sign that we should be handling the light DOM case elsewhere?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.
I think of this as node being owned by a shadowRoot or document (in which case it's null). It's owned by document, in case of light DOM parents.
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.
Would having more tests for childNodes/children help build confidence? I suspect we don’t have a lot.
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.
For both
childrenGetterPatched
andchildNodesGetterPatched
, if there is no owner, then it means that the element or node is not shadowed, correct? If so, then it seems like we should immediately returngetFilteredChildNodes(this)
instead of drilling down intogetAllMatches()
andisNodeOwnedBy()
.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.
Makes sense! Done.