mirror of https://github.com/sveltejs/svelte
fix: ensure custom elements do not sync flush on mount (#12787)
* fix: ensure Svelte4Components do not sync flush * fix: ensure Svelte4Components do not sync flush * lint * feedback * simplify test, remove redundant comments * prettier * fix test --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/12789/head
parent
057316ccd1
commit
d8954d7add
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: ensure custom elements do not sync flush on mount
|
@ -0,0 +1,20 @@
|
|||||||
|
import { test } from '../../assert';
|
||||||
|
const tick = () => Promise.resolve();
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
async test({ assert, target }) {
|
||||||
|
let changed = false;
|
||||||
|
|
||||||
|
target.innerHTML = '<child-element></child-element>';
|
||||||
|
|
||||||
|
await tick(); // wait for element to upgrade
|
||||||
|
|
||||||
|
target.addEventListener('change', () => {
|
||||||
|
changed = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
await tick(); // wait for effect
|
||||||
|
|
||||||
|
assert.equal(changed, true);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,7 @@
|
|||||||
|
<svelte:options customElement="child-element" />
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$effect(() => {
|
||||||
|
$host().dispatchEvent(new CustomEvent('change', { bubbles: true }));
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Reference in new issue