From 003a1d7cb125c3a246c1abd78ff38991f61a4ae6 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Tue, 14 May 2024 17:14:21 +0200 Subject: [PATCH] Add fallback to previous element ID for iAPI store data --- packages/interactivity/src/store.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/interactivity/src/store.ts b/packages/interactivity/src/store.ts index ea5ef07a2613eb..ddadc01c0bbf1b 100644 --- a/packages/interactivity/src/store.ts +++ b/packages/interactivity/src/store.ts @@ -320,9 +320,11 @@ export function store( } export const parseInitialData = ( dom = document ) => { - const jsonDataScriptTag = dom.getElementById( - 'wp-scriptmodule-data_@wordpress/interactivity' - ); + const jsonDataScriptTag = + // Preferred Script Module data passing form + dom.getElementById( 'wp-scriptmodule-data_@wordpress/interactivity' ) ?? + // Legacy form + dom.getElementById( 'wp-interactivity-data' ); if ( jsonDataScriptTag?.textContent ) { try { return JSON.parse( jsonDataScriptTag.textContent );