-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Toggle Creation Details currently says:
ISSUE 1: Define the precise point in update the rendering when toggles are created if toggle-root names a toggle that doesn’t exist on the element yet.
It's not clear to me what the intent of this.
Done naively, I think this would produce the result that :toggle()
pseudo-classes don't match until the update after the toggle-root
property is added. I think this would have two harmful results:
- you'd see a flash of "unstyled" content where the
:toggle()
selectors weren't matched on the first update - Things that "flush" style wouldn't produce up-to-date results for the matching of
:toggle()
selectors, in cases where thetoggle-root
property is new (which, in realistic cases, means the element was newly created and the flush is styling it for the first time).
I presume the alternative (within the description given in the issue) is to create the toggles and then do another round of restyling to match the :toggle()
selectors, and repeat until stable. I think the number of possible iterations is bounded by the number of elements in the document... though in realistic cases more than one iteration seems unlikely. This does require adding a loop in a relatively core part of the engine for something that's specific to toggles, and it may require some care to specify how it interacts with other features.
I think there's a third alternative that deviates from what is suggested in the issue, which is to work like transitions and create the toggles during style resolution, before resolving style on descendants or later siblings. This is problematic for engines that want to do some of this work in parallel, and it also introduces a lot of complexity. (Getting this right for transitions is hard, and I'm not sure we've done so yet. We recently proposed redesigning how it works.) But this does avoid the problems with either of the previous two alternatives.
I'm curious which alternative was actually intended by the spec.