Skip to content

Commit 80b09b5

Browse files
committed
(fix) don't run binding init unnecessarily
Fixes part of sveltejs#7032 Fixes sveltejs#6298
1 parent 146e7a6 commit 80b09b5

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ export default class InlineComponentWrapper extends Wrapper {
393393

394394
component.partly_hoisted.push(body);
395395

396-
return b`@binding_callbacks.push(() => @bind(${this.var}, '${binding.name}', ${id}));`;
396+
return b`@binding_callbacks.push(() => @bind(${this.var}, '${binding.name}', ${id}, ${snippet}));`;
397397
});
398398

399399
const munged_handlers = this.node.handlers.map(handler => {

src/runtime/internal/Component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { children, detach, start_hydrating, end_hydrating } from './dom';
55
import { transition_in } from './transitions';
66
import { T$$ } from './types';
77

8-
export function bind(component, name, callback) {
8+
export function bind(component, name, callback, value) {
99
const index = component.$$.props[name];
1010
if (index !== undefined) {
1111
component.$$.bound[index] = callback;
12-
callback(component.$$.ctx[index]);
12+
if (value === undefined) {
13+
callback(component.$$.ctx[index]);
14+
}
1315
}
1416
}
1517

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<script>
2+
export let tab;
3+
</script>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default {
2+
async test({ assert, target }) {
3+
assert.htmlEqual(target.innerHTML, `
4+
<p>0</p>
5+
`);
6+
}
7+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script>
2+
import { writable } from "svelte/store";
3+
import Tab from "./Tab.svelte";
4+
5+
let i = 0;
6+
const { set, subscribe } = writable({ id: 1, name: "tab1" });
7+
const tab = {
8+
set(value) {
9+
i++;
10+
set(value);
11+
},
12+
subscribe,
13+
};
14+
</script>
15+
16+
<Tab bind:tab={$tab} />
17+
<p>{i}</p>

0 commit comments

Comments
 (0)