File tree 3 files changed +28
-1
lines changed
test/runtime/samples/reactive-value-function-hoist-b
3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1040,6 +1040,8 @@ export default class Component {
1040
1040
1041
1041
walk ( fn_declaration , {
1042
1042
enter ( node , parent ) {
1043
+ if ( ! hoistable ) return this . skip ( ) ;
1044
+
1043
1045
if ( map . has ( node ) ) {
1044
1046
scope = map . get ( node ) ;
1045
1047
}
@@ -1048,7 +1050,7 @@ export default class Component {
1048
1050
const { name } = flatten_reference ( node ) ;
1049
1051
const owner = scope . find_owner ( name ) ;
1050
1052
1051
- if ( node . type === 'Identifier' && injected_reactive_declaration_vars . has ( name ) ) {
1053
+ if ( injected_reactive_declaration_vars . has ( name ) ) {
1052
1054
hoistable = false ;
1053
1055
} else if ( name [ 0 ] === '$' && ! owner ) {
1054
1056
hoistable = false ;
Original file line number Diff line number Diff line change
1
+ export default {
2
+ html : `
3
+ <button>Click me</button>
4
+ ` ,
5
+
6
+ async test ( { assert, target, window } ) {
7
+ const event = new window . MouseEvent ( 'click' ) ;
8
+ const button = target . querySelector ( 'button' ) ;
9
+
10
+ await button . dispatchEvent ( event ) ;
11
+ assert . htmlEqual ( target . innerHTML , `
12
+ <button>A,B,C</button>
13
+ ` ) ;
14
+ }
15
+ } ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ let array = [' a' , ' b' , ' c' ];
3
+ $: uppercase = array .map (str => str .toUpperCase ());
4
+
5
+ function onClick () {
6
+ this .innerHTML = uppercase .join (' ,' );
7
+ }
8
+ </script >
9
+
10
+ <button on:click ={onClick }>Click me</button >
You can’t perform that action at this time.
0 commit comments