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

When is slotchange handler fired? #515

Closed
trusktr opened this issue Jun 6, 2016 · 5 comments
Closed

When is slotchange handler fired? #515

trusktr opened this issue Jun 6, 2016 · 5 comments

Comments

@trusktr
Copy link
Contributor

trusktr commented Jun 6, 2016

When is slotchange handler fired in the following case?

@hayatoito
Copy link
Contributor

hayatoito commented Jun 7, 2016

It's difficult to explain briefly here.
These are now defined in the DOM Standard. The followings might be what you want to read:

@rniwa
Copy link
Collaborator

rniwa commented Jun 7, 2016

slotchange event fires at the end of the current microtask. Those custom element callbacks fire at the end of current "nanotask" which are basically when UA returns the control back to author scripts from their DOM, CSS OM, etc... APIs. So slotchange tends to fire a lot later than custom elements callbacks in common cases.

@trusktr
Copy link
Contributor Author

trusktr commented Jun 9, 2016

@rniwa How can a distributed node then run some code after slotchange handlers have fired without knowing about slotchange? If slotchange fired in the same tick as the custom element callbacks, then the simple solution is deferring to the next tick.

I would really like to detect when the tree looks like this:

div
 |
slot
 |
motor-node

and I need that distributed motor-node to throw an error when it is distributed into a div.

@rniwa
Copy link
Collaborator

rniwa commented Jun 9, 2016

I don't follow what you're saying. slotchange event is fired on slot element, not the nodes distributed to the slot.

@trusktr
Copy link
Contributor Author

trusktr commented Jun 29, 2016

@rniwa Yep, that's exactly what I'm saying: that there's no way for a distributed node to know about being distributed because only the parent of the slot or slot itself can work with slotchange, so I suggested distributedCallback as a possible solution.

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