[fix] don't run binding init unnecessarily (#7981)

pull/8087/head
Simon H 2 years ago committed by GitHub
parent d2ff2aee4f
commit 4c5469b1ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -393,7 +393,7 @@ export default class InlineComponentWrapper extends Wrapper {
component.partly_hoisted.push(body);
return b`@binding_callbacks.push(() => @bind(${this.var}, '${binding.name}', ${id}));`;
return b`@binding_callbacks.push(() => @bind(${this.var}, '${binding.name}', ${id}, ${snippet}));`;
});
const munged_handlers = this.node.handlers.map(handler => {

@ -5,11 +5,13 @@ import { children, detach, start_hydrating, end_hydrating } from './dom';
import { transition_in } from './transitions';
import { T$$ } from './types';
export function bind(component, name, callback) {
export function bind(component, name, callback, value) {
const index = component.$$.props[name];
if (index !== undefined) {
component.$$.bound[index] = callback;
callback(component.$$.ctx[index]);
if (value === undefined) {
callback(component.$$.ctx[index]);
}
}
}

@ -0,0 +1,7 @@
export default {
async test({ assert, target }) {
assert.htmlEqual(target.innerHTML, `
<p>0</p>
`);
}
};

@ -0,0 +1,17 @@
<script>
import { writable } from "svelte/store";
import Tab from "./Tab.svelte";
let i = 0;
const { set, subscribe } = writable({ id: 1, name: "tab1" });
const tab = {
set(value) {
i++;
set(value);
},
subscribe,
};
</script>
<Tab bind:tab={$tab} />
<p>{i}</p>
Loading…
Cancel
Save