fix: interpolated style directive updates properly with spread

pull/8505/head
gtmnayan 3 years ago
parent eab148f8b9
commit 8486b9f904

@ -1240,19 +1240,27 @@ export default class ElementWrapper extends Wrapper {
block.chunks.hydrate.push(updater); block.chunks.hydrate.push(updater);
const self_deps = expression.dynamic_dependencies();
const all_deps = new Set([
...self_deps,
...this.dynamic_style_dependencies,
]);
let condition = block.renderer.dirty([...all_deps]);
// Assume that style has changed through the spread attribute // Assume that style has changed through the spread attribute
if (has_spread) { if (has_spread) {
if (should_cache && all_deps.size) {
// Update the cached value
block.chunks.update.push(b`
if (${condition}) {
${cached_snippet} = ${snippet};
}`
);
}
block.chunks.update.push(updater); block.chunks.update.push(updater);
} else { } else {
const self_deps = expression.dynamic_dependencies(); if (all_deps.size === 0) return;
const all_deps = new Set([
...self_deps,
...this.dynamic_style_dependencies
]);
if (all_deps.size === 0) return;
let condition = block.renderer.dirty([...all_deps]);
if (should_cache) { if (should_cache) {
condition = x`${condition} && ${cached_snippet} !== (${cached_snippet} = ${snippet})`; condition = x`${condition} && ${cached_snippet} !== (${cached_snippet} = ${snippet})`;

Loading…
Cancel
Save