File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed
src/compiler/phases/3-transform/client/visitors
tests/runtime-runes/samples/bind-this-order Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -1890,7 +1890,8 @@ export const template_visitors = {
1890
1890
? b . literal ( null )
1891
1891
: b . thunk ( /** @type {Expression } */ ( visit ( node . expression ) ) ) ;
1892
1892
1893
- state . init . push (
1893
+ // in after_update to ensure it always happens after bind:this
1894
+ state . after_update . push (
1894
1895
b . stmt (
1895
1896
b . call (
1896
1897
'$.animation' ,
@@ -1922,7 +1923,8 @@ export const template_visitors = {
1922
1923
args . push ( b . thunk ( /** @type {Expression } */ ( visit ( node . expression ) ) ) ) ;
1923
1924
}
1924
1925
1925
- state . init . push ( b . stmt ( b . call ( '$.transition' , ...args ) ) ) ;
1926
+ // in after_update to ensure it always happens after bind:this
1927
+ state . after_update . push ( b . stmt ( b . call ( '$.transition' , ...args ) ) ) ;
1926
1928
} ,
1927
1929
RegularElement ( node , context ) {
1928
1930
/** @type {import('#shared').SourceLocation } */
Original file line number Diff line number Diff line change
1
+ import { flushSync } from 'svelte' ;
2
+ import { test } from '../../test' ;
3
+
4
+ export default test ( {
5
+ mode : [ 'client' ] ,
6
+ async test ( { assert, target } ) {
7
+ const btn = target . querySelector ( 'button' ) ;
8
+
9
+ btn ?. click ( ) ;
10
+ flushSync ( ) ;
11
+ assert . htmlEqual ( target . innerHTML , `<button>toggle</button> <nav>hello</nav>` ) ;
12
+ }
13
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ function fly (node , params ) {
3
+ return {};
4
+ }
5
+
6
+ let show = $state (false );
7
+ let sidebar = $state ();
8
+ </script >
9
+
10
+ <button onclick ={() => (show = ! show )}>toggle</button >
11
+
12
+ {#if show }
13
+ <!-- bind:this should be applied before any of the directives -->
14
+ <nav transition:fly ={{ x : sidebar .offsetWidth }} bind:this ={sidebar }>hello</nav >
15
+ {/if }
You can’t perform that action at this time.
0 commit comments