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

A slottable's assigned slot is never reset #1352

Open
simonwuelker opened this issue Feb 1, 2025 · 3 comments
Open

A slottable's assigned slot is never reset #1352

simonwuelker opened this issue Feb 1, 2025 · 3 comments
Labels
editorial Changes that do not affect how the standard is understood topic: shadow Relates to shadow trees (as defined in DOM)

Comments

@simonwuelker
Copy link

What is the issue with the DOM Standard?

When assigning slottables for a slot, the spec updates the assigned slot of any slottable that is added to the slot in

  1. For each slottable of slottables, set slottable’s assigned slot to slot.

However, the assigned slot of any slottables that were previously assigned to the slot but aren't anymore won't change. I would expect a slottable's assigned slot to be null if that slottable is not also part of that slot's assigned nodes.

I'm not sure if this is intended, because the assignedSlot getter for slottables seems to work around it by calling find a slot.

This is causing extra work in algorithms like Node::remove:

If node is assigned, then run assign slottables for node’s assigned slot.

If the node was previously removed from a slot (but keeps a nonnull assigned slot) then this won't do anything.

@annevk
Copy link
Member

annevk commented Feb 10, 2025

I honestly don't quite recall why we (maybe just me) did it this way. I think a refactoring would be okay. Are you interested in working on that?

(@domenic, @hayatoito, or @smaug---- might remember more.)

@annevk annevk added topic: shadow Relates to shadow trees (as defined in DOM) editorial Changes that do not affect how the standard is understood labels Feb 10, 2025
@simonwuelker
Copy link
Author

Are you interested in working on that?

Yeah sure! I'll wait a bit for the authors you pinged to give their thoughts (if any).

For reference, the version of assign slottables that I implemented in servo does disconnect slottables that are removed (doing so simplified the logic in the stylo integration) and so far that hasn't caused any problems for us.

https://github.com/servo/servo/blob/90130315a771cf2d52c982523721162f007a400c/components/script/dom/htmlslotelement.rs#L330-L337

@annevk
Copy link
Member

annevk commented Feb 11, 2025

It might be worth looking at blame for the original commit, though I somewhat doubt it will give much context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial Changes that do not affect how the standard is understood topic: shadow Relates to shadow trees (as defined in DOM)
Development

No branches or pull requests

2 participants