File tree 4 files changed +30
-2
lines changed
test/runtime/samples/reactive-value-mutate-const
4 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -1114,9 +1114,11 @@ export default class Component {
1114
1114
if ( ! assignee_nodes . has ( identifier ) ) {
1115
1115
const { name } = identifier ;
1116
1116
const owner = scope . find_owner ( name ) ;
1117
+ const component_var = component . var_lookup . get ( name ) ;
1118
+ const is_writable_or_mutated = component_var && ( component_var . writable || component_var . mutated ) ;
1117
1119
if (
1118
1120
( ! owner || owner === component . instance_scope ) &&
1119
- ( name [ 0 ] === '$' || component . var_lookup . has ( name ) && component . var_lookup . get ( name ) . writable )
1121
+ ( name [ 0 ] === '$' || is_writable_or_mutated )
1120
1122
) {
1121
1123
dependencies . add ( name ) ;
1122
1124
}
Original file line number Diff line number Diff line change @@ -364,7 +364,7 @@ export default function dom(
364
364
}
365
365
366
366
const variable = component . var_lookup . get ( n ) ;
367
- return variable && variable . writable ;
367
+ return variable && ( variable . writable || variable . mutated ) ;
368
368
} )
369
369
. map ( n => `$$dirty.${ n } ` ) . join ( ' || ' ) ;
370
370
Original file line number Diff line number Diff line change
1
+ export default {
2
+ html : `
3
+ <button>Mutate a</button>
4
+ <div>{}</div>
5
+ ` ,
6
+
7
+ async test ( { assert, target } ) {
8
+ const button = target . querySelector ( 'button' ) ;
9
+ const click = new window . MouseEvent ( 'click' ) ;
10
+
11
+ await button . dispatchEvent ( click ) ;
12
+ assert . htmlEqual ( target . innerHTML , `
13
+ <button>Mutate a</button>
14
+ <div>{"foo":42}</div>
15
+ ` ) ;
16
+ }
17
+ } ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ const a = {};
3
+ const b = {};
4
+ $: b .foo = a .foo ;
5
+ </script >
6
+
7
+ <button on:click ={() => a .foo = 42 }>Mutate a</button >
8
+ <div >{JSON .stringify (b )}</div >
9
+
You can’t perform that action at this time.
0 commit comments