Skip to content

Commit

Permalink
Merge pull request #1630 from tomusborne/fix/inline-dynamic-bgs
Browse files Browse the repository at this point in the history
Fix: Inline dynamic bgs
  • Loading branch information
iansvo authored Jan 2, 2025
2 parents ac74231 + 5bcdb01 commit 06f2614
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/editor/style-html-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ addFilter(
}

// Get the cached result if available.
if ( cache[ clientId ][ style ] ) {
return cache[ style ];
if ( cache[ blockCacheKey ][ style ] ) {
return cache[ blockCacheKey ][ style ];
}

const replacements = await replaceTags( { content: style, context, clientId } );
Expand All @@ -53,9 +53,6 @@ addFilter(
return style;
}

// Cache the result.
cache[ clientId ][ style ] = replacements;

const withReplacements = replacements.reduce( ( acc, { original, replacement, fallback } ) => {
if ( ! replacement ) {
return acc.replaceAll( original, fallback );
Expand All @@ -64,6 +61,11 @@ addFilter(
return acc.replaceAll( original, replacement );
}, style );

return withReplacements ? withReplacements : style;
const newStyle = withReplacements ? withReplacements : style;

// Cache the result.
cache[ blockCacheKey ][ style ] = newStyle;

return newStyle;
}
);

0 comments on commit 06f2614

Please sign in to comment.