title-removal-fix
Rich Harris 9 months ago
parent 963d3930fb
commit 2072638d18

@ -14,10 +14,11 @@ export function TitleElement(node, context) {
context.state
);
context.state.init.push(b.stmt(b.call('$.title', value)));
const statement = b.stmt(b.call('$.title', value));
if (has_state) {
const statement = b.stmt(b.assignment('=', b.id('$.document.title'), value));
context.state.update.push(statement);
} else {
context.state.init.push(statement);
}
}

@ -5,7 +5,7 @@ export default test({
async test({ assert, target, window }) {
const [btn1] = target.querySelectorAll('button');
assert.htmlEqual(window.document.head.innerHTML, ``);
assert.htmlEqual(window.document.head.innerHTML, `<title>initial</title>`);
flushSync(() => {
btn1.click();
@ -17,6 +17,6 @@ export default test({
btn1.click();
});
assert.htmlEqual(window.document.head.innerHTML, `<title>hello world</title>`);
assert.htmlEqual(window.document.head.innerHTML, `<title>initial</title>`);
}
});

@ -8,6 +8,10 @@
}
</script>
<svelte:head>
<title>initial</title>
</svelte:head>
<button onclick={toggle}>
toggle
</button>

Loading…
Cancel
Save