mirror of https://github.com/sveltejs/svelte
Merge pull request #1628 from sveltejs/gh-1540
handle rest elements in computed propertiespull/1636/head
commit
e35f174207
@ -0,0 +1,27 @@
|
||||
export default {
|
||||
skip: +/v(\d+)/.exec(process.version)[1] < 8,
|
||||
|
||||
html: `
|
||||
<pre>{"wanted":2}</pre>
|
||||
`,
|
||||
|
||||
test(assert, component, target) {
|
||||
component.set({
|
||||
unwanted: 3,
|
||||
wanted: 4
|
||||
});
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<pre>{"wanted":4}</pre>
|
||||
`);
|
||||
|
||||
component.set({
|
||||
unwanted: 5,
|
||||
wanted: 6
|
||||
});
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<pre>{"wanted":6}</pre>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,18 @@
|
||||
<pre>{JSON.stringify(props)}</pre>
|
||||
<script>
|
||||
export default {
|
||||
data: () => ({
|
||||
unwanted: 1,
|
||||
wanted: 2
|
||||
}),
|
||||
|
||||
helpers: {
|
||||
// prevent this being mixed in with data
|
||||
JSON
|
||||
},
|
||||
|
||||
computed: {
|
||||
props: ({ unwanted, ...x }) => x
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue