update spread props in each blocks without other dynamic attributes - fixes #1337

pull/1357/head
Rich Harris 7 years ago
parent c84bd85167
commit a0404f7331

@ -37,7 +37,7 @@ export default class Component extends Node {
attribute.expression.arguments.forEach((arg: Node) => { attribute.expression.arguments.forEach((arg: Node) => {
block.addDependencies(arg.metadata.dependencies); block.addDependencies(arg.metadata.dependencies);
}); });
} else if (attribute.type === 'Binding') { } else if (attribute.type === 'Binding' || attribute.type === 'Spread') {
block.addDependencies(attribute.metadata.dependencies); block.addDependencies(attribute.metadata.dependencies);
} }
} }

@ -89,6 +89,8 @@ export default class Element extends Node {
} }
} else if (attribute.type === 'Action' && attribute.expression) { } else if (attribute.type === 'Action' && attribute.expression) {
block.addDependencies(attribute.metadata.dependencies); block.addDependencies(attribute.metadata.dependencies);
} else if (attribute.type === 'Spread') {
block.addDependencies(attribute.metadata.dependencies);
} }
} }
}); });

@ -0,0 +1 @@
<div data-a={a} data-b={b}></div>

@ -0,0 +1,26 @@
export default {
html: `
<div data-a="1" data-b="2"></div>
<div data-a="3" data-b="4"></div>
`,
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, `
<div data-a="3" data-b="4"></div>
<div data-a="1" data-b="2"></div>
`);
},
};

@ -0,0 +1,11 @@
{#each things as thing}
<Nested {...thing}/>
{/each}
<script>
import Nested from './Nested.html';
export default {
components: { Nested }
};
</script>

@ -0,0 +1,26 @@
export default {
html: `
<div data-a="1" data-b="2"></div>
<div data-c="3" data-d="4"></div>
`,
data: {
things: [
{ 'data-a': 1, 'data-b': 2 },
{ 'data-c': 3, 'data-d': 4 }
]
},
test(assert, component, target) {
const { things } = component.get();
component.set({
things: things.reverse()
});
assert.htmlEqual(target.innerHTML, `
<div data-c="3" data-d="4"></div>
<div data-a="1" data-b="2"></div>
`);
},
};

@ -0,0 +1,3 @@
{#each things as thing}
<div {...thing}></div>
{/each}
Loading…
Cancel
Save