-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Interactivity API: Improve context merges using proxies #59187
Interactivity API: Improve context merges using proxies #59187
Conversation
Size Change: +148 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
Flaky tests detected in 9c7b3a5. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7992783284
|
fcae882
to
43037bc
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
||
const mergeDeepSignals = ( target, source, overwrite ) => { | ||
const isPlainObject = ( item ) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be similar as the one in store.ts
#59039
Should we move it to another file to share same code in different files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, maybe we could move it to utils.js
. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
0ec816e
to
9c7b3a5
Compare
* First attempt using proxies * Simplify context logic * Return true from proxy `set` trap * Update wp-context and wp-each implementation * Rename `isObject` to `isPlainObject` * Refactor and document proxifyContext * Add test for new parent properties * Do not proxify assigned objects * Set the item after proxifying the context * Rename contextIgnores to contextAssignedObjects * Add comment to `udpateSignals` * Fix context values when navigating back and forward * Add more tests for navigations * Update tests to cover a tricky case * Update comment * Fix context definition in navigation block * Add test for object overwritten * Update changelog Co-authored-by: DAreRodz <darerodz@git.wordpress.org> Co-authored-by: c4rl0sbr4v0 <cbravobernal@git.wordpress.org>
I just cherry-picked this PR to the cherry-pick-wp-6-5-beta-3 branch to get it included in the next release: 8374560 |
* First attempt using proxies * Simplify context logic * Return true from proxy `set` trap * Update wp-context and wp-each implementation * Rename `isObject` to `isPlainObject` * Refactor and document proxifyContext * Add test for new parent properties * Do not proxify assigned objects * Set the item after proxifying the context * Rename contextIgnores to contextAssignedObjects * Add comment to `udpateSignals` * Fix context values when navigating back and forward * Add more tests for navigations * Update tests to cover a tricky case * Update comment * Fix context definition in navigation block * Add test for object overwritten * Update changelog Co-authored-by: DAreRodz <darerodz@git.wordpress.org> Co-authored-by: c4rl0sbr4v0 <cbravobernal@git.wordpress.org>
What?
Reimplements the context merging algorithm using proxies.
Contexts are defined using the
data-wp-context
directive. A context can inherit properties from upper contexts defined in the DOM. To achieve that, contexts are "merged" top-down.Why?
It solves a couple of inconsistencies, like changes in inherited context not being reflected in child contexts and issues during navigations.
These issues are:
data-wp-context
are inherited. That means newly added properties to parent contexts don't appear in children.How?
Implementing a function called
proxifyContext
. It receives two arguments: thedeepSignal
instance for the current context and the inherited context. The proxy makes inherited properties appear like they were defined in the current context.