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 the slotting algorithm run #401
Comments
I'm assuming we have to run this whenever the tree or shadow tree is modified? Might it be better to define it lazily what |
The CSS box generation requires the flattened tree. I don't think there is any point in making the spec run this algorithm lazily. We can spec it to run whenever DOM gets mutated and implementors can do the work lazily as an optimization. |
That would mean though that without optimization we'd have to run this each mutation, for each node in the tree, including any associated shadow trees, and their associated shadow trees, etc., since It seems easier to specify this as a lazy algorithm if this is only used for (I'm assuming you mean the "slotting algorithm" and not the "flatted tree algorithm" when you say "this algorithm".) |
In that case, I'd suggest writing two algorithms. One that finds (slot name, slot element) pairs in a given node tree and another one that creates a list of (slot name, list of assigned nodes) pairs from the child nodes of a shadow host. The first algorithm is implemented in WebKit at: The second algorithm is implemented in WebKit at: |
Seems reasonable. @hayatoito I think this is one of the main problems with the specification. That while algorithms are defined, it's unclear where these algorithms are plugged into the rest of the system. |
I added dfn.js to the spec. It looks that the (reverse) dependency is:
Thus, the consumers are getAssignedNodes() and (how to construct) a flat tree.
Yes, that's my intention. I thought that we can keep the spec simple by this laziness (declarative) definition. I would like to avoid to specify the timing when these algorithms are run. |
When I click on slotting algorithm it says "No references in this file." I don't think the current approach works. There's a couple of places where it's observable whether or not the algorithm has run. Either you need to just hook into mutation or you need to make sure it's run by the time it's being observed. Currently it doesn't really seem like either is required. |
The dependency (slotting algorithm -> assigned slot) exists in the following sentence.
Should we clarify the timing? AFAIR, the spec had a sentence, such as:
However, I removed this sentence because this sentence does not define anything. As a dependency shows, we need to define the timing when we should construct a "flat tree", ultimately, if we are to define the timing exactly. I have no idea how to define it nicely. |
My current approach in defining this in the DOM Standard is to basically define algorithms similar to those in Shadow DOM "find a slot", "find slotables", "find distributed slotables", and invoke those from places such as assignedSlot and getAssignedNodes() (not yet defined, to be done in HTML). The CSS specification for Shadow DOM will have to deal with the flattened tree and maybe even define that in detail since that is largely immaterial to DOM (it doesn't affect event dispatch or any API). WDYT? |
It sounds good. |
Searching for "slotting algorithm" does not find any callers. That does not seem right.
The text was updated successfully, but these errors were encountered: