Skip to content
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

slotChange event is not working on anything but the slot attribute change #937

Open
Kokujou opened this issue Aug 9, 2021 · 3 comments
Open

Comments

@Kokujou
Copy link

Kokujou commented Aug 9, 2021

hello,

first: i was pointed here by this bug, i created:
https://bugzilla.mozilla.org/show_bug.cgi?id=1724680

the problem is the following:
i have a webcomponent which uses slots. And i want to detect when there is a change in those slots, especially in attributes and the inner text of the elelment. i want to catch this change and refresh my web-component

but currently the slotChange event is only triggered when the slot attribute is changed, which is very limited.

there is a workaround being the use of the MutationObserver assigned to the webComponent root (not shadow root!).

@justinfagnani
Copy link
Contributor

I'm sure there are some existing issues on this topic. It's very often been requested to be able to observe changes in children, whether projected or not.

@Kokujou
Copy link
Author

Kokujou commented Aug 9, 2021

if yes feel free to link it.
but for slots it's the most common thing to do that the component get's updated when the children do.

however if there is something like a "slotChange" event and it is not fired if the slot is changed... then i would at least thing it is a syntactical bug.

if it is intended that this event is only called on the change of the assigned elements list without any context about anything else, then call it "slotAdded" or "elementAdded" or "rangeUpdated" or so.

@dbatiste
Copy link

I suspect there may be older issues raised for this, but this one is very recent - #933.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants