Open annevk opened 4 years ago
Because commit()
actually applies the stages mutations, can it defer mutation events to fire after mutations and before CE reactions? Maybe this is the queue you're referring to in that issue.
It's specifically about script and iframe insertions and they have their own queue as you can insert multiple together, but you don't want to execute them before they are all inserted. (Let's assume mutation events are completely disabled as that seems like a solid plan.)
Wow, I see there's a lot of history in whatwg/dom#808. But I think those are separate issues from the parts batch commit(), and they can be tackled independently.
For the batching concept, can we view the subtree where all the parts are being committed as a DocumentFragment, for the duration of the commit()? Therefore, DOM insertions of scripts and iframes don't run immediately. Only after all the DOM mutations have been completed, does the UA initiate script execution and iframe loading, in the parts order inside a PartGroup.
This way, each browser's behavior will be exactly as @annevk outline in the example, issue/575. You can think of it as adding scripts and iframes to a DocumentFragment and inserting its content into the DOM.
This is just a conceptual framework. We don't need to make the whole subtree a DocumentFragment, then reinsert back into DOM. But it's to highlight the expected behavior. UA can hold references to these part values and execute them afterward.
I think it may be necessary to define the two phases of batch commit: Phase_Mutation & Phase_Script.
What do you think?
I suspect that's roughly what we have to do, but given that user agents are not interoperable on those phases I don't think it can be tackled independently. We need to actually get agreement on that model.
With https://github.com/whatwg/dom/issues/808 still unsolved it seems somewhat hard to figure out how batch mutations would have to change that "unknown" model. (Because even if we disable mutation events, script and iframe insertions and such probably have to remain functioning.)