Skip to content

Commit

Permalink
invalidate styles cache when assets are changed
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Oct 9, 2024
1 parent b965a68 commit 80db76d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/builder/app/canvas/shared/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,18 @@ export const subscribeStyles = () => {

// add/delete declarations in mixins
let prevStylesSet = new Set<StyleDecl>();
let prevTransformValue: undefined | TransformValue;
// track value transformer to properly serialize var() fallback as unparsed
// before it was managed css engine but here toValue is invoked by styles renderer directly
const unsubscribeStyles = computed(
[$styles, $transformValue],
(styles, transformValue) => [styles, transformValue] as const
).subscribe(([styles, transformValue]) => {
// invalidate styles cache when assets are changed
if (prevTransformValue !== transformValue) {
prevTransformValue = transformValue;
prevStylesSet = new Set();
}
const stylesSet = new Set(styles.values());
const addedStyles = setDifference(stylesSet, prevStylesSet);
const deletedStyles = setDifference(prevStylesSet, stylesSet);
Expand Down

0 comments on commit 80db76d

Please sign in to comment.