allow reactive declarations to only depend on $$props - fixes #2264

pull/2266/head
Rich Harris 6 years ago
parent 51ab376de8
commit 0f4cf99bcd

@ -346,6 +346,7 @@ export default function dom(
const reactive_declarations = component.reactive_declarations.map(d => {
const condition = Array.from(d.dependencies)
.filter(n => {
if (n === '$$props') return false;
const variable = component.var_lookup.get(n);
return variable && variable.writable;
})
@ -358,8 +359,11 @@ export default function dom(
[${d.node.body.start}-${d.node.end}]
}`;
return deindent`
if (${condition}) ${snippet}`
return condition
? deindent`
if (${condition}) ${snippet}`
: deindent`
${snippet}`
});
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