Skip to content

Commit

Permalink
Fix: Inline dynamic bgs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusborne committed Jan 2, 2025
1 parent e8d3597 commit 5bcdb01
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 5bcdb01

Please sign in to comment.