merge master -> slot-runtime-hasupdatemethod and add a test

pull/2250/head
Richard Harris 6 years ago
commit 5d6333aa8f

@ -141,7 +141,7 @@ export default class SlotWrapper extends Wrapper {
if (this.dependencies.size > 1) update_conditions = `(${update_conditions})`;
block.builders.update.addBlock(deindent`
if (${slot} && ${update_conditions}) {
if (${slot} && ${slot}.p && ${update_conditions}) {
${slot}.p(@get_slot_changes(${slot_definition}, ctx, changed, ${get_slot_changes}), @get_slot_context(${slot_definition}, ctx, ${get_slot_context}));
}
`);
@ -150,4 +150,4 @@ export default class SlotWrapper extends Wrapper {
`if (${slot}) ${slot}.d(detach);`
);
}
}
}

@ -0,0 +1,4 @@
<div>
<slot name="a"></slot>
<slot name="b"></slot>
</div>

@ -0,0 +1,19 @@
export default {
html: `
<div>
<span slot="a">static</span>
<span slot="b">0</span>
</div>
`,
test({ assert, component, target }) {
component.dynamic += 1;
assert.htmlEqual(target.innerHTML, `
<div>
<span slot="a">static</span>
<span slot="b">1</span>
</div>
`);
}
};

@ -0,0 +1,11 @@
<script>
import Nested from "./Nested.svelte";
export let dynamic = 0;
</script>
<Nested>
<span slot="a">static</span>
<span slot="b">{dynamic}</span>
</Nested>
Loading…
Cancel
Save