Skip to content

Commit b3ef4e6

Browse files
committed
always update reactive declarations with $$props - fixes #3286
1 parent 17beaa0 commit b3ef4e6

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

src/compiler/compile/render_dom/index.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,11 @@ export default function dom(
359359

360360
component.reactive_declarations
361361
.forEach(d => {
362-
let uses_props;
362+
const dependencies = Array.from(d.dependencies);
363+
const uses_props = !!dependencies.find(n => n === '$$props');
363364

364-
const condition = Array.from(d.dependencies)
365+
const condition = !uses_props && dependencies
365366
.filter(n => {
366-
if (n === '$$props') {
367-
uses_props = true;
368-
return false;
369-
}
370-
371367
const variable = component.var_lookup.get(n);
372368
return variable && (variable.writable || variable.mutated);
373369
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export default {
2+
props: {
3+
a: 1,
4+
b: 2
5+
},
6+
7+
html: `
8+
<p>a: 1</p>
9+
<p>b: 2</p>
10+
<p>c: 3</p>
11+
`,
12+
13+
async test({ assert, component, target }) {
14+
await component.$set({ a: 4 });
15+
16+
assert.htmlEqual(target.innerHTML, `
17+
<p>a: 4</p>
18+
<p>b: 2</p>
19+
<p>c: 6</p>
20+
`);
21+
22+
await component.$set({ b: 5 });
23+
24+
assert.htmlEqual(target.innerHTML, `
25+
<p>a: 4</p>
26+
<p>b: 5</p>
27+
<p>c: 9</p>
28+
`);
29+
}
30+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script>
2+
export let a;
3+
$: c = a + $$props.b;
4+
</script>
5+
6+
<p>a: {a}</p>
7+
<p>b: {$$props.b}</p>
8+
<p>c: {c}</p>

0 commit comments

Comments
 (0)