Skip to content

Interactivity API: Show the data-wp-html fallback on created elements under Trusted Types - #84924

Merged
luisherranz merged 11 commits into
trunkfrom
fix/interactivity-data-wp-html-created-element-fallback
Nov 4, 2026
Merged

luisherranz merged 11 commits into
trunkfrom
fix/interactivity-data-wp-html-created-element-fallback

Conversation

@luisherranz

@luisherranz luisherranz commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

What?

Follow-up to #84652 and #84889.

Elements the client creates instead of hydrating, such as data-wp-each items added after hydration or elements a client-side navigation adds, now show their data-wp-html fallback on sites enforcing Trusted Types while their value is pending or { "wpServerHtml": true }. This removes the known limitation documented in #84652.

Why?

When Preact creates an element, it writes dangerouslySetInnerHTML.__html with innerHTML. While the value was pending, the directive handed Preact the fallback as a plain string, so a site enforcing Trusted Types rejected it, or a default policy rewrote it. Created elements on those sites therefore had to have an empty fallback. The package deliberately creates no Trusted Types policy of its own, so writing the fallback as a string can't be made to work.

How?

  • toVdom() keeps a detached copy of each data-wp-html element's content, next to the existing string, without its <script> elements (getHtmlFallback()).
  • The copy is imported node by node into the document that already holds the live page's <template> contents (document.createElement( 'template' ).content.ownerDocument). That document is inert, so the copy starts no resource loads, and it doesn't belong to the page the router parsed, so that page can be released after navigation. Nested <template> contents go into the same document.
  • The directive always gives Preact the policy-free empty HTML, so Preact never writes HTML for it.
  • In a layout effect, before paint, at the first commit on each host element, the directive inserts a copy of the snapshot with importNode() when the element is empty and its value is pending or the server representation. Cloning and inserting nodes isn't a Trusted Types sink. Later values follow the existing value rule, and the fallback doesn't come back after a value empties the element.
  • The directive's record of the HTML it last applied now belongs to the host element, not to its component. Preact can keep the directive's component while creating a new host beneath it, for example when navigation swaps a div for a span at the same position, and the old host's record would otherwise leave the new host empty.
  • <script> elements are left out of the copy so they never run. Scripts written with innerHTML never ran either, but inserted copies of template content would.
  • An element named template outside the HTML namespace, such as <svg><template>, is copied as an ordinary element with its children.

Trade-off: the copy is taken for every data-wp-html element each time toVdom() runs (the initial page and every page the router fetches), even when the value is a token. It can't be taken lazily, because the original element may have changed by the time a new host needs it.

Changes since the first review

  • Fallback media was requested twice, and every fetched or prefetched page stayed in memory, because the copy was cloned inside the page being parsed. Copies now live in the template-contents document instead.
  • A document from document.implementation.createHTMLDocument(), as suggested, also fixes both issues. However, the first <template> imported into it makes the browser create a second inert document to hold template contents. The live page's template-contents document already exists, and nested templates reuse it.
  • New e2e tests cover these cases: a hydrated fallback requests its media once, prefetching a page requests none of its fallback media, and navigating doesn't increase the number of HTMLDocuments in the heap.
  • A fallback containing <svg><template> threw during hydration and stopped later interactive regions from hydrating. This is now fixed and tested.
  • The handbook now says that a created element's fallback never goes through a Trusted Types policy, including a default policy, so fallback markup must come from trusted content.
  • Merged trunk, resolving an import conflict with the recent directive-processing hardening.

Testing Instructions

  1. Activate the "Gutenberg Test Interactive Blocks" plugin (it ships with the e2e test environment) and publish a post containing the test/directive-html block.
  2. Open the post with ?require_trusted_types=true appended to the URL. The response carries Content-Security-Policy: require-trusted-types-for 'script'.
  3. Click "Add fallback". The new item shows "Loading". On trunk it stays empty, and the console reports a Trusted Types violation.
  4. Click "Add script items". The items show "Loading", and window.fallbackRuns stays undefined.
  5. For the resource and memory fixes, follow the reproduction from the review: a Query Loop with enhanced pagination whose post template contains a data-wp-html fallback with a <video preload="metadata">. Open DevTools → Network filtered by the video's name: there is one request. Hover the Next link: no new request. In Memory, take heap snapshots before and after navigating Next, Next, Previous: the HTMLDocument count stays the same.
  6. Automated:
    • npm run test:unit:vitest -- packages/interactivity
    • npm run test:e2e -- test/e2e/specs/interactivity/directive-html.spec.ts test/e2e/specs/interactivity/router-html.spec.ts

Testing Instructions for Keyboard

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 @luisherranz before the PR was opened.

@github-actions github-actions Bot added [Package] E2E Tests /packages/e2e-tests [Package] Interactivity /packages/interactivity labels Oct 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: luisherranz <luisherranz@git.wordpress.org>
Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: +243 B (0%)

Total Size: 8.56 MB

📦 View Changed
Filename Size Change
build/modules/interactivity/index.min.js 16.2 kB +243 B (+1.52%)

6c78e96 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 19d5adb trunk % Change
timeToFirstByte 45.75 ms +16.61% -6.12% 47.55 ms +5.05% -3.15% -3.79%
largestContentfulPaint 78 ms +7.69% -7.69% 76 ms +13.16% -2.63% 2.63%
lcpMinusTtfb 28.65 ms +17.45% -5.76% 29.45 ms +6.62% -3.4% -2.72%
wpBeforeTemplate 23.13 ms +21.62% -3.46% 24.37 ms +10.01% -4.47% -5.09%
wpTemplate 17.76 ms +4.67% -7.21% 18.92 ms +7.29% -6.45% -6.13%
wpTotal 41.29 ms +14.8% -5.3% 44.09 ms +4.81% -3.36% -6.35%
wpMemoryUsage 7.70 MB +0% -0% 7.67 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 19d5adb trunk % Change
timeToFirstByte 38.8 ms +5.8% -6.7% 38.05 ms +7.23% -3.29% 1.97%
largestContentfulPaint 84 ms +4.76% -2.38% 84 ms +2.38% -4.76% 0%
lcpMinusTtfb 45.55 ms +4.28% -2.63% 44.85 ms +2.12% -2.68% 1.56%
wpBeforeTemplate 20.55 ms +9.68% -4.72% 20.52 ms +7.94% -4.09% 0.15%
wpTemplate 14.63 ms +7.04% -6.22% 14.17 ms +6.21% -4.09% 3.25%
wpTotal 35.75 ms +5.76% -7.22% 35.1 ms +7.18% -3.3% 1.85%
wpMemoryUsage 6.40 MB +0% -0% 6.36 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 19d5adb trunk % Change
mediaProcessingJpeg 336.59 ms +0.3% -1.89% 331.63 ms +1.96% -0.21% 1.5%
mediaProcessingAvif 4939.38 ms +0.43% -0.63% 4878.67 ms +0.14% -0.33% 1.24%
mediaProcessingJpegToAvif 3433.15 ms +0.39% -0.82% 3402.82 ms +0.63% -0.36% 0.89%

media-upload

Metric 19d5adb trunk % Change
jpegUploadProcessing 1436.97 ms +0.86% -0.57% 1452.22 ms +1.1% -1.5% -1.05%
pngUploadProcessing 239.92 ms +1.16% -6.46% 259.76 ms +1.87% -12.14% -7.64%
largeJpegUploadProcessing 1448.82 ms +3% -0.85% 1436.32 ms +0.82% -0.81% 0.87%
multipleImageUploadProcessing 1570.24 ms +0.76% -2.19% 1508.45 ms +0.94% -1.87% 4.1%

post-editor

Metric 19d5adb trunk % Change
serverResponse 535.86 ms +3.67% -4.78% 527.81 ms +5.76% -6.65% 1.53%
firstPaint 507.56 ms +1.9% -19.74% 455.07 ms +13.78% -32.9% 11.53%
domContentLoaded 882.88 ms +2.98% -4.47% 888.3 ms +1.17% -4.59% -0.61%
loaded 884.14 ms +3.01% -4.49% 889.39 ms +1.2% -4.57% -0.59%
firstContentfulPaint 514.86 ms +1.08% -5.82% 512.31 ms +1.06% -14.24% 0.5%
firstBlock 2956.95 ms +0.94% -0.69% 2970.35 ms +0.44% -1.19% -0.45%
type 17.75 ms +9.8% -7.89% 18.65 ms +1.66% -15.23% -4.83%
typeWithoutInspector 17.52 ms +10.27% -3.54% 17.53 ms +3.08% -7.42% -0.06%
typeWithTopToolbar 23.33 ms +1.46% -9.99% 21.46 ms +8.48% -4.75% 8.71%
typeContainer 8.38 ms +1.55% -11.34% 8.36 ms +3.23% -6.1% 0.24%
focus 114.19 ms +16.59% -6.31% 116.23 ms +5.39% -7.46% -1.76%
firstFocus 240.69 ms +0% -0% 232.15 ms +0% -0% 3.68%
selectAll 460.79 ms +4.31% -3.44% 448.46 ms +10.02% -1.14% 2.75%
undo 31.07 ms +8.34% -6.6% 30.16 ms +1.92% -5.67% 3.02%
listViewOpen 82.87 ms +6.64% -5.42% 73.11 ms +3.45% -4.1% 13.35%
inserterOpen 41.29 ms +8.62% -8.72% 40.91 ms +5.01% -10.34% 0.93%
inserterHover 11.05 ms +8.78% -10.59% 10.48 ms +11.74% -4.68% 5.44%
inserterSearch 8.09 ms +10.38% -5.81% 7.82 ms +7.42% -5.37% 3.45%
loadPatterns 647.01 ms +1.85% -5.52% 615.23 ms +7.11% -5.89% 5.17%
wpTotal 525.06 ms +3.57% -4.72% 517.29 ms +5.94% -6.78% 1.5%
wpMemoryUsage 14.73 MB +0% -0% 14.72 MB +0% -0% 0.1%
wpDbQueries 55 +0% -1.82% 55 +0% -1.82% 0%

site-editor

Metric 19d5adb trunk % Change
serverResponse 424.15 ms +3.47% -3.17% 436.75 ms +1.3% -3.35% -2.88%
firstPaint 275.16 ms +11.64% -7.79% 246.57 ms +9.47% -11.21% 11.6%
domContentLoaded 923.98 ms +5.5% -1% 896.48 ms +1.92% -1.19% 3.07%
loaded 925.18 ms +5.5% -1.02% 897.65 ms +1.95% -1.21% 3.07%
firstContentfulPaint 523.81 ms +3.31% -3.25% 490.82 ms +6.68% -3.97% 6.72%
firstBlock 3939.77 ms +3.36% -1.41% 3836.83 ms +0.58% -2.13% 2.68%
type 21.7 ms +8.06% -12.81% 22.06 ms +4.22% -18.68% -1.63%
navigate 125.27 ms +5.65% -3.61% 117.08 ms +7.73% -7.29% 7%
loadPatterns 1168.67 ms +4.45% -1.4% 1128.41 ms +9.22% -4.8% 3.57%
loadPages 962.21 ms +3.45% -0.23% 1003.22 ms +1.47% -1.67% -4.09%
wpTotal 413.12 ms +3.51% -3.31% 425.2 ms +0.53% -3.24% -2.84%
wpMemoryUsage 12.77 MB +0% -0% 12.73 MB +0% -0% 0.27%
wpDbQueries 44 +2.27% -0% 44 +2.27% -0% 0%

6c78e96 Run

🏁 Flaky tests

Some 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.

As a site builder, I want to insert a core navigation overlay pattern with CTA and see it on the frontend (Site Editor v2) in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator:  getByRole('option', { name: /Overlay with site info and CTA/i })
Expected: visible
Received: hidden
Timeout:  5000ms

Call log:
  - Expect "toBeVisible" getByRole('option', { name: /Overlay with site info and CTA/i }) with timeout 5000ms
  - waiting for getByRole('option', { name: /Overlay with site info and CTA/i })
    14 × locator resolved to <div role="option" tabindex="-1" data-base-ui-tooltip-trigger="" aria-label="Overlay with site info and CTA" class="block-editor-block-patterns-list__item" id="core/navigation-overlay-centered-with-extras" aria-describedby="block-editor-block-patterns-list__item-description-4">…</div>
       - unexpected value "hidden"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:254:31
Undo restores the post selection when another synced entity is loaded in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 6,
+   "offset": 6,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
can be converted to a quote in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 1
+ Received  + 1

@@ -1,9 +1,9 @@
  <!-- wp:quote -->
  <blockquote class="wp-block-quote"><!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>one</li>
+ <li>e</li>
  <!-- /wp:list-item -->

  <!-- wp:list-item -->
  <li>two</li>
  <!-- /wp:list-item --></ul>

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:436:52
inserts a block should show a blue line indicator in /test/e2e/specs/editor/various/inserting-blocks.spec.js, passed after 1 failed attempt.
TimeoutError: locator.boundingBox: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('data-testid=block-list-insertion-point-indicator')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/inserting-blocks.spec.js:678:41
keeps the inline inserter open when the Block Library panel closes in /test/e2e/specs/editor/various/inserting-blocks.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeHidden() failed

Locator:  getByRole('region', { name: 'Block Library' })
Expected: hidden
Received: visible
Timeout:  5000ms

Call log:
  - Expect "toBeHidden" getByRole('region', { name: 'Block Library' }) with timeout 5000ms
  - waiting for getByRole('region', { name: 'Block Library' })
    13 × locator resolved to <div role="region" tabindex="-1" aria-label="Block Library" class="admin-ui-navigable-region interface-interface-skeleton__secondary-sidebar">…</div>
       - unexpected value "visible"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/inserting-blocks.spec.js:619:32
should cut and paste individual blocks with collapsed selection in /test/e2e/specs/editor/various/copy-cut-paste.spec.js, passed after 1 failed attempt.
Error: expect(string).toMatchSnapshot(expected) failed

  @@ -1,3 +1,3 @@
   <!-- wp:paragraph -->
  -<p>2Cut - collapsed selection</p>
  +<p>2</p>
   <!-- /wp:paragraph -->


    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/copy-cut-paste.spec.js:45:49
should give the image its context menu while selected @WebKit @Firefox in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Test timeout of 100000ms exceeded.
should insert a line break on shift+enter in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 1
+ Received  + 1

  <!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>a<br></li>
+ <li><br></li>
  <!-- /wp:list-item --></ul>
  <!-- /wp:list -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:1210:52
should merge a following sibling list into the outermost list with Delete from a nested item (#77245) in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

@@ -8,11 +8,11 @@
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {
                  "attributes": Object {
-                   "content": "b‸",
+                   "content": "b",
                  },
                  "name": "core/list-item",
                },
              ],
              "name": "core/list",
@@ -25,11 +25,11 @@
    },
    Object {
      "innerBlocks": Array [
        Object {
          "attributes": Object {
-           "content": "1",
+           "content": "‸1",
          },
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:2854:41
should place the caret at the click position when clicking a block that is not selected in /test/e2e/specs/editor/various/writing-flow.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

@@ -1,9 +1,9 @@
  Array [
    Object {
      "attributes": Object {
-       "content": "First!",
+       "content": "First",
      },
      "name": "core/paragraph",
    },
    Object {
      "attributes": Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/writing-flow.spec.js:952:41
should replace selected non-breaking spaces from the toolbar in /test/e2e/specs/editor/various/rich-text.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

  Array [
    Object {
      "attributes": Object {
-       "content": "one two three",
+       "content": "ne two three",
      },
      "name": "core/paragraph",
    },
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/rich-text.spec.js:1053:41
should select by dragging into nested block in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 2
+ Received  + 1

  Array [
-   1,
-   2,
+   3,
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:568:5
should undo without broken temporary state in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:image -->
- <figure class="wp-block-image"><img alt=""/></figure>
+ <!-- wp:image {"id":22,"sizeSlug":"full","linkDestination":"none"} -->
+ <figure class="wp-block-image size-full"><img src="http://localhost:8889/wp-content/uploads/2026/10/c578fd55-7920-4fc7-86f9-540bf4dad2b0.png" alt="" class="wp-image-22"/></figure>
  <!-- /wp:image -->
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/image.spec.js:432:49

6c78e96 Run

@luisherranz luisherranz added [Type] Bug An existing feature does not function as intended and removed [Package] E2E Tests /packages/e2e-tests labels Oct 16, 2026
@luisherranz luisherranz self-assigned this Oct 16, 2026
@github-actions github-actions Bot added the [Package] E2E Tests /packages/e2e-tests label Oct 16, 2026
@luisherranz luisherranz mentioned this pull request Oct 16, 2026
19 of 24 tasks
Base automatically changed from add/interactivity-data-wp-html-server-representation to trunk October 16, 2026 12:27
@luisherranz
luisherranz force-pushed the fix/interactivity-data-wp-html-created-element-fallback branch from 682a4e9 to e22c7ca Compare October 16, 2026 13:22

@SantosGuillamot SantosGuillamot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed and tested this and it looks good, except for something Claude raised while reviewing it, which seems to be legit: the fallback snapshot keeps fetched pages in memory and loads fallback media twice.

toVdom() now clones the content of every data-wp-html element into a snapshot (packages/interactivity/src/vdom.ts:324-327). The clone is made inside the document the element belongs to, which has two side effects:

Testing instructions

  1. Create some published posts to have pagination in the Query Loop.
  2. Create a page with this content in the code editor:
<!-- wp:query {"queryId":2,"query":{"perPage":1,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false},"enhancedPagination":true} -->
<div class="wp-block-query"><!-- wp:post-template -->
<!-- wp:post-title /-->
<!-- /wp:post-template -->

<!-- wp:html -->
<div data-wp-context='{"html":{"wpServerHtml":true}}' data-wp-html="context.html">
	<p>Fallback content</p>
	<video src="/demo-video.mp4" preload="metadata"></video>
</div>
<!-- /wp:html -->

<!-- wp:query-pagination -->
<!-- wp:query-pagination-previous /-->

<!-- wp:query-pagination-numbers /-->

<!-- wp:query-pagination-next /-->
<!-- /wp:query-pagination --></div>
<!-- /wp:query -->

Test 1: fallback media is loaded twice

Open the page with DevTools open and the Network panel filtered by demo-video (the file doesn't exist, a 404 is fine).

trunk this PR
Requests for demo-video.mp4 1 2

The server-rendered <video> loads once, and the clone made inside the live document starts a second load.

Test 2: fetched pages are never released

Remove the <video> line from the page. Then open the page, DevTools → Memory → take a heap snapshot, type HTMLDocument in the class filter and note the count after the ×. Click Next twice and Previous once, take another snapshot, read the count again.

trunk this PR
HTMLDocument before navigating 1 1
HTMLDocument after navigating 1 5

Hovering pagination links prefetches, so it grows on hover too.

Potential path (Suggested by Claude)

Build the snapshot in a single inert document created once with document.implementation.createHTMLDocument( '' ), using importNode() into it instead of cloneNode(). Nodes in an inert document don't load resources, don't upgrade custom elements, and don't keep the parsed page alive. The insertion in directives/html.ts can stay as it is, since importing into the live document at that point is where loads should happen.

Importing or adopting the snapshot into the live document instead would trade one problem for another: a detached <video> imported into the live document starts loading immediately, so every fetched and prefetched page would download the media inside its fallbacks.

@luisherranz

Copy link
Copy Markdown
Member Author

Thanks for the review, Mario!

The snapshots are now created in an inert document, so the fallback media loads once and fetched pages are released. I also added e2e tests for both cases.

@SantosGuillamot SantosGuillamot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🙂 I tested the previously raised issued, and I can't reproduce it anymore

@luisherranz luisherranz added Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta and removed [Package] E2E Tests /packages/e2e-tests labels Nov 4, 2026
@luisherranz
luisherranz merged commit 79ec6bf into trunk Nov 4, 2026
111 of 114 checks passed
@luisherranz
luisherranz deleted the fix/interactivity-data-wp-html-created-element-fallback branch November 4, 2026 13:20
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

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.

# Checkout the wp/7.2 branch instead of trunk.
git checkout wp/7.2

# Create a new branch for your PR.
git checkout -b my-branch

# Cherry-pick the commit.
git cherry-pick 79ec6bf2d6d5a6ff28d2d9c3fcd9a9f1b7af100d

# Check which files have conflicts.
git status

# Resolve the conflict...
# Add the resolved files to the staging area.
git status
git add .
git cherry-pick --continue

# Push the branch to the repository
git push origin my-branch

# Create a PR and set the base to the wp/7.2 branch.
# See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request.

luisherranz added a commit that referenced this pull request Nov 4, 2026
… under Trusted Types (#84924) (#86306)

* Interactivity API: Show the data-wp-html fallback on created elements by copying its nodes

* Interactivity API: Add e2e tests for created data-wp-html fallbacks

* Interactivity API: Document created data-wp-html fallbacks

* Apply batched suggestions from code review



* Interactivity API: Remove an extra blank line from the data-wp-html docs

* Interactivity API: Keep data-wp-html fallback snapshots in the live document's template contents document

* Interactivity API: Restore the e2e tests of created data-wp-html fallbacks

* Interactivity API: Copy non-HTML template elements in data-wp-html fallbacks as ordinary elements

* Interactivity API: Move the created data-wp-html fallback changelog entry to Unreleased

* Interactivity API: Document that created data-wp-html fallbacks bypass Trusted Types policies



(cherry picked from commit 79ec6bf)

Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org>
@luisherranz luisherranz removed the Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Nov 4, 2026
wporg-sync pushed a commit to WordPress/wordpress-develop that referenced this pull request Nov 10, 2026
This updates the pinned commit hash of the Gutenberg repository from `c035c1a649ef68f5c1646694cf440df1d7ae6e62` to `1b0dc90c700746b108e080263a4dc67707b750a1` (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@c035c1a...1b0dc90

- [WP 7.2] Components, UI: Use focus-visible for disabled item focus rings (WordPress/gutenberg#86269)
- Notes: Keep the canvas still when a new note is added (WordPress/gutenberg#86283) (#86293)
- Post summary: Show placeholders for an empty excerpt and a missing author (WordPress/gutenberg#85842) (#86294)
- Core fields: Restore the previous Publish and Status panel date behaviour (WordPress/gutenberg#86065) (#86295)
- Interactivity API: Show the data-wp-html fallback on created elements under Trusted Types (WordPress/gutenberg#84924) (#86306)
- [WP 7.2] UI: Add LoadingIndicator to item popups (WordPress/gutenberg#86303)
- Interactivity Router: Fix nested router regions without data-wp-interactive disappearing on navigation (WordPress/gutenberg#86061) (#86308)
- Interactivity API: Run watch() cleanups and attachTo render callbacks without a directive scope (WordPress/gutenberg#86058) (#86311)
- DataForm: Fix clipped focus ring of field values in panel layout (WordPress/gutenberg#86361) (#86369)
- Tests: Avoid passing an object when invoking static methods via reflection. (WordPress/gutenberg#86329)
- [WP 7.2] DropdownMenu: Invert the selected item indicator while highlighted (WordPress/gutenberg#86379)
- Fields: Lowercase the (no excerpt), (no author) and (no description) placeholders (WordPress/gutenberg#86391) (#86424)
- Core fields: Decode non-Latin slugs in the slug field (WordPress/gutenberg#86359)
- Interactivity API: Show the new page's server content in kept data-wp-html elements (WordPress/gutenberg#86416)
- DataForm: Tighten value density in the panel layout (WordPress/gutenberg#86389) (#86426)
- Post summary: Show "Immediately" and relative publish dates in the Date row (WordPress/gutenberg#86367)
- [WP 7.2] Block Styles: Show the active style variation in forced colors mode (WordPress/gutenberg#86450)
- Site Editor: Fix the frame snapping to the mobile width when resized with the mouse (WordPress/gutenberg#86423)
- Image: measure the lightbox container, not the image's parent (WordPress/gutenberg#82312) (#85491)
- URL: Decode percent-encoded characters in getFilename (WordPress/gutenberg#86422) (#86477)
- Fix: Hide the author avatar when the site does not show avatars and frame a blank one. (WordPress/gutenberg#86395)
- Date picker: Mark the posts of the month a typed or reset date moves to (WordPress/gutenberg#86298) (#86463)
- Fix iOS 27 tap into a heading leaving the caret in a quote (WordPress/gutenberg#85809)
- Hand focus back to the field on a press in every browser (WordPress/gutenberg#86549)
- Prevent jobs from running within forks on `push`. (WordPress/gutenberg#85968)
- i18n: Add translator context to the "Copy error" button label (WordPress/gutenberg#85967)
- Bubble editor canvas events to the outer iframe (WordPress/gutenberg#85263)
- UI: Use LoadingIndicator in remaining popup consumers (WordPress/gutenberg#86501)
- Block Editor: Keep the revision canvas read-only in preview mode (WordPress/gutenberg#84578)
- Core Data: Rank an exact title match first among tied link suggestions (WordPress/gutenberg#86327)
- Tests: Render the router-html-server context case through state (WordPress/gutenberg#86511)
- iOS tests: De-flake the selection handle test (WordPress/gutenberg#85461)

Props mamaduka, wildworks.
See #66340.

git-svn-id: https://develop.svn.wordpress.org/trunk@65379 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 10, 2026
This updates the pinned commit hash of the Gutenberg repository from `c035c1a649ef68f5c1646694cf440df1d7ae6e62` to `1b0dc90c700746b108e080263a4dc67707b750a1` (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@c035c1a...1b0dc90

- [WP 7.2] Components, UI: Use focus-visible for disabled item focus rings (WordPress/gutenberg#86269)
- Notes: Keep the canvas still when a new note is added (WordPress/gutenberg#86283) (#86293)
- Post summary: Show placeholders for an empty excerpt and a missing author (WordPress/gutenberg#85842) (#86294)
- Core fields: Restore the previous Publish and Status panel date behaviour (WordPress/gutenberg#86065) (#86295)
- Interactivity API: Show the data-wp-html fallback on created elements under Trusted Types (WordPress/gutenberg#84924) (#86306)
- [WP 7.2] UI: Add LoadingIndicator to item popups (WordPress/gutenberg#86303)
- Interactivity Router: Fix nested router regions without data-wp-interactive disappearing on navigation (WordPress/gutenberg#86061) (#86308)
- Interactivity API: Run watch() cleanups and attachTo render callbacks without a directive scope (WordPress/gutenberg#86058) (#86311)
- DataForm: Fix clipped focus ring of field values in panel layout (WordPress/gutenberg#86361) (#86369)
- Tests: Avoid passing an object when invoking static methods via reflection. (WordPress/gutenberg#86329)
- [WP 7.2] DropdownMenu: Invert the selected item indicator while highlighted (WordPress/gutenberg#86379)
- Fields: Lowercase the (no excerpt), (no author) and (no description) placeholders (WordPress/gutenberg#86391) (#86424)
- Core fields: Decode non-Latin slugs in the slug field (WordPress/gutenberg#86359)
- Interactivity API: Show the new page's server content in kept data-wp-html elements (WordPress/gutenberg#86416)
- DataForm: Tighten value density in the panel layout (WordPress/gutenberg#86389) (#86426)
- Post summary: Show "Immediately" and relative publish dates in the Date row (WordPress/gutenberg#86367)
- [WP 7.2] Block Styles: Show the active style variation in forced colors mode (WordPress/gutenberg#86450)
- Site Editor: Fix the frame snapping to the mobile width when resized with the mouse (WordPress/gutenberg#86423)
- Image: measure the lightbox container, not the image's parent (WordPress/gutenberg#82312) (#85491)
- URL: Decode percent-encoded characters in getFilename (WordPress/gutenberg#86422) (#86477)
- Fix: Hide the author avatar when the site does not show avatars and frame a blank one. (WordPress/gutenberg#86395)
- Date picker: Mark the posts of the month a typed or reset date moves to (WordPress/gutenberg#86298) (#86463)
- Fix iOS 27 tap into a heading leaving the caret in a quote (WordPress/gutenberg#85809)
- Hand focus back to the field on a press in every browser (WordPress/gutenberg#86549)
- Prevent jobs from running within forks on `push`. (WordPress/gutenberg#85968)
- i18n: Add translator context to the "Copy error" button label (WordPress/gutenberg#85967)
- Bubble editor canvas events to the outer iframe (WordPress/gutenberg#85263)
- UI: Use LoadingIndicator in remaining popup consumers (WordPress/gutenberg#86501)
- Block Editor: Keep the revision canvas read-only in preview mode (WordPress/gutenberg#84578)
- Core Data: Rank an exact title match first among tied link suggestions (WordPress/gutenberg#86327)
- Tests: Render the router-html-server context case through state (WordPress/gutenberg#86511)
- iOS tests: De-flake the selection handle test (WordPress/gutenberg#85461)

Props mamaduka, wildworks.
See #66340.
Built from https://develop.svn.wordpress.org/trunk@65379


git-svn-id: http://core.svn.wordpress.org/trunk@64518 1a063a9b-81f0-0310-95a4-ce76da25c4cd
arshidkv12 pushed a commit to arshidkv12/wordpress-develop that referenced this pull request Nov 21, 2026
This updates the pinned commit hash of the Gutenberg repository from `c035c1a649ef68f5c1646694cf440df1d7ae6e62` to `1b0dc90c700746b108e080263a4dc67707b750a1` (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@c035c1a...1b0dc90

- [WP 7.2] Components, UI: Use focus-visible for disabled item focus rings (WordPress/gutenberg#86269)
- Notes: Keep the canvas still when a new note is added (WordPress/gutenberg#86283) (#86293)
- Post summary: Show placeholders for an empty excerpt and a missing author (WordPress/gutenberg#85842) (#86294)
- Core fields: Restore the previous Publish and Status panel date behaviour (WordPress/gutenberg#86065) (#86295)
- Interactivity API: Show the data-wp-html fallback on created elements under Trusted Types (WordPress/gutenberg#84924) (#86306)
- [WP 7.2] UI: Add LoadingIndicator to item popups (WordPress/gutenberg#86303)
- Interactivity Router: Fix nested router regions without data-wp-interactive disappearing on navigation (WordPress/gutenberg#86061) (#86308)
- Interactivity API: Run watch() cleanups and attachTo render callbacks without a directive scope (WordPress/gutenberg#86058) (#86311)
- DataForm: Fix clipped focus ring of field values in panel layout (WordPress/gutenberg#86361) (#86369)
- Tests: Avoid passing an object when invoking static methods via reflection. (WordPress/gutenberg#86329)
- [WP 7.2] DropdownMenu: Invert the selected item indicator while highlighted (WordPress/gutenberg#86379)
- Fields: Lowercase the (no excerpt), (no author) and (no description) placeholders (WordPress/gutenberg#86391) (#86424)
- Core fields: Decode non-Latin slugs in the slug field (WordPress/gutenberg#86359)
- Interactivity API: Show the new page's server content in kept data-wp-html elements (WordPress/gutenberg#86416)
- DataForm: Tighten value density in the panel layout (WordPress/gutenberg#86389) (#86426)
- Post summary: Show "Immediately" and relative publish dates in the Date row (WordPress/gutenberg#86367)
- [WP 7.2] Block Styles: Show the active style variation in forced colors mode (WordPress/gutenberg#86450)
- Site Editor: Fix the frame snapping to the mobile width when resized with the mouse (WordPress/gutenberg#86423)
- Image: measure the lightbox container, not the image's parent (WordPress/gutenberg#82312) (#85491)
- URL: Decode percent-encoded characters in getFilename (WordPress/gutenberg#86422) (#86477)
- Fix: Hide the author avatar when the site does not show avatars and frame a blank one. (WordPress/gutenberg#86395)
- Date picker: Mark the posts of the month a typed or reset date moves to (WordPress/gutenberg#86298) (#86463)
- Fix iOS 27 tap into a heading leaving the caret in a quote (WordPress/gutenberg#85809)
- Hand focus back to the field on a press in every browser (WordPress/gutenberg#86549)
- Prevent jobs from running within forks on `push`. (WordPress/gutenberg#85968)
- i18n: Add translator context to the "Copy error" button label (WordPress/gutenberg#85967)
- Bubble editor canvas events to the outer iframe (WordPress/gutenberg#85263)
- UI: Use LoadingIndicator in remaining popup consumers (WordPress/gutenberg#86501)
- Block Editor: Keep the revision canvas read-only in preview mode (WordPress/gutenberg#84578)
- Core Data: Rank an exact title match first among tied link suggestions (WordPress/gutenberg#86327)
- Tests: Render the router-html-server context case through state (WordPress/gutenberg#86511)
- iOS tests: De-flake the selection handle test (WordPress/gutenberg#85461)

Props mamaduka, wildworks.
See #66340.

git-svn-id: https://develop.svn.wordpress.org/trunk@65379 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Interactivity /packages/interactivity [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants