CustomElement Reactions#2394
Open
karlseguin wants to merge 1 commit intomainfrom
Open
Conversation
While this PR touches a lot of files, and isn't trivial, many of the changes
are either:
1 - removing guards added in previous PRs, e.g.
#1969
#2172
#2313
#2366
2 - Adding the `.ce_reactions = true` flag to various WebAPIs
CustomElements have callbacks, e.g. connectedCallback. Also, many WebAPI calls
are implemented as a series of mutations, e.g. appendChild = remove from current
+ append to new.
These two things interact in an important way: when should callbacks execute?
Before this PR, we were invoking callbacks at each individual step. This is
(a) technically wrong and (b) breaks a lot of assumptions (the reason the above
4 PRs were needed to fix bugs).
This PR adds a `_ce_reactions` queue to the frame. And, instead of invoking
callbacks, we "enqueue" the reaction. At various boundaries, a scope is created
the DOM manipulation is done, and then we pop the scope, invoking all queued
reactions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While this PR touches a lot of files, and isn't trivial, many of the changes are either:
1 - removing guards added in previous PRs, e.g.
#1969
#2172
#2313
#2366
2 - Adding the
.ce_reactions = trueflag to various WebAPIsCustomElements have callbacks, e.g. connectedCallback. Also, many WebAPI calls are implemented as a series of mutations, e.g. appendChild = remove from current & append to new.
These two things interact in an important way: when should callbacks execute? Before this PR, we were invoking callbacks at each individual step. This is (a) technically wrong and (b) breaks a lot of assumptions (the reason the above 4 PRs were needed to fix bugs).
This PR adds a
_ce_reactionsqueue to the frame. And, instead of invoking callbacks, we "enqueue" the reaction. At various boundaries, a scope is created the DOM manipulation is done (which queues reactions instead of invoking them directly), and then we pop the scope, invoking all queued reactions.