diff --git a/src/generators/nodes/Element.ts b/src/generators/nodes/Element.ts index 066072a0d9..140db2d36e 100644 --- a/src/generators/nodes/Element.ts +++ b/src/generators/nodes/Element.ts @@ -246,15 +246,10 @@ export default class Element extends Node { this.addBindings(block, allUsedContexts); const eventHandlerUsesComponent = this.addEventHandlers(block, allUsedContexts); this.addRefs(block); + this.addAttributes(block); this.addTransitions(block); this.addActions(block); - if (this.attributes.find(attr => attr.type === 'Spread')) { - this.addSpreadAttributes(block); - } else { - this.addAttributes(block); - } - if (allUsedContexts.size || eventHandlerUsesComponent) { const initialProps: string[] = []; const updates: string[] = []; @@ -443,6 +438,11 @@ export default class Element extends Node { } addAttributes(block: Block) { + if (this.attributes.find(attr => attr.type === 'Spread')) { + this.addSpreadAttributes(block); + return; + } + this.attributes.filter((a: Attribute) => a.type === 'Attribute').forEach((attribute: Attribute) => { attribute.render(block); }); @@ -609,6 +609,7 @@ export default class Element extends Node { } addRefs(block: Block) { + // TODO it should surely be an error to have more than one ref this.attributes.filter((a: Ref) => a.type === 'Ref').forEach((attribute: Ref) => { const ref = `#component.refs.${attribute.name}`; diff --git a/src/generators/server-side-rendering/visitors/Element.ts b/src/generators/server-side-rendering/visitors/Element.ts index 9fbb56165f..fe193170cb 100644 --- a/src/generators/server-side-rendering/visitors/Element.ts +++ b/src/generators/server-side-rendering/visitors/Element.ts @@ -36,6 +36,7 @@ export default function visitElement( } if (node.attributes.find(attr => attr.type === 'Spread')) { + // TODO dry this out const args = []; node.attributes.forEach((attribute: Node) => { if (attribute.type === 'Spread') { diff --git a/test/runtime/samples/spread-component/_config.js b/test/runtime/samples/spread-component/_config.js index 66df4c04e7..06acc4906d 100644 --- a/test/runtime/samples/spread-component/_config.js +++ b/test/runtime/samples/spread-component/_config.js @@ -1,6 +1,4 @@ export default { - solo: true, - data: { props: { foo: 'lol', diff --git a/test/runtime/samples/spread-element/_config.js b/test/runtime/samples/spread-element/_config.js index 4f0043a97d..bd6c0b891e 100644 --- a/test/runtime/samples/spread-element/_config.js +++ b/test/runtime/samples/spread-element/_config.js @@ -1,6 +1,4 @@ export default { - solo: true, - html: `
red
`, test ( assert, component, target ) {