From ca80766ccb9af051f5750a359c053fd68de625dd Mon Sep 17 00:00:00 2001 From: luisherranz Date: Tue, 6 Oct 2026 07:17:18 +0200 Subject: [PATCH 01/19] Interactivity API: Migrate Interactivity fixtures to supported directive forms --- .../plugins/interactive-blocks/directive-init/render.php | 2 +- .../interactive-blocks/directive-on-document/render.php | 2 +- .../plugins/interactive-blocks/directive-on-window/render.php | 2 +- .../plugins/interactive-blocks/directive-on/render.php | 2 +- .../plugins/interactive-blocks/directive-run/render.php | 2 +- .../plugins/interactive-blocks/directive-run/view.js | 4 ++-- .../plugins/interactive-blocks/directive-watch/render.php | 2 +- .../plugins/interactive-blocks/tovdom-islands/render.php | 1 - .../plugins/interactive-blocks/with-scope/render.php | 2 +- 9 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-init/render.php b/packages/e2e-tests/plugins/interactive-blocks/directive-init/render.php index 55726cb6be89e9..dcb9327d851261 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-init/render.php +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-init/render.php @@ -19,7 +19,7 @@

false,false

diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-on-document/render.php b/packages/e2e-tests/plugins/interactive-blocks/directive-on-document/render.php index c4cc7d64fe5c2c..168f26c177721f 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-on-document/render.php +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-on-document/render.php @@ -26,7 +26,7 @@

no

diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-on-window/render.php b/packages/e2e-tests/plugins/interactive-blocks/directive-on-window/render.php index 847eb11af13a68..b1d2b31a7bca2f 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-on-window/render.php +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-on-window/render.php @@ -23,7 +23,7 @@

no

diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-on/render.php b/packages/e2e-tests/plugins/interactive-blocks/directive-on/render.php index 6475e883a66f73..f4fb9d7b9ba57b 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-on/render.php +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-on/render.php @@ -66,7 +66,7 @@
diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-run/render.php b/packages/e2e-tests/plugins/interactive-blocks/directive-run/render.php index 2f3ce3d3565535..a2d51c1d0cb6b6 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-run/render.php +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-run/render.php @@ -43,7 +43,7 @@ data-watch="" >
Element with wp-run using hooks diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-run/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-run/view.js index d8b19b7f3590f7..45882931f3674a 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-run/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-run/view.js @@ -39,8 +39,8 @@ const html = `
yes
diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-watch/render.php b/packages/e2e-tests/plugins/interactive-blocks/directive-watch/render.php index 727031b79c5dbe..b8710416175068 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-watch/render.php +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-watch/render.php @@ -31,7 +31,7 @@
-
+

0

0

From c3a1daf0c2e20bf49550029eeb46e0137c1545b1 Mon Sep 17 00:00:00 2001 From: luisherranz Date: Tue, 6 Oct 2026 07:17:27 +0200 Subject: [PATCH 02/19] Interactivity API: Use full event suffix in event directives --- packages/interactivity/src/directives/on.ts | 41 +++----- .../src/test/directives.jsdom.test.ts | 93 +++++++++++++++++++ 2 files changed, 104 insertions(+), 30 deletions(-) create mode 100644 packages/interactivity/src/test/directives.jsdom.test.ts diff --git a/packages/interactivity/src/directives/on.ts b/packages/interactivity/src/directives/on.ts index 6892b0200a65d4..b145844c80480c 100644 --- a/packages/interactivity/src/directives/on.ts +++ b/packages/interactivity/src/directives/on.ts @@ -5,10 +5,7 @@ import { type DirectiveCallback, type DirectiveEntry, } from '../hooks'; -import { - warnUniqueIdWithTwoHyphens, - warnWithSyncEvent, -} from './utils/warnings'; +import { warnWithSyncEvent } from './utils/warnings'; /** * Wraps event object to warn about access of synchronous properties and methods. @@ -64,9 +61,10 @@ function wrapEventAsync( event: Event ) { /** * Creates a directive that adds an event listener to the global window or - * document object. + * document object using the full directive suffix as its event name. * * @param type 'window' or 'document' + * @return Directive callback that manages the global event listener. */ const getGlobalEventDirective = ( type: 'window' | 'document' @@ -75,17 +73,7 @@ const getGlobalEventDirective = ( directives[ `on-${ type }` ] .filter( isNonDefaultDirectiveSuffix ) .forEach( ( entry ) => { - const suffixParts = entry.suffix.split( '--', 2 ); - const eventName = suffixParts[ 0 ]; - if ( globalThis.SCRIPT_DEBUG ) { - if ( suffixParts[ 1 ] ) { - warnUniqueIdWithTwoHyphens( - `on-${ type }`, - suffixParts[ 0 ], - suffixParts[ 1 ] - ); - } - } + const eventName = entry.suffix; useInit( () => { const cb = ( event: Event ) => { const result = evaluate( entry ); @@ -138,24 +126,17 @@ const getGlobalAsyncEventDirective = ( }; }; -// data-wp-on--[event]---[unique-id] +/** + * Registers element event handlers using the full directive suffix as the event name. + */ directive( 'on', ( { directives: { on }, element, evaluate } ) => { const events = new Map< string, Set< DirectiveEntry > >(); on.filter( isNonDefaultDirectiveSuffix ).forEach( ( entry ) => { - const suffixParts = entry.suffix.split( '--', 2 ); - if ( globalThis.SCRIPT_DEBUG ) { - if ( suffixParts[ 1 ] ) { - warnUniqueIdWithTwoHyphens( - 'on', - suffixParts[ 0 ], - suffixParts[ 1 ] - ); - } - } - if ( ! events.has( suffixParts[ 0 ] ) ) { - events.set( suffixParts[ 0 ], new Set< DirectiveEntry >() ); + const eventType = entry.suffix; + if ( ! events.has( eventType ) ) { + events.set( eventType, new Set< DirectiveEntry >() ); } - events.get( suffixParts[ 0 ] )!.add( entry ); + events.get( eventType )!.add( entry ); } ); events.forEach( ( entries, eventType ) => { diff --git a/packages/interactivity/src/test/directives.jsdom.test.ts b/packages/interactivity/src/test/directives.jsdom.test.ts new file mode 100644 index 00000000000000..79eea29692d238 --- /dev/null +++ b/packages/interactivity/src/test/directives.jsdom.test.ts @@ -0,0 +1,93 @@ +import { hydrate } from 'preact'; +import { act } from 'preact/test-utils'; +import { expect, test, vi } from 'vitest'; + +await vi.hoisted( async () => { + window.performance.getEntriesByType = () => + [ + { domContentLoadedEventStart: 1 }, + ] as unknown as PerformanceEntryList; + window.performance.measure = () => + undefined as unknown as PerformanceMeasure; +} ); + +/** + * Appends directive markup to the document and hydrates it as the runtime does. + * + * @param html Markup containing a single root element. + * @param toVdom Converts the root element into a virtual DOM tree. + * @param getRegionRootFragment Gets the hydration fragment for the root element. + * @return The hydrated root element. + */ +function hydrateHtml( + html: string, + toVdom: typeof import( '../vdom' ).toVdom, + getRegionRootFragment: typeof import( '../hydration' ).getRegionRootFragment +): Element { + const container = document.createElement( 'div' ); + container.innerHTML = html; + document.body.appendChild( container ); + const element = container.firstElementChild as Element; + hydrate( toVdom( element ), getRegionRootFragment( element ) ); + return element; +} + +test( 'event directives listen for the complete suffix', async () => { + const { privateApis, store } = await import( '../index' ); + const { toVdom, getRegionRootFragment, afterNextFrame } = privateApis( + 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.' + ); + + /** Records invocations of the click event action. */ + const clickAction = vi.fn(); + /** Records invocations of the window resize action. */ + const resizeAction = vi.fn(); + /** Records invocations of the document keydown action. */ + const keydownAction = vi.fn(); + + store( 'test/event-directives', { + actions: { + /** Handles the `click--counter` event. */ + click: clickAction, + /** Handles the `resize--second` event. */ + resize: resizeAction, + /** Handles the `keydown--second` event. */ + keydown: keydownAction, + }, + } ); + + /** Hydrated buttons and their containing interactive region. */ + const root = hydrateHtml( + '
', + toVdom, + getRegionRootFragment + ); + const clickButton = root.querySelector( 'button' )!; + + try { + await afterNextFrame( () => undefined ); + + await act( () => { + clickButton.dispatchEvent( new Event( 'click' ) ); + window.dispatchEvent( new Event( 'resize' ) ); + document.dispatchEvent( new Event( 'keydown' ) ); + } ); + + expect( clickAction ).not.toHaveBeenCalled(); + expect( resizeAction ).not.toHaveBeenCalled(); + expect( keydownAction ).not.toHaveBeenCalled(); + + await act( () => { + clickButton.dispatchEvent( new Event( 'click--counter' ) ); + window.dispatchEvent( new Event( 'resize--second' ) ); + document.dispatchEvent( new Event( 'keydown--second' ) ); + } ); + + expect( clickAction ).toHaveBeenCalledTimes( 1 ); + expect( resizeAction ).toHaveBeenCalledTimes( 1 ); + expect( keydownAction ).toHaveBeenCalledTimes( 1 ); + expect( console ).not.toHaveWarned(); + } finally { + root.parentElement?.remove(); + } +} ); From f33869e82c4101b1e8e122639bb12184a3d26d9c Mon Sep 17 00:00:00 2001 From: luisherranz Date: Tue, 6 Oct 2026 07:17:36 +0200 Subject: [PATCH 03/19] Interactivity API: Skip suffixed lifecycle directives --- packages/interactivity/src/directives/init.ts | 11 +-- packages/interactivity/src/directives/run.ts | 11 +-- .../src/directives/utils/warnings.ts | 20 ++--- .../interactivity/src/directives/watch.ts | 11 +-- .../src/test/directives.jsdom.test.ts | 79 +++++++++++++++++++ 5 files changed, 107 insertions(+), 25 deletions(-) diff --git a/packages/interactivity/src/directives/init.ts b/packages/interactivity/src/directives/init.ts index 45908f798f85ea..5c66f13af86be5 100644 --- a/packages/interactivity/src/directives/init.ts +++ b/packages/interactivity/src/directives/init.ts @@ -1,14 +1,15 @@ import { directive } from '../hooks'; import { useInit } from '../utils'; -import { warnUniqueIdWithTwoHyphens } from './utils/warnings'; +import { warnSuffixNotSupported } from './utils/warnings'; -// data-wp-init---[unique-id] — Run expression on first render. +// data-wp-init---[unique-id] — Run on first render; suffixes are unsupported. directive( 'init', ( { directives: { init }, evaluate } ) => { init.forEach( ( entry ) => { - if ( globalThis.SCRIPT_DEBUG ) { - if ( entry.suffix ) { - warnUniqueIdWithTwoHyphens( 'init', entry.suffix ); + if ( entry.suffix !== null ) { + if ( globalThis.SCRIPT_DEBUG ) { + warnSuffixNotSupported( 'init', entry.suffix ); } + return; } // TODO: Replace with useEffect to prevent unneeded scopes. useInit( () => { diff --git a/packages/interactivity/src/directives/run.ts b/packages/interactivity/src/directives/run.ts index 05af9caf422a72..d76efa578adf40 100644 --- a/packages/interactivity/src/directives/run.ts +++ b/packages/interactivity/src/directives/run.ts @@ -1,13 +1,14 @@ import { directive } from '../hooks'; -import { warnUniqueIdWithTwoHyphens } from './utils/warnings'; +import { warnSuffixNotSupported } from './utils/warnings'; -// data-wp-run---[unique-id] — Run expression on render. +// data-wp-run---[unique-id] — Run on render; suffixes are unsupported. directive( 'run', ( { directives: { run }, evaluate } ) => { run.forEach( ( entry ) => { - if ( globalThis.SCRIPT_DEBUG ) { - if ( entry.suffix ) { - warnUniqueIdWithTwoHyphens( 'run', entry.suffix ); + if ( entry.suffix !== null ) { + if ( globalThis.SCRIPT_DEBUG ) { + warnSuffixNotSupported( 'run', entry.suffix ); } + return; } let result = evaluate( entry ); if ( typeof result === 'function' ) { diff --git a/packages/interactivity/src/directives/utils/warnings.ts b/packages/interactivity/src/directives/utils/warnings.ts index ed2b6e16f9b383..72b0a68b75d7ce 100644 --- a/packages/interactivity/src/directives/utils/warnings.ts +++ b/packages/interactivity/src/directives/utils/warnings.ts @@ -1,18 +1,18 @@ import { warn } from '../../utils'; -// Warns about the deprecated two-hyphen unique ID syntax. -export const warnUniqueIdWithTwoHyphens = ( +/** + * Warns that suffixes are not supported for a lifecycle directive. + * + * @param prefix Directive name. + * @param suffix Unsupported suffix. + */ +export const warnSuffixNotSupported = ( prefix: string, - suffix: string, - uniqueId?: string -) => { + suffix: string +): void => { if ( globalThis.SCRIPT_DEBUG ) { warn( - `The usage of data-wp-${ prefix }--${ suffix }${ - uniqueId ? `--${ uniqueId }` : '' - } (two hyphens for unique ID) is deprecated and will stop working in WordPress 7.1. Please use data-wp-${ prefix }${ - uniqueId ? `--${ suffix }---${ uniqueId }` : `---${ suffix }` - } (three hyphens for unique ID) from now on.` + `Suffixes are not supported for the data-wp-${ prefix } directive. Ignoring the directive with suffix "${ suffix }".` ); } }; diff --git a/packages/interactivity/src/directives/watch.ts b/packages/interactivity/src/directives/watch.ts index ee18e0f1a19884..c56478cc1282ba 100644 --- a/packages/interactivity/src/directives/watch.ts +++ b/packages/interactivity/src/directives/watch.ts @@ -1,14 +1,15 @@ import { directive } from '../hooks'; import { useWatch } from '../utils'; -import { warnUniqueIdWithTwoHyphens } from './utils/warnings'; +import { warnSuffixNotSupported } from './utils/warnings'; -// data-wp-watch---[unique-id] — Reactive effect. +// data-wp-watch---[unique-id] — Reactive effect; suffixes are unsupported. directive( 'watch', ( { directives: { watch }, evaluate } ) => { watch.forEach( ( entry ) => { - if ( globalThis.SCRIPT_DEBUG ) { - if ( entry.suffix ) { - warnUniqueIdWithTwoHyphens( 'watch', entry.suffix ); + if ( entry.suffix !== null ) { + if ( globalThis.SCRIPT_DEBUG ) { + warnSuffixNotSupported( 'watch', entry.suffix ); } + return; } useWatch( () => { let start; diff --git a/packages/interactivity/src/test/directives.jsdom.test.ts b/packages/interactivity/src/test/directives.jsdom.test.ts index 79eea29692d238..6297e1df63565e 100644 --- a/packages/interactivity/src/test/directives.jsdom.test.ts +++ b/packages/interactivity/src/test/directives.jsdom.test.ts @@ -91,3 +91,82 @@ test( 'event directives listen for the complete suffix', async () => { root.parentElement?.remove(); } } ); + +test( 'lifecycle directives skip suffixes and keep three-hyphen IDs', async () => { + const { privateApis, store } = await import( '../index' ); + const { toVdom, getRegionRootFragment, afterNextFrame } = privateApis( + 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.' + ); + + /** Records invocations of suffixed lifecycle callbacks. */ + const unsupportedCallbacks = { + watch: vi.fn(), + watchWithUniqueId: vi.fn(), + init: vi.fn(), + run: vi.fn(), + }; + /** Records invocations of lifecycle callbacks with supported unique IDs. */ + const uniqueIdCallbacks = { + watchOne: vi.fn(), + watchTwo: vi.fn(), + initOne: vi.fn(), + initTwo: vi.fn(), + runOne: vi.fn(), + runTwo: vi.fn(), + }; + store( 'test/lifecycle-directives', { + callbacks: { + watch: unsupportedCallbacks.watch, + watchWithUniqueId: unsupportedCallbacks.watchWithUniqueId, + init: unsupportedCallbacks.init, + run: unsupportedCallbacks.run, + ...uniqueIdCallbacks, + }, + } ); + + vi.stubGlobal( 'SCRIPT_DEBUG', false ); + const productionRoot = hydrateHtml( + '
', + toVdom, + getRegionRootFragment + ); + try { + await afterNextFrame( () => undefined ); + expect( unsupportedCallbacks.watch ).not.toHaveBeenCalled(); + expect( unsupportedCallbacks.watchWithUniqueId ).not.toHaveBeenCalled(); + expect( unsupportedCallbacks.init ).not.toHaveBeenCalled(); + expect( unsupportedCallbacks.run ).not.toHaveBeenCalled(); + expect( console ).not.toHaveWarned(); + } finally { + productionRoot.parentElement?.remove(); + } + + vi.stubGlobal( 'SCRIPT_DEBUG', true ); + const developmentRoot = hydrateHtml( + '
', + toVdom, + getRegionRootFragment + ); + try { + await afterNextFrame( () => undefined ); + + expect( unsupportedCallbacks.watch ).not.toHaveBeenCalled(); + expect( unsupportedCallbacks.watchWithUniqueId ).not.toHaveBeenCalled(); + expect( unsupportedCallbacks.init ).not.toHaveBeenCalled(); + expect( unsupportedCallbacks.run ).not.toHaveBeenCalled(); + Object.values( uniqueIdCallbacks ).forEach( ( callback ) => + expect( callback ).toHaveBeenCalledTimes( 1 ) + ); + expect( console ).toHaveWarnedWith( + 'Suffixes are not supported for the data-wp-watch directive. Ignoring the directive with suffix "one".' + ); + expect( console ).toHaveWarnedWith( + 'Suffixes are not supported for the data-wp-init directive. Ignoring the directive with suffix "one".' + ); + expect( console ).toHaveWarnedWith( + 'Suffixes are not supported for the data-wp-run directive. Ignoring the directive with suffix "one".' + ); + } finally { + developmentRoot.parentElement?.remove(); + } +} ); From 88327a8d2ddeb1a39d9358b13aa3882701b8f509 Mon Sep 17 00:00:00 2001 From: luisherranz Date: Tue, 6 Oct 2026 07:17:45 +0200 Subject: [PATCH 04/19] Interactivity API: Do not invoke negated functions --- packages/interactivity/src/hooks.tsx | 27 +++++++++------ .../src/test/directives.jsdom.test.ts | 33 +++++++++++++++++++ 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/packages/interactivity/src/hooks.tsx b/packages/interactivity/src/hooks.tsx index 554b4665c04a8b..eab73597bb8e4b 100644 --- a/packages/interactivity/src/hooks.tsx +++ b/packages/interactivity/src/hooks.tsx @@ -86,8 +86,14 @@ interface DirectiveOptions { priority?: number; } +/** + * Resolves a directive entry's value in the current scope. + * + * @param entry The directive entry whose value should be resolved. + * @return The resolved value. + */ export interface Evaluate { - ( entry: DirectiveEntry, ...args: any[] ): any; + ( entry: DirectiveEntry ): any; } interface GetEvaluate { @@ -229,11 +235,16 @@ const resolve = ( path: string, namespace: string ) => { } }; -// Generate the evaluate function. +/** + * Creates an evaluator bound to a directive scope. + * + * @param args Arguments used to bind the evaluator to a scope. + * @param args.scope Scope used to resolve directive values. + * @return An evaluator for directive entries. + */ export const getEvaluate: GetEvaluate = ( { scope } ) => - // TODO: When removing the temporarily remaining `value( ...args )` call below, remove the `...args` parameter too. - ( entry, ...args ) => { + ( entry ) => { let { value: path, namespace } = entry; if ( typeof path !== 'string' ) { throw new Error( 'The `value` prop should be a string path' ); @@ -245,16 +256,12 @@ export const getEvaluate: GetEvaluate = const value = resolve( path, namespace ); // Functions are returned without invoking them. if ( typeof value === 'function' ) { - // Except if they have a negation operator present, for backward compatibility. - // This pattern is strongly discouraged and deprecated, and it will be removed in a near future release. - // TODO: Remove this condition to effectively ignore negation operator when provided with a function. if ( hasNegationOperator ) { warn( - 'Using a function with a negation operator is deprecated and will stop working in WordPress 6.9. Please use derived state instead.' + `The value of "${ path }" is a function and cannot be negated. Please use derived state instead.` ); - const functionResult = ! value( ...args ); resetScope(); - return functionResult; + return undefined; } // Reset scope before return and wrap the function so it will still run within the correct scope. resetScope(); diff --git a/packages/interactivity/src/test/directives.jsdom.test.ts b/packages/interactivity/src/test/directives.jsdom.test.ts index 6297e1df63565e..f5c9e932bd4c57 100644 --- a/packages/interactivity/src/test/directives.jsdom.test.ts +++ b/packages/interactivity/src/test/directives.jsdom.test.ts @@ -170,3 +170,36 @@ test( 'lifecycle directives skip suffixes and keep three-hyphen IDs', async () = developmentRoot.parentElement?.remove(); } } ); + +test( 'negated functions remain unresolved and warn about derived state', async () => { + const { privateApis, store } = await import( '../index' ); + const { toVdom, getRegionRootFragment, afterNextFrame } = privateApis( + 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.' + ); + + /** Records invocations of the negated action. */ + const isClosed = vi.fn(); + store( 'test/negated-functions', { + actions: { isClosed }, + } ); + + vi.stubGlobal( 'SCRIPT_DEBUG', true ); + const root = hydrateHtml( + '
', + toVdom, + getRegionRootFragment + ); + const boundElement = root.querySelector( 'span' )!; + + try { + await afterNextFrame( () => undefined ); + + expect( isClosed ).not.toHaveBeenCalled(); + expect( boundElement ).not.toHaveAttribute( 'hidden' ); + expect( console ).toHaveWarnedWith( + 'The value of "actions.isClosed" is a function and cannot be negated. Please use derived state instead.' + ); + } finally { + root.parentElement?.remove(); + } +} ); From 7523f9ba281e919413afb12c0a1cc78f8c325f6f Mon Sep 17 00:00:00 2001 From: luisherranz Date: Tue, 6 Oct 2026 07:19:17 +0200 Subject: [PATCH 05/19] Interactivity API: Remove special handling for data-wp-ignore --- .../interactivity/src/directives/ignore.ts | 31 -------------- .../interactivity/src/directives/index.ts | 1 - packages/interactivity/src/vdom.ts | 40 ++++++------------- 3 files changed, 13 insertions(+), 59 deletions(-) delete mode 100644 packages/interactivity/src/directives/ignore.ts diff --git a/packages/interactivity/src/directives/ignore.ts b/packages/interactivity/src/directives/ignore.ts deleted file mode 100644 index 41bd84a4231de5..00000000000000 --- a/packages/interactivity/src/directives/ignore.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { h as createElement } from 'preact'; -import { useMemo } from 'preact/hooks'; -import { directive } from '../hooks'; -import { warn } from '../utils'; - -// data-wp-ignore (deprecated) — Preserve inner HTML. -directive( - 'ignore', - ( { - element: { - type: Type, - props: { innerHTML, ...rest }, - }, - }: { - element: any; - } ) => { - if ( globalThis.SCRIPT_DEBUG ) { - warn( - 'The data-wp-ignore directive is deprecated and will be removed in version 7.0.' - ); - } - - // Preserve the initial inner HTML - // eslint-disable-next-line react-hooks/exhaustive-deps - const cached = useMemo( () => innerHTML, [] ); - return createElement( Type, { - dangerouslySetInnerHTML: { __html: cached }, - ...rest, - } ); - } -); diff --git a/packages/interactivity/src/directives/index.ts b/packages/interactivity/src/directives/index.ts index b339b0f4b45911..0a98310e30f534 100644 --- a/packages/interactivity/src/directives/index.ts +++ b/packages/interactivity/src/directives/index.ts @@ -10,7 +10,6 @@ import './class'; import './context'; import './each'; import './html'; -import './ignore'; import './init'; import './on'; import './router-region'; diff --git a/packages/interactivity/src/vdom.ts b/packages/interactivity/src/vdom.ts index e5366e78fc05a2..fbd3453ae501fb 100644 --- a/packages/interactivity/src/vdom.ts +++ b/packages/interactivity/src/vdom.ts @@ -145,7 +145,6 @@ export function toVdom( root: Node ): ComponentChild { const directives: Array< [ name: string, namespace: string | null, value: unknown ] > = []; - let ignore = false; let island = false; for ( let i = 0; i < attributes.length; i++ ) { @@ -156,24 +155,20 @@ export function toVdom( root: Node ): ComponentChild { attributeName.slice( 0, directivePrefix.length ) === directivePrefix ) { - if ( attributeName === 'data-wp-ignore' ) { - ignore = true; + const { namespace, value } = + parseDirectiveValue( attributeValue ); + if ( attributeName === 'data-wp-interactive' ) { + island = true; + const islandNamespace = + // eslint-disable-next-line no-nested-ternary + typeof value === 'string' + ? value + : typeof value?.namespace === 'string' + ? value.namespace + : null; + namespaces.push( islandNamespace ); } else { - const { namespace, value } = - parseDirectiveValue( attributeValue ); - if ( attributeName === 'data-wp-interactive' ) { - island = true; - const islandNamespace = - // eslint-disable-next-line no-nested-ternary - typeof value === 'string' - ? value - : typeof value?.namespace === 'string' - ? value.namespace - : null; - namespaces.push( islandNamespace ); - } else { - directives.push( [ attributeName, namespace, value ] ); - } + directives.push( [ attributeName, namespace, value ] ); } } else if ( attributeName === 'ref' ) { continue; @@ -193,15 +188,6 @@ export function toVdom( root: Node ): ComponentChild { } } - if ( ignore && ! island ) { - return [ - h< any, any >( localName, { - ...props, - innerHTML: elementNode.innerHTML, - __directives: { ignore: true }, - } ), - ]; - } if ( island ) { hydratedIslands.add( elementNode ); } From 27aca8a9ff8d0059b16245d7808fc222d295f52b Mon Sep 17 00:00:00 2001 From: luisherranz Date: Tue, 6 Oct 2026 07:19:40 +0200 Subject: [PATCH 06/19] Interactivity API: Update island hydration e2e coverage --- .../plugins/interactive-blocks/tovdom-islands/render.php | 4 ++-- test/e2e/specs/interactivity/tovdom-islands.spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php b/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php index cdc454cbd5da90..231b869442f7b9 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php +++ b/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php @@ -35,8 +35,8 @@ - This should be shown because it is inside an inner - block of an isolated island. + This should be hidden because it is inside a data-wp-ignore + element of an island.
diff --git a/test/e2e/specs/interactivity/tovdom-islands.spec.ts b/test/e2e/specs/interactivity/tovdom-islands.spec.ts index 900d8fd9b42245..5cdcbe3c3659f0 100644 --- a/test/e2e/specs/interactivity/tovdom-islands.spec.ts +++ b/test/e2e/specs/interactivity/tovdom-islands.spec.ts @@ -36,13 +36,13 @@ test.describe( 'toVdom - islands', () => { await expect( el ).toBeHidden(); } ); - test( 'directives that are inside inner blocks of isolated islands should not be hydrated', async ( { + test( 'directives inside a data-wp-ignore element of an island should be hydrated', async ( { page, } ) => { const el = page.getByTestId( 'inside an inner block of an isolated island' ); - await expect( el ).toBeVisible(); + await expect( el ).toBeHidden(); } ); test( 'directives inside islands should not be hydrated twice', async ( { From 5663d23409279b449bce86a02fa9909a7758bedd Mon Sep 17 00:00:00 2001 From: luisherranz Date: Tue, 6 Oct 2026 07:19:52 +0200 Subject: [PATCH 07/19] Interactivity API: Correct hydration fixture explanation --- .../plugins/interactive-blocks/tovdom-islands/render.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php b/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php index 231b869442f7b9..5bccb4fcfe0954 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php +++ b/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php @@ -35,8 +35,10 @@ - This should be hidden because it is inside a data-wp-ignore - element of an island. + This should be hidden because directives inside a + `data-wp-ignore` element of an island are hydrated, so + the `data-wp-show-mock="state.falseValue"` directive + wrapping it runs.
From e2e8267212a7d9ff75127e2290116dae68d2fabf Mon Sep 17 00:00:00 2001 From: luisherranz Date: Tue, 6 Oct 2026 07:19:53 +0200 Subject: [PATCH 08/19] Interactivity API: Remove expired unique-ID deprecation notices from Interactivity API reference --- .../interactivity-api/directives-and-store.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/reference-guides/interactivity-api/directives-and-store.md b/docs/reference-guides/interactivity-api/directives-and-store.md index 6c7b0099e822de..85d516d00bf1c7 100644 --- a/docs/reference-guides/interactivity-api/directives-and-store.md +++ b/docs/reference-guides/interactivity-api/directives-and-store.md @@ -487,8 +487,6 @@ It runs a callback **when the node is created and runs it again when the state o You can attach several side effects to the same DOM element by using the syntax `data-wp-watch---[unique-id]` (note the three hyphens before the unique ID). -> **Deprecation notice:** The two-hyphen syntax `data-wp-watch--[unique-id]` is deprecated and will stop working in WordPress 7.1. Use three hyphens (`---`) for unique IDs. - The `unique-id` doesn't need to be unique globally. It just needs to be different from the other unique IDs of the `wp-watch` directives of that DOM element. ```html @@ -547,8 +545,6 @@ This directive runs a callback **only when the node is created**. You can attach several `wp-init` to the same DOM element by using the syntax `data-wp-init---[unique-id]` (note the three hyphens before the unique ID). -> **Deprecation notice:** The two-hyphen syntax `data-wp-init--[unique-id]` is deprecated and will stop working in WordPress 7.1. Use three hyphens (`---`) for unique IDs. - The `unique-id` doesn't need to be unique globally. It just needs to be different from the other unique IDs of the `wp-init` directives of that DOM element. ```html @@ -597,8 +593,6 @@ You can use and compose hooks like `useState`, `useWatch`, or `useEffect` inside You can attach several `wp-run` to the same DOM element by using the syntax `data-wp-run---[unique-id]` (note the three hyphens before the unique ID). -> **Deprecation notice:** The two-hyphen syntax `data-wp-run--[unique-id]` is deprecated and will stop working in WordPress 7.1. Use three hyphens (`---`) for unique IDs. - The `unique-id` doesn't need to be unique globally. It just needs to be different from the other unique IDs of the `wp-run` directives of that DOM element. ```html From f6f2d8ee3a5831c54e13edb2b277b13d89ab56aa Mon Sep 17 00:00:00 2001 From: luisherranz Date: Tue, 6 Oct 2026 07:20:57 +0200 Subject: [PATCH 09/19] Interactivity API: Announce removals in the changelog --- packages/interactivity/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/interactivity/CHANGELOG.md b/packages/interactivity/CHANGELOG.md index ebe479ecf07ef4..a672b445fa1fdf 100644 --- a/packages/interactivity/CHANGELOG.md +++ b/packages/interactivity/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Breaking Changes + +- Remove three behaviors whose deprecation warnings named WordPress versions that have already shipped. Use the replacement for each: (1) The `data-wp-ignore` directive is gone, and an element carrying it now hydrates like any other element, so drop the attribute and expect ordinary hydration. (2) Two-hyphen unique IDs, such as `data-wp-on--click--id`, are no longer recognized on `data-wp-watch`, `data-wp-init`, `data-wp-run`, `data-wp-on`, `data-wp-on-window`, and `data-wp-on-document`; use the three-hyphen form, such as `data-wp-on--click---id`. On `data-wp-watch`, `data-wp-init`, and `data-wp-run`, a suffix now makes the directive skipped, with a warning in development mode, and on the `data-wp-on` family the text after `on--` is now read whole as the event name instead of being cut at `--`. (3) Applying `!` to a function in a directive value, such as `data-wp-bind--hidden="!state.isOpen"` when `isOpen` is a function, now leaves the value unresolved, with a warning in development mode; use derived state, such as a getter, instead. Negating a non-function value or a getter is unchanged ([#00000](https://github.com/WordPress/gutenberg/pull/00000)). + ### New Features - Add the `data-wp-html` directive and `asDangerousHTML()` for rendering explicitly trusted HTML from reactive state. ([#83092](https://github.com/WordPress/gutenberg/pull/83092)) From d4f65220f532275a6608d6bd448ea7ddcc675c71 Mon Sep 17 00:00:00 2001 From: luisherranz Date: Tue, 6 Oct 2026 07:25:31 +0200 Subject: [PATCH 10/19] Interactivity API: Normalize reference emphasis formatting --- .../interactivity-api/directives-and-store.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference-guides/interactivity-api/directives-and-store.md b/docs/reference-guides/interactivity-api/directives-and-store.md index 85d516d00bf1c7..336b18dd0b0a32 100644 --- a/docs/reference-guides/interactivity-api/directives-and-store.md +++ b/docs/reference-guides/interactivity-api/directives-and-store.md @@ -1019,7 +1019,7 @@ This approach enables some functionalities that make directives flexible and pow #### On the client side -_In the `view.js` file of each block_ the developer can define both the state and the elements of the store referencing functions like actions, side effects or derived state. +*In the `view.js` file of each block* the developer can define both the state and the elements of the store referencing functions like actions, side effects or derived state. The `store` method used to set the store in JavaScript can be imported from `@wordpress/interactivity`. @@ -1052,7 +1052,7 @@ The state defined on the server with `wp_interactivity_state()` gets merged with The `wp_interactivity_state` function receives two arguments, a `string` with the namespace that will be used as a reference and an [associative array](https://www.php.net/manual/en/language.types.array.php) containing the values. -_Example of store initialized from the server with a `state` = `{ someValue: 123 }`_ +*Example of store initialized from the server with a `state` = `{ someValue: 123 }`* ```php // render.php From a3416726089778eb26bf8261302b6ee522ebaebc Mon Sep 17 00:00:00 2001 From: luisherranz Date: Tue, 6 Oct 2026 07:33:22 +0200 Subject: [PATCH 11/19] Interactivity API: Reference removal PR in the changelog --- packages/interactivity/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/interactivity/CHANGELOG.md b/packages/interactivity/CHANGELOG.md index a672b445fa1fdf..192892d9d4b849 100644 --- a/packages/interactivity/CHANGELOG.md +++ b/packages/interactivity/CHANGELOG.md @@ -4,7 +4,7 @@ ### Breaking Changes -- Remove three behaviors whose deprecation warnings named WordPress versions that have already shipped. Use the replacement for each: (1) The `data-wp-ignore` directive is gone, and an element carrying it now hydrates like any other element, so drop the attribute and expect ordinary hydration. (2) Two-hyphen unique IDs, such as `data-wp-on--click--id`, are no longer recognized on `data-wp-watch`, `data-wp-init`, `data-wp-run`, `data-wp-on`, `data-wp-on-window`, and `data-wp-on-document`; use the three-hyphen form, such as `data-wp-on--click---id`. On `data-wp-watch`, `data-wp-init`, and `data-wp-run`, a suffix now makes the directive skipped, with a warning in development mode, and on the `data-wp-on` family the text after `on--` is now read whole as the event name instead of being cut at `--`. (3) Applying `!` to a function in a directive value, such as `data-wp-bind--hidden="!state.isOpen"` when `isOpen` is a function, now leaves the value unresolved, with a warning in development mode; use derived state, such as a getter, instead. Negating a non-function value or a getter is unchanged ([#00000](https://github.com/WordPress/gutenberg/pull/00000)). +- Remove three behaviors whose deprecation warnings named WordPress versions that have already shipped. Use the replacement for each: (1) The `data-wp-ignore` directive is gone, and an element carrying it now hydrates like any other element, so drop the attribute and expect ordinary hydration. (2) Two-hyphen unique IDs, such as `data-wp-on--click--id`, are no longer recognized on `data-wp-watch`, `data-wp-init`, `data-wp-run`, `data-wp-on`, `data-wp-on-window`, and `data-wp-on-document`; use the three-hyphen form, such as `data-wp-on--click---id`. On `data-wp-watch`, `data-wp-init`, and `data-wp-run`, a suffix now makes the directive skipped, with a warning in development mode, and on the `data-wp-on` family the text after `on--` is now read whole as the event name instead of being cut at `--`. (3) Applying `!` to a function in a directive value, such as `data-wp-bind--hidden="!state.isOpen"` when `isOpen` is a function, now leaves the value unresolved, with a warning in development mode; use derived state, such as a getter, instead. Negating a non-function value or a getter is unchanged ([#84098](https://github.com/WordPress/gutenberg/pull/84098)). ### New Features From cdc18088f92f36a0f9db225f79e2cc2f79682314 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 6 Oct 2026 12:42:53 +0200 Subject: [PATCH 12/19] Interactivity API: Warn about two-hyphen event names Event directives now read the whole suffix as the event name, so a leftover two-hyphen unique ID silently listens for an event that never fires. Warn in development mode and suggest the three-hyphen form. Document that the deprecated async event directives still cut the event name at `--`. --- packages/interactivity/src/directives/on.ts | 30 +++++++++++++++---- .../src/directives/utils/warnings.ts | 16 ++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/packages/interactivity/src/directives/on.ts b/packages/interactivity/src/directives/on.ts index b145844c80480c..17ac50f8b82279 100644 --- a/packages/interactivity/src/directives/on.ts +++ b/packages/interactivity/src/directives/on.ts @@ -5,7 +5,10 @@ import { type DirectiveCallback, type DirectiveEntry, } from '../hooks'; -import { warnWithSyncEvent } from './utils/warnings'; +import { + warnEventNameWithTwoHyphens, + warnWithSyncEvent, +} from './utils/warnings'; /** * Wraps event object to warn about access of synchronous properties and methods. @@ -74,6 +77,14 @@ const getGlobalEventDirective = ( .filter( isNonDefaultDirectiveSuffix ) .forEach( ( entry ) => { const eventName = entry.suffix; + if ( globalThis.SCRIPT_DEBUG ) { + if ( eventName.includes( '--' ) ) { + warnEventNameWithTwoHyphens( + `on-${ type }`, + eventName + ); + } + } useInit( () => { const cb = ( event: Event ) => { const result = evaluate( entry ); @@ -95,6 +106,11 @@ const getGlobalEventDirective = ( /** * Creates a directive that adds an async event listener to the global window or * document object. + * + * Unlike the synchronous directives, the deprecated async directives still cut + * the event name at `--`, so the legacy two-hyphen unique ID syntax keeps + * working until they are removed. + * * @param type 'window' or 'document' */ const getGlobalAsyncEventDirective = ( @@ -126,13 +142,16 @@ const getGlobalAsyncEventDirective = ( }; }; -/** - * Registers element event handlers using the full directive suffix as the event name. - */ +// data-wp-on--[event]---[unique-id] directive( 'on', ( { directives: { on }, element, evaluate } ) => { const events = new Map< string, Set< DirectiveEntry > >(); on.filter( isNonDefaultDirectiveSuffix ).forEach( ( entry ) => { const eventType = entry.suffix; + if ( globalThis.SCRIPT_DEBUG ) { + if ( eventType.includes( '--' ) ) { + warnEventNameWithTwoHyphens( 'on', eventType ); + } + } if ( ! events.has( eventType ) ) { events.set( eventType, new Set< DirectiveEntry >() ); } @@ -180,7 +199,8 @@ directive( 'on', ( { directives: { on }, element, evaluate } ) => { } ); } ); -// data-wp-on-async--[event] (deprecated) +// data-wp-on-async--[event] (deprecated). The event name is still cut at `--` +// to keep the legacy two-hyphen unique ID syntax working until removal. directive( 'on-async', ( { directives: { 'on-async': onAsync }, element, evaluate } ) => { diff --git a/packages/interactivity/src/directives/utils/warnings.ts b/packages/interactivity/src/directives/utils/warnings.ts index 72b0a68b75d7ce..2c7893d45a07a9 100644 --- a/packages/interactivity/src/directives/utils/warnings.ts +++ b/packages/interactivity/src/directives/utils/warnings.ts @@ -17,6 +17,22 @@ export const warnSuffixNotSupported = ( } }; +// Warns that an event name contains `--`, which is most likely a leftover of +// the removed two-hyphen unique ID syntax. +export const warnEventNameWithTwoHyphens = ( + prefix: string, + eventName: string +) => { + if ( globalThis.SCRIPT_DEBUG ) { + const [ event, ...rest ] = eventName.split( '--' ); + warn( + `The data-wp-${ prefix }--${ eventName } directive listens for an event named "${ eventName }". Two-hyphen unique IDs are no longer supported. If you meant to add a unique ID, please use data-wp-${ prefix }--${ event }---${ rest.join( + '--' + ) } instead.` + ); + } +}; + // Warns that unique IDs are not supported for a given directive. export const warnUniqueIdNotSupported = ( prefix: string, From 63895013e6aebbeb3734ffaf7e4e372c5e6dca78 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 6 Oct 2026 12:42:59 +0200 Subject: [PATCH 13/19] Interactivity API: Share the unsupported suffix warning with router-region Align the warnSuffixNotSupported() wording with the existing router-region message and use the helper there too. --- .../interactivity/src/directives/router-region.ts | 10 +++++----- .../interactivity/src/directives/utils/warnings.ts | 14 +++----------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/packages/interactivity/src/directives/router-region.ts b/packages/interactivity/src/directives/router-region.ts index b69534eb3d832c..3529edaa07f627 100644 --- a/packages/interactivity/src/directives/router-region.ts +++ b/packages/interactivity/src/directives/router-region.ts @@ -2,9 +2,11 @@ import { cloneElement, type VNode } from 'preact'; import { useLayoutEffect } from 'preact/hooks'; import { signal, type Signal } from '@preact/signals'; import { directive, isDefaultDirectiveSuffix } from '../hooks'; -import { warn } from '../utils'; import { getScope, navigationContextSignal } from '../scopes'; -import { warnUniqueIdNotSupported } from './utils/warnings'; +import { + warnSuffixNotSupported, + warnUniqueIdNotSupported, +} from './utils/warnings'; /** * Relates each router region with its current vDOM content. Used by the @@ -31,9 +33,7 @@ directive( if ( entry.suffix ) { if ( globalThis.SCRIPT_DEBUG ) { - warn( - `Suffixes for the data-wp-router-region directive are not supported. Ignoring the directive with suffix "${ entry.suffix }".` - ); + warnSuffixNotSupported( 'router-region', entry.suffix ); } return; } diff --git a/packages/interactivity/src/directives/utils/warnings.ts b/packages/interactivity/src/directives/utils/warnings.ts index 2c7893d45a07a9..2c6176bb76ac65 100644 --- a/packages/interactivity/src/directives/utils/warnings.ts +++ b/packages/interactivity/src/directives/utils/warnings.ts @@ -1,18 +1,10 @@ import { warn } from '../../utils'; -/** - * Warns that suffixes are not supported for a lifecycle directive. - * - * @param prefix Directive name. - * @param suffix Unsupported suffix. - */ -export const warnSuffixNotSupported = ( - prefix: string, - suffix: string -): void => { +// Warns that suffixes are not supported for a given directive. +export const warnSuffixNotSupported = ( prefix: string, suffix: string ) => { if ( globalThis.SCRIPT_DEBUG ) { warn( - `Suffixes are not supported for the data-wp-${ prefix } directive. Ignoring the directive with suffix "${ suffix }".` + `Suffixes for the data-wp-${ prefix } directive are not supported. Ignoring the directive with suffix "${ suffix }".` ); } }; From 65c017fd4b6b111b51c38424bb1005ee1528c36d Mon Sep 17 00:00:00 2001 From: David Date: Tue, 6 Oct 2026 12:43:03 +0200 Subject: [PATCH 14/19] Interactivity API: Warn about leftover data-wp-ignore attributes --- packages/interactivity/src/vdom.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/interactivity/src/vdom.ts b/packages/interactivity/src/vdom.ts index fbd3453ae501fb..4b9e0224d5fe31 100644 --- a/packages/interactivity/src/vdom.ts +++ b/packages/interactivity/src/vdom.ts @@ -155,6 +155,13 @@ export function toVdom( root: Node ): ComponentChild { attributeName.slice( 0, directivePrefix.length ) === directivePrefix ) { + if ( globalThis.SCRIPT_DEBUG ) { + if ( attributeName === 'data-wp-ignore' ) { + warn( + 'The data-wp-ignore directive has been removed. The element and its descendants are now hydrated like any other element. Please remove the attribute.' + ); + } + } const { namespace, value } = parseDirectiveValue( attributeValue ); if ( attributeName === 'data-wp-interactive' ) { From dfa07af6dd6b8648cfcca1c512f6c46a8a5193d1 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 6 Oct 2026 12:43:07 +0200 Subject: [PATCH 15/19] Interactivity API: Remove JSDoc from the Evaluate interface --- packages/interactivity/src/hooks.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/interactivity/src/hooks.tsx b/packages/interactivity/src/hooks.tsx index eab73597bb8e4b..bdc5c231422e35 100644 --- a/packages/interactivity/src/hooks.tsx +++ b/packages/interactivity/src/hooks.tsx @@ -86,12 +86,6 @@ interface DirectiveOptions { priority?: number; } -/** - * Resolves a directive entry's value in the current scope. - * - * @param entry The directive entry whose value should be resolved. - * @return The resolved value. - */ export interface Evaluate { ( entry: DirectiveEntry ): any; } From 0ff03cb7ec4206888ef1cda0be79f354779fdde4 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 6 Oct 2026 12:43:12 +0200 Subject: [PATCH 16/19] Interactivity API: Move and extend tests for removed deprecations Move the tests next to the other directive tests and follow their conventions. Cover production mode, the new warnings, data-wp-ignore hydration, deprecated async event directives, and negation of values and getters. --- .../directives/test/directives.jsdom.test.ts | 289 ++++++++++++++++++ .../src/test/directives.jsdom.test.ts | 205 ------------- 2 files changed, 289 insertions(+), 205 deletions(-) create mode 100644 packages/interactivity/src/directives/test/directives.jsdom.test.ts delete mode 100644 packages/interactivity/src/test/directives.jsdom.test.ts diff --git a/packages/interactivity/src/directives/test/directives.jsdom.test.ts b/packages/interactivity/src/directives/test/directives.jsdom.test.ts new file mode 100644 index 00000000000000..a5a20c9b902d5d --- /dev/null +++ b/packages/interactivity/src/directives/test/directives.jsdom.test.ts @@ -0,0 +1,289 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { hydrate } from 'preact'; +import { act } from 'preact/test-utils'; +import '../index'; // Registers all core directives. +import { hydratedIslands, toVdom } from '../../vdom'; +import { store } from '../../store'; + +let namespaceCount = 0; + +// Each test gets its own store namespace: the store registry is a module +// singleton, so reusing a namespace across tests would leak state. +function uniqueNamespace(): string { + return `test/directives-${ ++namespaceCount }`; +} + +function createRegion( namespace: string, innerHtml: string ): HTMLElement { + const container = document.createElement( 'div' ); + container.innerHTML = `
${ innerHtml }
`; + document.body.appendChild( container ); + return container.firstElementChild as HTMLElement; +} + +async function hydrateRegion( region: HTMLElement ) { + await act( () => hydrate( toVdom( region ), region.parentNode! ) ); +} + +beforeEach( () => { + document.body.innerHTML = ''; + // @ts-expect-error `_values` is an internal property, accessed here for testing. + hydratedIslands._values = new WeakMap(); +} ); + +afterEach( () => { + vi.unstubAllGlobals(); +} ); + +describe( 'event directives', () => { + it( 'use the complete suffix as the event name and warn about two hyphens', async () => { + const namespace = uniqueNamespace(); + const click = vi.fn(); + const resize = vi.fn(); + const keydown = vi.fn(); + store( namespace, { actions: { click, resize, keydown } } ); + + const region = createRegion( + namespace, + '' + + '
' + + '
' + ); + await hydrateRegion( region ); + const button = region.querySelector( 'button' )!; + + await act( () => { + button.dispatchEvent( new Event( 'click' ) ); + window.dispatchEvent( new Event( 'resize' ) ); + document.dispatchEvent( new Event( 'keydown' ) ); + } ); + expect( click ).not.toHaveBeenCalled(); + expect( resize ).not.toHaveBeenCalled(); + expect( keydown ).not.toHaveBeenCalled(); + + await act( () => { + button.dispatchEvent( new Event( 'click--counter' ) ); + window.dispatchEvent( new Event( 'resize--second' ) ); + document.dispatchEvent( new Event( 'keydown--second' ) ); + } ); + expect( click ).toHaveBeenCalledTimes( 1 ); + expect( resize ).toHaveBeenCalledTimes( 1 ); + expect( keydown ).toHaveBeenCalledTimes( 1 ); + + expect( console ).toHaveWarnedWith( + 'The data-wp-on--click--counter directive listens for an event named "click--counter". Two-hyphen unique IDs are no longer supported. If you meant to add a unique ID, please use data-wp-on--click---counter instead.' + ); + expect( console ).toHaveWarnedWith( + 'The data-wp-on-window--resize--second directive listens for an event named "resize--second". Two-hyphen unique IDs are no longer supported. If you meant to add a unique ID, please use data-wp-on-window--resize---second instead.' + ); + expect( console ).toHaveWarnedWith( + 'The data-wp-on-document--keydown--second directive listens for an event named "keydown--second". Two-hyphen unique IDs are no longer supported. If you meant to add a unique ID, please use data-wp-on-document--keydown---second instead.' + ); + } ); + + it( 'do not warn about two hyphens when SCRIPT_DEBUG is disabled', async () => { + vi.stubGlobal( 'SCRIPT_DEBUG', false ); + const namespace = uniqueNamespace(); + store( namespace, { actions: { click: vi.fn() } } ); + + const region = createRegion( + namespace, + '' + ); + await hydrateRegion( region ); + + expect( console ).not.toHaveWarned(); + } ); + + it( 'keep cutting the event name at two hyphens in deprecated async directives', async () => { + const namespace = uniqueNamespace(); + const click = vi.fn(); + store( namespace, { actions: { click } } ); + + const region = createRegion( + namespace, + '' + ); + await hydrateRegion( region ); + + await act( async () => { + region + .querySelector( 'button' )! + .dispatchEvent( new Event( 'click' ) ); + await new Promise( ( resolve ) => setTimeout( resolve, 0 ) ); + } ); + + expect( click ).toHaveBeenCalledTimes( 1 ); + expect( console ).toHaveWarnedWith( + 'The usage of data-wp-on-async is deprecated and will stop working in WordPress 7.0. Please, use data-wp-on with the withSyncEvent() helper from now on.' + ); + } ); +} ); + +describe( 'lifecycle directives', () => { + it( 'skip suffixes and keep three-hyphen unique IDs', async () => { + const namespace = uniqueNamespace(); + const unsupported = { + watch: vi.fn(), + watchWithUniqueId: vi.fn(), + init: vi.fn(), + run: vi.fn(), + }; + const supported = { + watchOne: vi.fn(), + watchTwo: vi.fn(), + initOne: vi.fn(), + initTwo: vi.fn(), + runOne: vi.fn(), + runTwo: vi.fn(), + }; + store( namespace, { callbacks: { ...unsupported, ...supported } } ); + + const region = createRegion( + namespace, + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + ); + await hydrateRegion( region ); + + Object.values( unsupported ).forEach( ( callback ) => + expect( callback ).not.toHaveBeenCalled() + ); + Object.values( supported ).forEach( ( callback ) => + expect( callback ).toHaveBeenCalledTimes( 1 ) + ); + expect( console ).toHaveWarnedWith( + 'Suffixes for the data-wp-watch directive are not supported. Ignoring the directive with suffix "dev".' + ); + expect( console ).toHaveWarnedWith( + 'Suffixes for the data-wp-init directive are not supported. Ignoring the directive with suffix "dev".' + ); + expect( console ).toHaveWarnedWith( + 'Suffixes for the data-wp-run directive are not supported. Ignoring the directive with suffix "dev".' + ); + } ); + + it( 'skip suffixes without warning when SCRIPT_DEBUG is disabled', async () => { + vi.stubGlobal( 'SCRIPT_DEBUG', false ); + const namespace = uniqueNamespace(); + const callbacks = { + watch: vi.fn(), + init: vi.fn(), + run: vi.fn(), + }; + store( namespace, { callbacks } ); + + const region = createRegion( + namespace, + '' + + '' + + '' + ); + await hydrateRegion( region ); + + Object.values( callbacks ).forEach( ( callback ) => + expect( callback ).not.toHaveBeenCalled() + ); + expect( console ).not.toHaveWarned(); + } ); +} ); + +describe( 'data-wp-ignore', () => { + it( 'no longer prevents hydration and warns', async () => { + const namespace = uniqueNamespace(); + store( namespace, { state: { text: 'hydrated' } } ); + + const region = createRegion( + namespace, + '
server
' + ); + await hydrateRegion( region ); + + expect( region.querySelector( 'span' ) ).toHaveTextContent( + 'hydrated' + ); + expect( console ).toHaveWarnedWith( + 'The data-wp-ignore directive has been removed. The element and its descendants are now hydrated like any other element. Please remove the attribute.' + ); + } ); +} ); + +describe( 'negation operator', () => { + it( 'does not invoke functions and warns about derived state', async () => { + const namespace = uniqueNamespace(); + const isClosed = vi.fn( () => true ); + store( namespace, { actions: { isClosed } } ); + + const region = createRegion( + namespace, + '' + ); + await hydrateRegion( region ); + + expect( isClosed ).not.toHaveBeenCalled(); + expect( region.querySelector( 'span' ) ).not.toHaveAttribute( + 'hidden' + ); + expect( console ).toHaveWarnedWith( + 'The value of "actions.isClosed" is a function and cannot be negated. Please use derived state instead.' + ); + } ); + + it( 'does not invoke functions or warn when SCRIPT_DEBUG is disabled', async () => { + vi.stubGlobal( 'SCRIPT_DEBUG', false ); + const namespace = uniqueNamespace(); + const isOpen = vi.fn( () => false ); + store( namespace, { actions: { isOpen } } ); + + const region = createRegion( + namespace, + '' + ); + await hydrateRegion( region ); + + expect( isOpen ).not.toHaveBeenCalled(); + expect( region.querySelector( 'span' ) ).not.toHaveAttribute( + 'hidden' + ); + expect( console ).not.toHaveWarned(); + } ); + + it( 'still negates plain values and getters', async () => { + const namespace = uniqueNamespace(); + const { state } = store( namespace, { + state: { + isOpen: false, + get isVisible() { + return state.isOpen; + }, + }, + } ); + + const region = createRegion( + namespace, + '' + + '' + ); + await hydrateRegion( region ); + const valueElement = region.querySelector( '[data-testid="value"]' )!; + const getterElement = region.querySelector( '[data-testid="getter"]' )!; + + expect( valueElement ).toHaveAttribute( 'hidden' ); + expect( getterElement ).toHaveAttribute( 'hidden' ); + + await act( () => { + state.isOpen = true; + } ); + + expect( valueElement ).not.toHaveAttribute( 'hidden' ); + expect( getterElement ).not.toHaveAttribute( 'hidden' ); + expect( console ).not.toHaveWarned(); + } ); +} ); diff --git a/packages/interactivity/src/test/directives.jsdom.test.ts b/packages/interactivity/src/test/directives.jsdom.test.ts deleted file mode 100644 index f5c9e932bd4c57..00000000000000 --- a/packages/interactivity/src/test/directives.jsdom.test.ts +++ /dev/null @@ -1,205 +0,0 @@ -import { hydrate } from 'preact'; -import { act } from 'preact/test-utils'; -import { expect, test, vi } from 'vitest'; - -await vi.hoisted( async () => { - window.performance.getEntriesByType = () => - [ - { domContentLoadedEventStart: 1 }, - ] as unknown as PerformanceEntryList; - window.performance.measure = () => - undefined as unknown as PerformanceMeasure; -} ); - -/** - * Appends directive markup to the document and hydrates it as the runtime does. - * - * @param html Markup containing a single root element. - * @param toVdom Converts the root element into a virtual DOM tree. - * @param getRegionRootFragment Gets the hydration fragment for the root element. - * @return The hydrated root element. - */ -function hydrateHtml( - html: string, - toVdom: typeof import( '../vdom' ).toVdom, - getRegionRootFragment: typeof import( '../hydration' ).getRegionRootFragment -): Element { - const container = document.createElement( 'div' ); - container.innerHTML = html; - document.body.appendChild( container ); - const element = container.firstElementChild as Element; - hydrate( toVdom( element ), getRegionRootFragment( element ) ); - return element; -} - -test( 'event directives listen for the complete suffix', async () => { - const { privateApis, store } = await import( '../index' ); - const { toVdom, getRegionRootFragment, afterNextFrame } = privateApis( - 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.' - ); - - /** Records invocations of the click event action. */ - const clickAction = vi.fn(); - /** Records invocations of the window resize action. */ - const resizeAction = vi.fn(); - /** Records invocations of the document keydown action. */ - const keydownAction = vi.fn(); - - store( 'test/event-directives', { - actions: { - /** Handles the `click--counter` event. */ - click: clickAction, - /** Handles the `resize--second` event. */ - resize: resizeAction, - /** Handles the `keydown--second` event. */ - keydown: keydownAction, - }, - } ); - - /** Hydrated buttons and their containing interactive region. */ - const root = hydrateHtml( - '
', - toVdom, - getRegionRootFragment - ); - const clickButton = root.querySelector( 'button' )!; - - try { - await afterNextFrame( () => undefined ); - - await act( () => { - clickButton.dispatchEvent( new Event( 'click' ) ); - window.dispatchEvent( new Event( 'resize' ) ); - document.dispatchEvent( new Event( 'keydown' ) ); - } ); - - expect( clickAction ).not.toHaveBeenCalled(); - expect( resizeAction ).not.toHaveBeenCalled(); - expect( keydownAction ).not.toHaveBeenCalled(); - - await act( () => { - clickButton.dispatchEvent( new Event( 'click--counter' ) ); - window.dispatchEvent( new Event( 'resize--second' ) ); - document.dispatchEvent( new Event( 'keydown--second' ) ); - } ); - - expect( clickAction ).toHaveBeenCalledTimes( 1 ); - expect( resizeAction ).toHaveBeenCalledTimes( 1 ); - expect( keydownAction ).toHaveBeenCalledTimes( 1 ); - expect( console ).not.toHaveWarned(); - } finally { - root.parentElement?.remove(); - } -} ); - -test( 'lifecycle directives skip suffixes and keep three-hyphen IDs', async () => { - const { privateApis, store } = await import( '../index' ); - const { toVdom, getRegionRootFragment, afterNextFrame } = privateApis( - 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.' - ); - - /** Records invocations of suffixed lifecycle callbacks. */ - const unsupportedCallbacks = { - watch: vi.fn(), - watchWithUniqueId: vi.fn(), - init: vi.fn(), - run: vi.fn(), - }; - /** Records invocations of lifecycle callbacks with supported unique IDs. */ - const uniqueIdCallbacks = { - watchOne: vi.fn(), - watchTwo: vi.fn(), - initOne: vi.fn(), - initTwo: vi.fn(), - runOne: vi.fn(), - runTwo: vi.fn(), - }; - store( 'test/lifecycle-directives', { - callbacks: { - watch: unsupportedCallbacks.watch, - watchWithUniqueId: unsupportedCallbacks.watchWithUniqueId, - init: unsupportedCallbacks.init, - run: unsupportedCallbacks.run, - ...uniqueIdCallbacks, - }, - } ); - - vi.stubGlobal( 'SCRIPT_DEBUG', false ); - const productionRoot = hydrateHtml( - '
', - toVdom, - getRegionRootFragment - ); - try { - await afterNextFrame( () => undefined ); - expect( unsupportedCallbacks.watch ).not.toHaveBeenCalled(); - expect( unsupportedCallbacks.watchWithUniqueId ).not.toHaveBeenCalled(); - expect( unsupportedCallbacks.init ).not.toHaveBeenCalled(); - expect( unsupportedCallbacks.run ).not.toHaveBeenCalled(); - expect( console ).not.toHaveWarned(); - } finally { - productionRoot.parentElement?.remove(); - } - - vi.stubGlobal( 'SCRIPT_DEBUG', true ); - const developmentRoot = hydrateHtml( - '
', - toVdom, - getRegionRootFragment - ); - try { - await afterNextFrame( () => undefined ); - - expect( unsupportedCallbacks.watch ).not.toHaveBeenCalled(); - expect( unsupportedCallbacks.watchWithUniqueId ).not.toHaveBeenCalled(); - expect( unsupportedCallbacks.init ).not.toHaveBeenCalled(); - expect( unsupportedCallbacks.run ).not.toHaveBeenCalled(); - Object.values( uniqueIdCallbacks ).forEach( ( callback ) => - expect( callback ).toHaveBeenCalledTimes( 1 ) - ); - expect( console ).toHaveWarnedWith( - 'Suffixes are not supported for the data-wp-watch directive. Ignoring the directive with suffix "one".' - ); - expect( console ).toHaveWarnedWith( - 'Suffixes are not supported for the data-wp-init directive. Ignoring the directive with suffix "one".' - ); - expect( console ).toHaveWarnedWith( - 'Suffixes are not supported for the data-wp-run directive. Ignoring the directive with suffix "one".' - ); - } finally { - developmentRoot.parentElement?.remove(); - } -} ); - -test( 'negated functions remain unresolved and warn about derived state', async () => { - const { privateApis, store } = await import( '../index' ); - const { toVdom, getRegionRootFragment, afterNextFrame } = privateApis( - 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.' - ); - - /** Records invocations of the negated action. */ - const isClosed = vi.fn(); - store( 'test/negated-functions', { - actions: { isClosed }, - } ); - - vi.stubGlobal( 'SCRIPT_DEBUG', true ); - const root = hydrateHtml( - '
', - toVdom, - getRegionRootFragment - ); - const boundElement = root.querySelector( 'span' )!; - - try { - await afterNextFrame( () => undefined ); - - expect( isClosed ).not.toHaveBeenCalled(); - expect( boundElement ).not.toHaveAttribute( 'hidden' ); - expect( console ).toHaveWarnedWith( - 'The value of "actions.isClosed" is a function and cannot be negated. Please use derived state instead.' - ); - } finally { - root.parentElement?.remove(); - } -} ); From 6ecd5658f49fe50f864647f26c5ebd1541ed7192 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 6 Oct 2026 12:43:16 +0200 Subject: [PATCH 17/19] Interactivity API: Rename stale isolated island e2e fixtures --- .../tovdom-islands/render.php | 18 +++++++----------- .../specs/interactivity/tovdom-islands.spec.ts | 10 ++++------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php b/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php index 5bccb4fcfe0954..3281740f422761 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php +++ b/packages/e2e-tests/plugins/interactive-blocks/tovdom-islands/render.php @@ -32,13 +32,9 @@
- - This should be hidden because directives inside a - `data-wp-ignore` element of an island are hydrated, so - the `data-wp-show-mock="state.falseValue"` directive - wrapping it runs. + + This should not be shown because data-wp-ignore no + longer prevents hydration.
@@ -65,11 +61,11 @@ >
- This should not be shown because even though it - is inside an inner block of an isolated island, - it's inside an new island. + This should not be shown because it is inside a + new island nested in an inner element of another + island.
diff --git a/test/e2e/specs/interactivity/tovdom-islands.spec.ts b/test/e2e/specs/interactivity/tovdom-islands.spec.ts index 5cdcbe3c3659f0..e9b343be614434 100644 --- a/test/e2e/specs/interactivity/tovdom-islands.spec.ts +++ b/test/e2e/specs/interactivity/tovdom-islands.spec.ts @@ -36,12 +36,10 @@ test.describe( 'toVdom - islands', () => { await expect( el ).toBeHidden(); } ); - test( 'directives inside a data-wp-ignore element of an island should be hydrated', async ( { + test( 'directives inside an element with data-wp-ignore should be hydrated', async ( { page, } ) => { - const el = page.getByTestId( - 'inside an inner block of an isolated island' - ); + const el = page.getByTestId( 'inside an element with data-wp-ignore' ); await expect( el ).toBeHidden(); } ); @@ -53,11 +51,11 @@ test.describe( 'toVdom - islands', () => { await expect( templates ).toHaveCount( 1 ); } ); - test( 'islands inside inner blocks of isolated islands should be hydrated', async ( { + test( 'islands nested in inner elements of other islands should be hydrated', async ( { page, } ) => { const el = page.getByTestId( - 'island inside inner block of isolated island' + 'island inside an inner element of another island' ); await expect( el ).toBeHidden(); } ); From 6de02d292594e91e3f8563976063f59e760cfb97 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 6 Oct 2026 12:43:21 +0200 Subject: [PATCH 18/19] Interactivity API: Document unique IDs for event directives and function negation --- .../interactivity-api/directives-and-store.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/reference-guides/interactivity-api/directives-and-store.md b/docs/reference-guides/interactivity-api/directives-and-store.md index 336b18dd0b0a32..1f14e7e98d5ff4 100644 --- a/docs/reference-guides/interactivity-api/directives-and-store.md +++ b/docs/reference-guides/interactivity-api/directives-and-store.md @@ -415,6 +415,17 @@ The `wp-on` directive is executed each time the associated event is triggered. The callback passed as the reference receives [the event](https://developer.mozilla.org/en-US/docs/Web/API/Event) (`event`), and the returned value by this callback is ignored. +You can attach several callbacks to the same event of a DOM element by using the syntax `data-wp-on--[event]---[unique-id]` (note the three hyphens before the unique ID). Everything between `data-wp-on--` and the three hyphens is used as the event name, so `data-wp-on--click--counter` listens for an event named `click--counter`, not for `click`. + +```html + +``` + ### `wp-on-window`
@@ -448,6 +459,8 @@ store( 'myPlugin', { The callback passed as the reference receives [the event](https://developer.mozilla.org/en-US/docs/Web/API/Event) (`event`), and the returned value by this callback is ignored. When the element is removed from the DOM, the event listener is also removed. +You can attach several callbacks to the same window event by using the syntax `data-wp-on-window--[window-event]---[unique-id]` (note the three hyphens before the unique ID), like `data-wp-on-window--resize---log-width`. + ### `wp-on-document`
@@ -481,6 +494,8 @@ store( 'myPlugin', { The callback passed as the reference receives [the event](https://developer.mozilla.org/en-US/docs/Web/API/Event) (`event`), and the returned value by this callback is ignored. When the element is removed from the DOM, the event listener is also removed. +You can attach several callbacks to the same document event by using the syntax `data-wp-on-document--[document-event]---[unique-id]` (note the three hyphens before the unique ID), like `data-wp-on-document--keydown---log-key`. + ### `wp-watch` It runs a callback **when the node is created and runs it again when the state or context changes**. @@ -770,6 +785,8 @@ And then, the string value `"state.isPlaying"` is used to assign the result of t
``` +The `!` operator negates the referenced value. It only works with values, such as state, context, or derived state defined with a getter. If the reference points to a function, such as an action or a callback, the function is not called and the directive receives `undefined` instead (with a warning when `SCRIPT_DEBUG` is enabled). To negate the result of a computation, define it as derived state with a getter and negate that. + These values assigned to directives are **references** to a particular property in the store. They are wired to the directives automatically so that each directive “knows” what store element refers to, without any additional configuration. Note that, by default, references point to properties in the current namespace, which is the one specified by the closest ancestor with a `data-wp-interactive` attribute. If you need to access a property from a different namespace, you can explicitly set the namespace where the property accessed is defined. The syntax is `namespace::reference`, replacing `namespace` with the appropriate value. From 14117757c09b4fa7026e3175d1d11f68211efd23 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 6 Oct 2026 12:43:22 +0200 Subject: [PATCH 19/19] Interactivity API: Split the breaking changes changelog entry --- packages/interactivity/CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/interactivity/CHANGELOG.md b/packages/interactivity/CHANGELOG.md index 192892d9d4b849..e8a434f124c38c 100644 --- a/packages/interactivity/CHANGELOG.md +++ b/packages/interactivity/CHANGELOG.md @@ -4,7 +4,10 @@ ### Breaking Changes -- Remove three behaviors whose deprecation warnings named WordPress versions that have already shipped. Use the replacement for each: (1) The `data-wp-ignore` directive is gone, and an element carrying it now hydrates like any other element, so drop the attribute and expect ordinary hydration. (2) Two-hyphen unique IDs, such as `data-wp-on--click--id`, are no longer recognized on `data-wp-watch`, `data-wp-init`, `data-wp-run`, `data-wp-on`, `data-wp-on-window`, and `data-wp-on-document`; use the three-hyphen form, such as `data-wp-on--click---id`. On `data-wp-watch`, `data-wp-init`, and `data-wp-run`, a suffix now makes the directive skipped, with a warning in development mode, and on the `data-wp-on` family the text after `on--` is now read whole as the event name instead of being cut at `--`. (3) Applying `!` to a function in a directive value, such as `data-wp-bind--hidden="!state.isOpen"` when `isOpen` is a function, now leaves the value unresolved, with a warning in development mode; use derived state, such as a getter, instead. Negating a non-function value or a getter is unchanged ([#84098](https://github.com/WordPress/gutenberg/pull/84098)). +- Remove the `data-wp-ignore` directive. An element carrying it is now hydrated like any other element, and a warning is shown in development mode. Remove the attribute. ([#84098](https://github.com/WordPress/gutenberg/pull/84098)) +- Remove support for two-hyphen unique IDs, such as `data-wp-watch--id` or `data-wp-on--click--id`. Use three hyphens instead, such as `data-wp-watch---id` or `data-wp-on--click---id`. `data-wp-watch`, `data-wp-init`, and `data-wp-run` now skip directives with a suffix, and `data-wp-on`, `data-wp-on-window`, and `data-wp-on-document` now use the whole text after `--` as the event name. Both show a warning in development mode. The deprecated `data-wp-on-async` directives are unchanged. ([#84098](https://github.com/WordPress/gutenberg/pull/84098)) +- Applying `!` to a function in a directive value, such as `data-wp-bind--hidden="!actions.isOpen"`, no longer calls the function: the value resolves to `undefined`, with a warning in development mode. Use derived state defined with a getter instead. Negating values and getters is unchanged. ([#84098](https://github.com/WordPress/gutenberg/pull/84098)) +- The `evaluate` function passed to directive callbacks now accepts only the directive entry. Additional arguments, which were only forwarded to negated functions, are no longer accepted. ([#84098](https://github.com/WordPress/gutenberg/pull/84098)) ### New Features