mirror of https://github.com/sveltejs/svelte
fix: improve bind:this support around proxyied state (#10732)
* fix: improve bind:this support around proxyied state * fix: improve bind:this support around proxyied state * fix: improve bind:this support around proxyied statepull/10716/head
parent
304db0d5b2
commit
7c00f1dacb
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: improve bind:this support around proxyied state
|
@ -0,0 +1,4 @@
|
||||
<script>
|
||||
export const a = {};
|
||||
</script>
|
||||
<div>Hello world</div>
|
@ -0,0 +1,29 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
import { log } from './log.js';
|
||||
|
||||
export default test({
|
||||
before_test: () => {
|
||||
log.length = 0;
|
||||
},
|
||||
|
||||
html: `<button>Toggle</button><div>Hello\nworld</div>`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
const [btn1] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => {
|
||||
btn1?.click();
|
||||
});
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `<button>Toggle</button>`);
|
||||
|
||||
flushSync(() => {
|
||||
btn1?.click();
|
||||
});
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `<button>Toggle</button><div>Hello\nworld</div>`);
|
||||
|
||||
assert.deepEqual(log, [{ a: {} }, null, { a: {} }]);
|
||||
}
|
||||
});
|
@ -0,0 +1,2 @@
|
||||
/** @type {any[]} */
|
||||
export const log = [];
|
@ -0,0 +1,23 @@
|
||||
<script>
|
||||
import { log } from './log.js';
|
||||
import Component from './Component.svelte';
|
||||
|
||||
let type = $state(Component)
|
||||
let elem = $state()
|
||||
|
||||
$effect(() => {
|
||||
log.push(elem);
|
||||
});
|
||||
</script>
|
||||
|
||||
<button onclick={() => {
|
||||
if (!type) {
|
||||
type = Component
|
||||
} else {
|
||||
type = false
|
||||
}
|
||||
}}>Toggle</button>
|
||||
|
||||
<svelte:component bind:this={elem} this={type}>
|
||||
Content
|
||||
</svelte:component>
|
Loading…
Reference in new issue