This repository was archived by the owner on Oct 13, 2025. It is now read-only.
Repository navigation
iAPI Router: Add support for new router regions with attachTo - #14
Merged
Merged
Conversation
Base automatically changed from
iapi-move-full-page-logic-to-its-own-module
to
interactivity-api
May 12, 2025 16:40
|
Size Change: +148 B (+0.01%) Total Size: 1.86 MB
ℹ️ View Unchanged
|
DAreRodz
commented
May 20, 2025
DAreRodz
commented
May 20, 2025
DAreRodz
commented
May 20, 2025
|
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. |
luisherranz
approved these changes
May 21, 2025
luisherranz
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, David!
Just a couple of details in the tests, but great tests as always. Pre-approving so you can merge whenever you want.
10 tasks done
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What?
Renders missing router regions from newly visited pages when they have an
attachToproperty defined.The
attachToproperty should be a valid CSS selector, pointing to the parent element where the new router region should be rendered.E.g., this region would be rendered in
<body>if it appears in a visited page, even when it wasn't initially rendered.Why?
Mainly, to support the
core/imageblock lightbox with region-based navigation.How?
Inside
regionsToVdom(), when a new page is processed, aregionsToAttachobject is created, mapping the ID of each router region withattachToto the CSS selector of the target parent element. The vDOM tree of these regions is still stored inregionsas usual.Later, inside
renderRegions(), when that page is rendered, all regions in the current HTML are updated with the new content. Regions withattachTocould already be present in the current HTML, and these are updated as previously. Only new regions withattachToare handled differently, creating a new root fragment for each of them in the corresponding target defined byattachTo.If any of these regions disappear on subsequent pages, they are unmounted as expected.
Testing Instructions
There are e2e tests for this feature.
Also, this feature can be tested manually following these steps:
/?query-1-page=999). You should see something like "Sorry, but nothing was found. Please try a search with different keywords".