File tree 5 files changed +37
-1
lines changed
tests/runtime-browser/custom-elements-samples
5 files changed +37
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: ensure custom elements do not sync flush on mount
Original file line number Diff line number Diff line change @@ -110,7 +110,10 @@ class Svelte4Component {
110
110
recover : options . recover
111
111
} ) ;
112
112
113
- flush_sync ( ) ;
113
+ // We don't flush_sync for custom element wrappers
114
+ if ( ! options ?. props ?. $$host ) {
115
+ flush_sync ( ) ;
116
+ }
114
117
115
118
this . #events = props . $$events ;
116
119
Original file line number Diff line number Diff line change
1
+ import { test } from '../../assert' ;
2
+ const tick = ( ) => Promise . resolve ( ) ;
3
+
4
+ export default test ( {
5
+ async test ( { assert, target } ) {
6
+ let changed = false ;
7
+
8
+ target . innerHTML = '<child-element></child-element>' ;
9
+
10
+ await tick ( ) ; // wait for element to upgrade
11
+
12
+ target . addEventListener ( 'change' , ( ) => {
13
+ changed = true ;
14
+ } ) ;
15
+
16
+ await tick ( ) ; // wait for effect
17
+
18
+ assert . equal ( changed , true ) ;
19
+ }
20
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <svelte:options customElement =" child-element" />
2
+
3
+ <script >
4
+ $effect (() => {
5
+ $host ().dispatchEvent (new CustomEvent (' change' , { bubbles: true }));
6
+ });
7
+ </script >
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ export default test({
5
5
async test ( { assert, target } ) {
6
6
target . innerHTML = '<custom-element></custom-element>' ;
7
7
await tick ( ) ;
8
+ await tick ( ) ;
8
9
/** @type {any } */
9
10
const ce = target . querySelector ( 'custom-element' ) ;
10
11
const icon = ce . shadowRoot . querySelector ( '.icon' ) ;
You can’t perform that action at this time.
0 commit comments