Set 'current' is the block have outros without intro (Fix #5120)

pull/5622/head
j3rem1e 5 years ago
parent 148b6105ed
commit 933ace07cd

@ -226,7 +226,9 @@ export default class Block {
const { dev } = this.renderer.options;
if (this.has_outros) {
this.add_variable({ type: 'Identifier', name: '#current' });
this.add_variable({ type: 'Identifier', name: '#current' },
this.chunks.intro.length === 0 ? x`true` : undefined);
if (this.chunks.intro.length > 0) {
this.chunks.intro.push(b`#current = true;`);

@ -0,0 +1,4 @@
<slot name="named"/>
<slot/>
<script></script>

@ -0,0 +1,15 @@
export default {
html: `
<div slot='named'></div>
<a href='___init'>___init</a>
`,
test({ assert, component, target }) {
component.value = 'update';
assert.htmlEqual(target.innerHTML, `
<div slot='named'></div>
<a href='___update'>___update</a>
`);
}
};

@ -0,0 +1,11 @@
<script>
import Component from './Component.svelte';
import Empty from './Empty.svelte';
export let value = "init"
</script>
<Component>
<div slot="named"><Empty/></div>
<a href="___{value}">___{value}</a>
</Component>
Loading…
Cancel
Save