File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed
src/compiler/phases/2-analyze
tests/runtime-legacy/samples/event-handler-mutation-scope Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ function get_delegated_event(node, context) {
175
175
// Bail-out if we reference anything from the EachBlock (for now) that mutates in non-runes mode,
176
176
( ( ! context . state . analysis . runes && binding . kind === 'each' ) ||
177
177
// or any normal not reactive bindings that are mutated.
178
- ( binding . kind === 'normal' && context . state . analysis . runes ) ||
178
+ binding . kind === 'normal' ||
179
179
// or any reactive imports (those are rewritten) (can only happen in legacy mode)
180
180
( binding . kind === 'state' && binding . declaration_kind === 'import' ) ) &&
181
181
binding . mutated
Original file line number Diff line number Diff line change
1
+ import { flushSync } from 'svelte' ;
2
+ import { ok , test } from '../../test' ;
3
+
4
+ export default test ( {
5
+ test ( { assert, component, target, window } ) {
6
+ const button = target . querySelector ( 'button' ) ;
7
+ ok ( button ) ;
8
+
9
+ flushSync ( ( ) => {
10
+ button . click ( ) ;
11
+ } ) ;
12
+
13
+ assert . deepEqual ( component . log , [ '1 - 1' ] ) ;
14
+
15
+ flushSync ( ( ) => {
16
+ button . click ( ) ;
17
+ } ) ;
18
+
19
+ assert . deepEqual ( component . log , [ '1 - 1' , '2 - 2' ] ) ;
20
+ }
21
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ export let log = [];
3
+ let referenced_directly = 0 ;
4
+ let not_referenced_directly = 0 ;
5
+ let css_based_on_not_referenced = ' ' ;
6
+
7
+ function click () {
8
+ referenced_directly += 1 ;
9
+ not_referenced_directly += 1 ;
10
+ css_based_on_not_referenced = not_referenced_directly % 2 == 1 ? ' background-color: red' : ' ' ;
11
+ log .push (referenced_directly + ' - ' + not_referenced_directly); // only referenced_directly is increasing
12
+ }
13
+ </script >
14
+
15
+ <button on:click ={click } style ={css_based_on_not_referenced }> increase both </button >
16
+ {referenced_directly }
You can’t perform that action at this time.
0 commit comments