File tree Expand file tree Collapse file tree 3 files changed +103
-3
lines changed
src/compiler/compile/render_dom/wrappers
test/runtime/samples/bitmask-overflow-if Expand file tree Collapse file tree 3 files changed +103
-3
lines changed Original file line number Diff line number Diff line change @@ -288,7 +288,7 @@ export default class IfBlockWrapper extends Wrapper {
288
288
}
289
289
290
290
block . chunks . init . push ( b `
291
- let ${ current_block_type } = ${ select_block_type } (#ctx, -1 );
291
+ let ${ current_block_type } = ${ select_block_type } (#ctx, ${ this . get_initial_dirty_bit ( ) } );
292
292
let ${ name } = ${ get_block } ;
293
293
` ) ;
294
294
@@ -407,12 +407,12 @@ export default class IfBlockWrapper extends Wrapper {
407
407
408
408
if ( has_else ) {
409
409
block . chunks . init . push ( b `
410
- ${ current_block_type_index } = ${ select_block_type } (#ctx, -1 );
410
+ ${ current_block_type_index } = ${ select_block_type } (#ctx, ${ this . get_initial_dirty_bit ( ) } );
411
411
${ name } = ${ if_blocks } [${ current_block_type_index } ] = ${ if_block_creators } [${ current_block_type_index } ](#ctx);
412
412
` ) ;
413
413
} else {
414
414
block . chunks . init . push ( b `
415
- if (~(${ current_block_type_index } = ${ select_block_type } (#ctx, -1 ))) {
415
+ if (~(${ current_block_type_index } = ${ select_block_type } (#ctx, ${ this . get_initial_dirty_bit ( ) } ))) {
416
416
${ name } = ${ if_blocks } [${ current_block_type_index } ] = ${ if_block_creators } [${ current_block_type_index } ](#ctx);
417
417
}
418
418
` ) ;
@@ -587,4 +587,18 @@ export default class IfBlockWrapper extends Wrapper {
587
587
` ) ;
588
588
}
589
589
}
590
+
591
+ get_initial_dirty_bit ( ) {
592
+ const _this = this ;
593
+ const array = x `[-1]` ;
594
+ const val = x `-1` ;
595
+
596
+ return {
597
+ ...array ,
598
+ ...val ,
599
+ get type ( ) {
600
+ return _this . renderer . context_overflow ? 'ArrayExpression' : 'Literal' ;
601
+ } ,
602
+ } ;
603
+ }
590
604
}
Original file line number Diff line number Diff line change
1
+ export default {
2
+ html : `
3
+ 012345678910111213141516171819202122232425262728293031323334353637383940
4
+ expected: true
5
+ if: true
6
+ <button></button>
7
+ ` ,
8
+
9
+ async test ( { assert, component, target, window } ) {
10
+ const button = target . querySelector ( "button" ) ;
11
+ await button . dispatchEvent ( new window . MouseEvent ( "click" ) ) ;
12
+
13
+ assert . htmlEqual (
14
+ target . innerHTML ,
15
+ `
16
+ 112345678910111213141516171819202122232425262728293031323334353637383940
17
+ expected: false
18
+ if: false
19
+ <div></div>
20
+ <button></button>
21
+ `
22
+ ) ;
23
+ }
24
+ } ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import { fade } from ' svelte/transition' ;
3
+ export let _a = [];
4
+ export let _0 = ' 0' ;
5
+ export let _1 = ' 1' ;
6
+ export let _2 = ' 2' ;
7
+ export let _3 = ' 3' ;
8
+ export let _4 = ' 4' ;
9
+ export let _5 = ' 5' ;
10
+ export let _6 = ' 6' ;
11
+ export let _7 = ' 7' ;
12
+ export let _8 = ' 8' ;
13
+ export let _9 = ' 9' ;
14
+ export let _10 = ' 10' ;
15
+ export let _11 = ' 11' ;
16
+ export let _12 = ' 12' ;
17
+ export let _13 = ' 13' ;
18
+ export let _14 = ' 14' ;
19
+ export let _15 = ' 15' ;
20
+ export let _16 = ' 16' ;
21
+ export let _17 = ' 17' ;
22
+ export let _18 = ' 18' ;
23
+ export let _19 = ' 19' ;
24
+ export let _20 = ' 20' ;
25
+ export let _21 = ' 21' ;
26
+ export let _22 = ' 22' ;
27
+ export let _23 = ' 23' ;
28
+ export let _24 = ' 24' ;
29
+ export let _25 = ' 25' ;
30
+ export let _26 = ' 26' ;
31
+ export let _27 = ' 27' ;
32
+ export let _28 = ' 28' ;
33
+ export let _29 = ' 29' ;
34
+ export let _30 = ' 30' ;
35
+ export let _31 = ' 31' ;
36
+ export let _32 = ' 32' ;
37
+ export let _33 = ' 33' ;
38
+ export let _34 = ' 34' ;
39
+ export let _35 = ' 35' ;
40
+ export let _36 = ' 36' ;
41
+ export let _37 = ' 37' ;
42
+ export let _38 = ' 38' ;
43
+ export let _39 = ' 39' ;
44
+ export let _40 = ' 40' ;
45
+
46
+ function update () {
47
+ _0 = ' 1' ;
48
+ }
49
+ </script >
50
+
51
+
52
+ {_0 }{_1 }{_2 }{_3 }{_4 }{_5 }{_6 }{_7 }{_8 }{_9 }{_10 }{_11 }{_12 }{_13 }{_14 }{_15 }{_16 }{_17 }{_18 }{_19 }{_20 }{_21 }{_22 }{_23 }{_24 }{_25 }{_26 }{_27 }{_28 }{_29 }{_30 }{_31 }{_32 }{_33 }{_34 }{_35 }{_36 }{_37 }{_38 }{_39 }{_40 }
53
+
54
+ expected: {_a .indexOf (_0 ) && _0 === ' 0' && _1 === ' 1' }
55
+ {#if _a .indexOf (_0 ) && _0 === ' 0' && _1 === ' 1' }
56
+ if: true
57
+ {:else }
58
+ if: false
59
+ <div out:fade ></div >
60
+ {/if }
61
+
62
+ <button on:click ={update }></button >
You can’t perform that action at this time.
0 commit comments