mirror of https://github.com/sveltejs/svelte
fix: propagate custom element component prop changes (#12774)
* fix: propagate custom element component prop changes * add testpull/12795/head
parent
a0bbf2ace0
commit
ba116a1b43
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: propagate custom element component prop changes
|
@ -0,0 +1,37 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../assert';
|
||||
const tick = () => Promise.resolve();
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
target.innerHTML = '<custom-element></custom-element>';
|
||||
await tick();
|
||||
await tick();
|
||||
|
||||
/** @type {any} */
|
||||
const el = target.querySelector('custom-element');
|
||||
const button = el.shadowRoot.querySelector('button');
|
||||
|
||||
assert.equal(button.textContent, '0');
|
||||
assert.equal(el.count, 0);
|
||||
|
||||
button.click();
|
||||
|
||||
flushSync();
|
||||
|
||||
assert.equal(button.textContent, '1');
|
||||
assert.equal(el.count, 1);
|
||||
|
||||
el.count = 0;
|
||||
|
||||
assert.equal(button.textContent, '0');
|
||||
assert.equal(el.count, 0);
|
||||
|
||||
button.click();
|
||||
|
||||
flushSync();
|
||||
|
||||
assert.equal(button.textContent, '1');
|
||||
assert.equal(el.count, 1);
|
||||
}
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
<svelte:options customElement="custom-element" />
|
||||
|
||||
<script>
|
||||
export let count = 0;
|
||||
</script>
|
||||
|
||||
<button onclick={() => count++}>{count}</button>
|
Loading…
Reference in new issue