Skip to content

Commit

Permalink
Add fallback to previous element ID for iAPI store data
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed May 14, 2024
1 parent 84810f8 commit 003a1d7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/interactivity/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 003a1d7

Please sign in to comment.