dont detach <svelte:head> contents twice - fixes #2086

pull/3159/head
Rich Harris 6 years ago
parent 9883a50bf9
commit aee2c9cb3f

@ -272,7 +272,7 @@ export default class ElementWrapper extends Wrapper {
);
if (parent_node === '@_document.head') {
block.builders.destroy.add_line(`@detach(${node});`);
block.builders.destroy.add_conditional('detaching', `@detach(${node});`);
}
} else {
block.builders.mount.add_line(`@insert(#target, ${node}, anchor);`);

@ -33,9 +33,11 @@ function create_fragment(ctx) {
o: noop,
d(detaching) {
if (detaching) {
detach(meta0);
detach(meta1);
}
}
};
}

@ -0,0 +1,5 @@
<svelte:head>
<meta name="description" content="A"/>
</svelte:head>
A

@ -0,0 +1,5 @@
<svelte:head>
<meta name="description" content="B"/>
</svelte:head>
B

@ -0,0 +1,15 @@
export default {
html: `
A
`,
test({ assert, component, window }) {
component.x = false;
const meta = window.document.querySelectorAll('meta');
assert.equal(meta.length, 1);
assert.equal(meta[0].name, 'description');
assert.equal(meta[0].content, 'B');
}
};

@ -0,0 +1,8 @@
<script>
import A from './A.svelte';
import B from './B.svelte';
export let x = true;
</script>
<svelte:component this="{x ? A : B}"/>
Loading…
Cancel
Save