Repository navigation
Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content - #84919
Conversation
🤖 PR meta 🤖🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +223 B (0%) Total Size: 8.56 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Navigates the items list via UP/DOWN arrow keys in
|
attachTo targets inside data-wp-html content- Shorten the changelog entries to the length of earlier ones, split the router entry into the two fixes it describes, and drop the stray period before the PR link. - README: move the data-wp-html paragraph after the example it was separating from its explanation, fix "An element is not usable when the selector matches nothing", and state the initial-page attachTo exception once instead of inside the first bullet. - Guide: define "data-wp-html element" by linking to the conflict rules instead of restating them, and remove repeated sentences. - Directive reference: link from "Inert content" to the router docs. - Comments: make the parseDirectiveName() and closestHtmlDirectiveElement() docblocks precise, drop an unrelated privateApis() docblock, and reword cryptic comments.
…router-data-wp-html-regions
…of order The runtime logs each warning once per module, so the tests restoring a region that carries data-wp-html emitted the conflict warning only when they ran before the test expecting it. CI runs tests shuffled, and both failed. Check Back in the test that expects the warning instead.
…router-data-wp-html-regions # Conflicts: # packages/interactivity-router/CHANGELOG.md # packages/interactivity-router/src/index.ts # packages/interactivity/CHANGELOG.md # packages/interactivity/src/vdom.ts
|
There was a conflict while trying to cherry-pick the commit to the wp/7.2 branch. Please resolve the conflict manually and create a PR to the wp/7.2 branch. PRs to wp/7.2 are similar to PRs to trunk, but you should base your PR on the wp/7.2 branch instead of trunk. |
…de data-wp-html content (#84919) (#86059) * Interactivity API: Expose parseDirectiveName() to internal consumers * Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content * Interactivity Router: Document data-wp-html content and unusable attachTo targets * Interactivity Router: Add the PR number to the changelog entries under Unreleased * Interactivity Router: Tighten docs, comments and changelog entries - Shorten the changelog entries to the length of earlier ones, split the router entry into the two fixes it describes, and drop the stray period before the PR link. - README: move the data-wp-html paragraph after the example it was separating from its explanation, fix "An element is not usable when the selector matches nothing", and state the initial-page attachTo exception once instead of inside the first bullet. - Guide: define "data-wp-html element" by linking to the conflict rules instead of restating them, and remove repeated sentences. - Directive reference: link from "Inert content" to the router docs. - Comments: make the parseDirectiveName() and closestHtmlDirectiveElement() docblocks precise, drop an unrelated privateApis() docblock, and reword cryptic comments. * Interactivity Router: Make the data-wp-html region tests independent of order The runtime logs each warning once per module, so the tests restoring a region that carries data-wp-html emitted the conflict warning only when they ran before the test expecting it. CI runs tests shuffled, and both failed. Check Back in the test that expects the warning instead. --------- (cherry picked from commit 00c4190) Co-authored-by: David Arenas <david.arenas@automattic.com>
This updates the pinned commit hash of the Gutenberg repository from `cc75a79186fd23e72eb015d594e82f40c6209eb5` to `c035c1a649ef68f5c1646694cf440df1d7ae6e62` (fixes cherry-picked to the `wp/7.2` branch). A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@cc75a79...c035c1a - Components: Use solid brand highlights for popup items (WordPress/gutenberg#84583) (#85848) - Fix endless sideload loop when the browser can't decode a big image (WordPress/gutenberg#83530) - Notes: Show reaction picker as a row of emoji (WordPress/gutenberg#85819) (#85892) - Notes: Add thumbs up and plus reactions (WordPress/gutenberg#85565) - Notes: Share thread focus recovery across actions (WordPress/gutenberg#85455) - Core Fields: Prevent extra space between `/` and text in slug input (WordPress/gutenberg#85935) - Notes: Add search and a status filter to the All Notes sidebar (WordPress/gutenberg#84060) - Notes: Use the note permission check when deleting a reaction (WordPress/gutenberg#85883) - [WP 7.2] Math block: Keyboard focus is trapped in the LaTeX field when the formula has an error (WordPress/gutenberg#86032) - Core fields: Keep the status icon full size when its label wraps (WordPress/gutenberg#85828) (#86050) - [WP 7.2] ToolsPanel: Keep the "Reset" label visible on the highlighted menu item (WordPress/gutenberg#86060) - Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content (WordPress/gutenberg#84919) (#86059) - [WP 7.2] wp-build: Derive CSS module class names from each stylesheet's CSS (WordPress/gutenberg#86062) - Playlist: Allow track without an attachment ID to render on the frontend (WordPress/gutenberg#83880) (#86158) - UI: Show only the day number in Calendar day cells (WordPress/gutenberg#86010) (#86183) - Notes: Tolerate a null comment in the reaction cascade hooks (WordPress/gutenberg#85959) - Rich Text: Remove stale format boundary when field loses selection (WordPress/gutenberg#86168) - Notes: Only let a reaction's author delete it (WordPress/gutenberg#85415) - Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen (WordPress/gutenberg#85408) - Try: Run e2e tests in parallel, on one wp-env site per two cores (WordPress/gutenberg#85420) - Raw handling: Keep shortcodes in text inline (WordPress/gutenberg#85795) - Fix: Fixes non-breaking space replacement tooltip (WordPress/gutenberg#85777) - Non-breaking space: Remove non-breaking spaces that would collapse when replaced (WordPress/gutenberg#85873) Props mamaduka. See #66340. git-svn-id: https://develop.svn.wordpress.org/trunk@65225 602fd350-edb4-49c9-b593-d223f7449a82
This updates the pinned commit hash of the Gutenberg repository from `cc75a79186fd23e72eb015d594e82f40c6209eb5` to `c035c1a649ef68f5c1646694cf440df1d7ae6e62` (fixes cherry-picked to the `wp/7.2` branch). A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@cc75a79...c035c1a - Components: Use solid brand highlights for popup items (WordPress/gutenberg#84583) (#85848) - Fix endless sideload loop when the browser can't decode a big image (WordPress/gutenberg#83530) - Notes: Show reaction picker as a row of emoji (WordPress/gutenberg#85819) (#85892) - Notes: Add thumbs up and plus reactions (WordPress/gutenberg#85565) - Notes: Share thread focus recovery across actions (WordPress/gutenberg#85455) - Core Fields: Prevent extra space between `/` and text in slug input (WordPress/gutenberg#85935) - Notes: Add search and a status filter to the All Notes sidebar (WordPress/gutenberg#84060) - Notes: Use the note permission check when deleting a reaction (WordPress/gutenberg#85883) - [WP 7.2] Math block: Keyboard focus is trapped in the LaTeX field when the formula has an error (WordPress/gutenberg#86032) - Core fields: Keep the status icon full size when its label wraps (WordPress/gutenberg#85828) (#86050) - [WP 7.2] ToolsPanel: Keep the "Reset" label visible on the highlighted menu item (WordPress/gutenberg#86060) - Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content (WordPress/gutenberg#84919) (#86059) - [WP 7.2] wp-build: Derive CSS module class names from each stylesheet's CSS (WordPress/gutenberg#86062) - Playlist: Allow track without an attachment ID to render on the frontend (WordPress/gutenberg#83880) (#86158) - UI: Show only the day number in Calendar day cells (WordPress/gutenberg#86010) (#86183) - Notes: Tolerate a null comment in the reaction cascade hooks (WordPress/gutenberg#85959) - Rich Text: Remove stale format boundary when field loses selection (WordPress/gutenberg#86168) - Notes: Only let a reaction's author delete it (WordPress/gutenberg#85415) - Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen (WordPress/gutenberg#85408) - Try: Run e2e tests in parallel, on one wp-env site per two cores (WordPress/gutenberg#85420) - Raw handling: Keep shortcodes in text inline (WordPress/gutenberg#85795) - Fix: Fixes non-breaking space replacement tooltip (WordPress/gutenberg#85777) - Non-breaking space: Remove non-breaking spaces that would collapse when replaced (WordPress/gutenberg#85873) Props mamaduka. See #66340. Built from https://develop.svn.wordpress.org/trunk@65225 git-svn-id: http://core.svn.wordpress.org/trunk@64374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This updates the pinned commit hash of the Gutenberg repository from `cc75a79186fd23e72eb015d594e82f40c6209eb5` to `c035c1a649ef68f5c1646694cf440df1d7ae6e62` (fixes cherry-picked to the `wp/7.2` branch). A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@cc75a79...c035c1a - Components: Use solid brand highlights for popup items (WordPress/gutenberg#84583) (#85848) - Fix endless sideload loop when the browser can't decode a big image (WordPress/gutenberg#83530) - Notes: Show reaction picker as a row of emoji (WordPress/gutenberg#85819) (#85892) - Notes: Add thumbs up and plus reactions (WordPress/gutenberg#85565) - Notes: Share thread focus recovery across actions (WordPress/gutenberg#85455) - Core Fields: Prevent extra space between `/` and text in slug input (WordPress/gutenberg#85935) - Notes: Add search and a status filter to the All Notes sidebar (WordPress/gutenberg#84060) - Notes: Use the note permission check when deleting a reaction (WordPress/gutenberg#85883) - [WP 7.2] Math block: Keyboard focus is trapped in the LaTeX field when the formula has an error (WordPress/gutenberg#86032) - Core fields: Keep the status icon full size when its label wraps (WordPress/gutenberg#85828) (#86050) - [WP 7.2] ToolsPanel: Keep the "Reset" label visible on the highlighted menu item (WordPress/gutenberg#86060) - Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content (WordPress/gutenberg#84919) (#86059) - [WP 7.2] wp-build: Derive CSS module class names from each stylesheet's CSS (WordPress/gutenberg#86062) - Playlist: Allow track without an attachment ID to render on the frontend (WordPress/gutenberg#83880) (#86158) - UI: Show only the day number in Calendar day cells (WordPress/gutenberg#86010) (#86183) - Notes: Tolerate a null comment in the reaction cascade hooks (WordPress/gutenberg#85959) - Rich Text: Remove stale format boundary when field loses selection (WordPress/gutenberg#86168) - Notes: Only let a reaction's author delete it (WordPress/gutenberg#85415) - Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen (WordPress/gutenberg#85408) - Try: Run e2e tests in parallel, on one wp-env site per two cores (WordPress/gutenberg#85420) - Raw handling: Keep shortcodes in text inline (WordPress/gutenberg#85795) - Fix: Fixes non-breaking space replacement tooltip (WordPress/gutenberg#85777) - Non-breaking space: Remove non-breaking spaces that would collapse when replaced (WordPress/gutenberg#85873) Props mamaduka. See #66340. git-svn-id: https://develop.svn.wordpress.org/trunk@65225 602fd350-edb4-49c9-b593-d223f7449a82
What?
Follow-up to #84652.
Client-side navigation now ignores router regions inside
data-wp-htmlcontent and never attaches a region to an element inside that content. A region whoseattachTohas no usable target is skipped instead of breaking navigation.Why?
Since #84652, the content of a
data-wp-htmlelement is inert: the runtime doesn't hydrate it or run its directives. The router didn't follow. It scans whole documents fordata-wp-router-region, so a region inside adata-wp-htmlelement's fallback, or inside inserted HTML that ends up in a fetched page, was extracted and rendered during navigation. A fallback copy could replace a real region with the same ID, and a region withattachToinside that content was created anyway.Separately, when an
attachToselector matched nothing,renderPage()passednullto aWeakMap, which threw and stopped the whole render. An invalid selector threw too.How?
parseDirectiveName()is exported fromvdom.tsand added toprivateApis().toVdom()is unchanged.closestHtmlDirectiveElement()(packages/interactivity-router/src/html-directive-element.ts) appliestoVdom()'s rule from markup alone: inside an interactive region, an element owns its content when it has adata-wp-htmlentry without a suffix and nodata-wp-text,data-wp-eachordata-wp-router-region. A unit test compares it with the realtoVdom()across directive spellings, so the two can't drift silently.preparePage()and the initial-pageattachToscan skip regions inside that content. A region that carriesdata-wp-htmlitself, or sits inside an element wheredata-wp-htmlyields, is still a region.attachTo.renderPage()resolves each selector against the live document on every render, including Back and Forward, to the first match that is neither adata-wp-htmlelement nor inside one. With no usable target (no match, only unusable matches, or an invalid selector), the region is left out of that render and the rest of the navigation completes. The cached page isn't changed, so a later render tries again.Unchanged: a region that is already attached and gets a different
attachTotarget on a later page is rendered in both targets. This happens on trunk too.Testing Instructions
npm run test:unit:vitest -- packages/interactivity packages/interactivity-router. Covers region discovery on prepared pages,attachToresolution and skipping (including Back, Forward and later retries), and the router check's agreement withtoVdom().npm run test:e2e -- test/e2e/specs/interactivity/router-html-regions.spec.ts test/e2e/specs/interactivity/router-regions.spec.ts. Covers fallback copies ignored through navigation and history, a real region still attaching despite a fallback copy, and unchanged behavior for regular regions.Optional: check it by hand
On a site with Gutenberg,
SCRIPT_DEBUGon, and Chrome (no e2e plugins needed):wp-content/mu-plugins/router-manual.phpwith the PHP snippet below.B_URLandATTACH_URLin Router A with the published pages' URLs before saving.Checks:
#inside-targetto#missingand save. Start again from Router A and click Go to Attach. trunk: an uncaughtTypeError: Invalid value used as weak map key; Page A and Real A disappear, the status stays Navigating, and the URL and browser title stay on Router A. This PR: the same successful result as check 2, without ATTACHED or an error. Back → Forward still works; then Go to B shows Real B.[[, save, and repeat check 3. trunk: an uncaughtSyntaxErrorsaying[[is not a valid selector, with the same unfinished navigation. This PR: the same successful result as check 3.Remove the mu-plugin and test pages when finished.
wp-content/mu-plugins/router-manual.php:Router Attach:
Router B:
Router A (replace both URL placeholders):
Testing Instructions for Keyboard
Not applicable: no UI changes.
Use of AI Tools
100% of the code, tests, and comments in this PR were autonomously generated by AI and reviewed by @DAreRodz before the PR was opened.