diff --git a/src/compiler/compile/render_dom/wrappers/Element/index.ts b/src/compiler/compile/render_dom/wrappers/Element/index.ts index 9b14d1cd6c..9d3f60ac7e 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/index.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/index.ts @@ -548,6 +548,13 @@ export default class ElementWrapper extends Wrapper { } add_attributes(block: Block) { + // Get all the class dependencies first + this.attributes.forEach((attribute) => { + if (attribute.node.name === 'class' && attribute.node.is_dynamic) { + this.class_dependencies.push(...attribute.node.dependencies); + } + }); + // @ts-ignore todo: if (this.node.attributes.find(attr => attr.type === 'Spread')) { this.add_spread_attributes(block); @@ -555,9 +562,6 @@ export default class ElementWrapper extends Wrapper { } this.attributes.forEach((attribute) => { - if (attribute.node.name === 'class' && attribute.node.is_dynamic) { - this.class_dependencies.push(...attribute.node.dependencies); - } attribute.render(block); }); }