-
Notifications
You must be signed in to change notification settings - Fork 879
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
Improve queryAssignedElements decorator browser compatibility #2392
Conversation
…ort. Due to the Lit library browser recommendations and available polyfill support, the easiest way to ensure queryAssignedElements is fully supported is by continuing to use assignedNodes. Why? ShadyDOM doesn't polyfill assignedElements: webcomponents/polyfills#46 But even if we did polyfill assignedElements, there is still a complexity introduced by assignedElements being added to browsers slightly after we recommend polyfills on our browser support matrix. For example, Firefox 65 would not have polyfills applied, and doesn't yet support assignedElements. assignedElements are added in Firefox 66.
🦋 Changeset detectedLatest commit: c4592a5 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultslit-element-list
render
update
update-reflect
lit-html-kitchen-sink
render
update
nop-update
lit-html-repeat
render
update
lit-html-template-heavy
render
update
reactive-element-list
render
update
update-reflect
|
packages/reactive-element/src/decorators/query-assigned-elements.ts
Outdated
Show resolved
Hide resolved
This provides a better experience on modern browsers.
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.
Looks good to me! Would be nice to get a stamp from @kevinpschaaf too on this approach.
Using != will check against null and undefined. opts passed into slotAssignedElementsPolyfill can also be undefined.
Note, this has passed isolated tgp with the new commit. |
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.
LGTM
Context
Internally queryAssignedElements was using the newer
HTMLSlotElement.assignedElements
method. This newer method doesn't have ShadyDOM polyfill support, but would still leave some browsers unsupported if it did have polyfill support.Using Modern browser breakdown as a guide,
assignedElements
is not supported until Firefox 66. This leaves Firefox versions 64 and 65 without support.tl;dr
queryAssignedElements
doesn't work on older browsers.How
Gracefully fallback on
assignedNodes
if required. The behavior of the decorator remains unchanged.Testing
This is a private implementation change, so the existing unit tests should cover this. No functional changes.
Also testing via cl/420366110
Size of decorators before changes (on main):
Size of decorators after change:
The release size is the same after this change, only dev has slightly increased in size.