Merge pull request #2266 from sveltejs/gh-2264

allow reactive declarations to only depend on $$props
pull/2269/head
Rich Harris 6 years ago committed by GitHub
commit beeaa3d09b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -352,6 +352,7 @@ export default function dom(
const reactive_declarations = component.reactive_declarations.map(d => { const reactive_declarations = component.reactive_declarations.map(d => {
const condition = Array.from(d.dependencies) const condition = Array.from(d.dependencies)
.filter(n => { .filter(n => {
if (n === '$$props') return false;
const variable = component.var_lookup.get(n); const variable = component.var_lookup.get(n);
return variable && variable.writable; return variable && variable.writable;
}) })
@ -364,8 +365,11 @@ export default function dom(
[${d.node.body.start}-${d.node.end}] [${d.node.body.start}-${d.node.end}]
}`; }`;
return deindent` return condition
? deindent`
if (${condition}) ${snippet}` if (${condition}) ${snippet}`
: deindent`
${snippet}`
}); });
const injected = Array.from(component.injected_reactive_declaration_vars).filter(name => { const injected = Array.from(component.injected_reactive_declaration_vars).filter(name => {

@ -0,0 +1,9 @@
<script>
let props;
$: {
let { foo, bar, baz, ...others } = $$props;
props = others;
}
</script>
<p>{props.qux}</p>

@ -0,0 +1,22 @@
export default {
show: 1,
props: {
a: 1,
b: 2,
c: 3,
d: 4
},
html: `
<p>4</p>
`,
test({ assert, component, target }) {
component.d = 5;
assert.htmlEqual(target.innerHTML, `
<p>5</p>
`);
}
};

@ -0,0 +1,10 @@
<script>
import Nested from './Nested.svelte';
export let a;
export let b;
export let c;
export let d;
</script>
<Nested foo={a} bar={b} baz={c} qux={d}/>
Loading…
Cancel
Save