mirror of https://github.com/sveltejs/svelte
fix: correctly assign bind:this with multiples (#9617)
* fix: correctly assign bind:this with multiples * better fix * better fix * lint * lint * Update packages/svelte/src/internal/client/render.js --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>pull/9621/head
parent
c22ebffb00
commit
509f92d29e
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: correct bind this multiple bindings
|
@ -0,0 +1,25 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, component, target }) {
|
||||
const [b1, b2, b3] = target.querySelectorAll('button');
|
||||
const first_h1 = target.querySelector('h1');
|
||||
|
||||
assert.deepEqual(component.log, [undefined, first_h1]);
|
||||
|
||||
flushSync(() => {
|
||||
b3.click();
|
||||
});
|
||||
|
||||
const third_h1 = target.querySelector('h1');
|
||||
|
||||
assert.deepEqual(component.log, [undefined, first_h1, third_h1]);
|
||||
|
||||
flushSync(() => {
|
||||
b1.click();
|
||||
});
|
||||
|
||||
assert.deepEqual(component.log, [undefined, first_h1, third_h1, target.querySelector('h1')]);
|
||||
}
|
||||
});
|
@ -0,0 +1,27 @@
|
||||
<script>
|
||||
let activeTab = 0;
|
||||
let activeHeading;
|
||||
export let log = [];
|
||||
|
||||
$: log.push(activeHeading);
|
||||
</script>
|
||||
|
||||
<div class="tabs">
|
||||
<div class="tab-toggles">
|
||||
<button class:active={activeTab === 0} on:click={() => activeTab = 0}>Tab 1</button>
|
||||
<button class:active={activeTab === 1} on:click={() => activeTab = 1}>Tab 2</button>
|
||||
<button class:active={activeTab === 2} on:click={() => activeTab = 2}>Tab 3</button>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
{#if activeTab === 0}
|
||||
<div><h1 bind:this={activeHeading}>Tab 1</h1></div>
|
||||
{/if}
|
||||
{#if activeTab === 1}
|
||||
<div><h1 bind:this={activeHeading}>Tab 2</h1></div>
|
||||
{/if}
|
||||
{#if activeTab === 2}
|
||||
<div><h1 bind:this={activeHeading}>Tab 3</h1></div>
|
||||
{/if}
|
||||
</div>
|
||||
<duiv>
|
||||
</div>
|
Loading…
Reference in new issue