-
Notifications
You must be signed in to change notification settings - Fork 794
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
feat(runtime): add slotchange
event and assignedNodes
/ assignedElements
methods for scoped: true
slots
#6151
Merged
christian-bromann
merged 12 commits into
ionic-team:main
from
johnjenkins:polyfill-slotchange
Feb 19, 2025
Merged
feat(runtime): add slotchange
event and assignedNodes
/ assignedElements
methods for scoped: true
slots
#6151
christian-bromann
merged 12 commits into
ionic-team:main
from
johnjenkins:polyfill-slotchange
Feb 19, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
slotchange
events and assignedNodes
/ assignedElements
for scoped: true
slotsslotchange
event and assignedNodes
/ assignedElements
methods for scoped: true
slots
@christian-bromann I could put this behind a new |
johnjenkins
commented
Feb 16, 2025
christian-bromann
approved these changes
Feb 19, 2025
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.
As always, fantastic job 🚀
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
Stencil's polyfilled - 'Pretend slots' - don't act like their native counterparts:
assignedNodes()
/assignedElements()
)slotchange
event)At present, on a
scoped: true
component devs have to resort to clunky mutation observers (for text, comment and element nodes on a default slot), saving node references to internal state to track when they change.This is frustrating as Stencil, internally, knows what is slotted.
Making this knowledge available to users will enable them to remove substantial LOC and mirroring the the native APIs makes swapping between native & proprietary behaviour much simpler.
GitHub Issue Number: #3782
What is the new behavior?
Fixes #3782
assignedNodes
andassignedElements
methods have been added to the mock<slot />
nodes (which in reality is an an empty text node (or a comment node in debug mode) or a<slot-fb />
if there is fallback nodes).Documentation
Does this introduce a breaking change?
No - although, there is a change in behaviour .. Previously when doing something like
<slot ref={s => this.slot} />
... theref
would resolve to a slotted node. I think this behaviour is 1) unintuitive & 2) not documented.Testing
New WDIO tests
Other information