Skip to content

CustomElement Reactions#2394

Open
karlseguin wants to merge 1 commit intomainfrom
custom_element_reactions
Open

CustomElement Reactions#2394
karlseguin wants to merge 1 commit intomainfrom
custom_element_reactions

Conversation

@karlseguin
Copy link
Copy Markdown
Collaborator

@karlseguin karlseguin commented May 8, 2026

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 (which queues reactions instead of invoking them directly), and then we pop the scope, invoking all queued reactions.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant