diff --git a/src/generators/nodes/Component.ts b/src/generators/nodes/Component.ts index d7bd3d442f..cc82981928 100644 --- a/src/generators/nodes/Component.ts +++ b/src/generators/nodes/Component.ts @@ -37,7 +37,7 @@ export default class Component extends Node { attribute.expression.arguments.forEach((arg: Node) => { block.addDependencies(arg.metadata.dependencies); }); - } else if (attribute.type === 'Binding') { + } else if (attribute.type === 'Binding' || attribute.type === 'Spread') { block.addDependencies(attribute.metadata.dependencies); } } diff --git a/src/generators/nodes/Element.ts b/src/generators/nodes/Element.ts index 0bc180e8d1..a44c949816 100644 --- a/src/generators/nodes/Element.ts +++ b/src/generators/nodes/Element.ts @@ -89,6 +89,8 @@ export default class Element extends Node { } } else if (attribute.type === 'Action' && attribute.expression) { block.addDependencies(attribute.metadata.dependencies); + } else if (attribute.type === 'Spread') { + block.addDependencies(attribute.metadata.dependencies); } } }); diff --git a/src/utils/flattenReference.ts b/src/utils/flattenReference.ts index b44fb6e27f..a2303bca34 100644 --- a/src/utils/flattenReference.ts +++ b/src/utils/flattenReference.ts @@ -1,6 +1,6 @@ import { Node } from '../interfaces'; -export default function flatten(node: Node) { +export default function flattenReference(node: Node) { const parts = []; const propEnd = node.end; diff --git a/test/runtime/samples/spread-each-component/Nested.html b/test/runtime/samples/spread-each-component/Nested.html new file mode 100644 index 0000000000..fb0f25d2e7 --- /dev/null +++ b/test/runtime/samples/spread-each-component/Nested.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/runtime/samples/spread-each-component/_config.js b/test/runtime/samples/spread-each-component/_config.js new file mode 100644 index 0000000000..c5fcfb06b7 --- /dev/null +++ b/test/runtime/samples/spread-each-component/_config.js @@ -0,0 +1,26 @@ +export default { + html: ` + + + `, + + data: { + things: [ + { a: 1, b: 2 }, + { a: 3, b: 4 } + ] + }, + + test(assert, component, target) { + const { things } = component.get(); + + component.set({ + things: things.reverse() + }); + + assert.htmlEqual(target.innerHTML, ` + + + `); + }, +}; diff --git a/test/runtime/samples/spread-each-component/main.html b/test/runtime/samples/spread-each-component/main.html new file mode 100644 index 0000000000..0e1e9ce1d6 --- /dev/null +++ b/test/runtime/samples/spread-each-component/main.html @@ -0,0 +1,11 @@ +{#each things as thing} +