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
); );
context.state.init.push(b.stmt(b.call('$.title', value))); const statement = b.stmt(b.call('$.title', value));
if (has_state) { if (has_state) {
const statement = b.stmt(b.assignment('=', b.id('$.document.title'), value));
context.state.update.push(statement); context.state.update.push(statement);
} else {
context.state.init.push(statement);
} }
} }

@ -5,7 +5,7 @@ export default test({
async test({ assert, target, window }) { async test({ assert, target, window }) {
const [btn1] = target.querySelectorAll('button'); const [btn1] = target.querySelectorAll('button');
assert.htmlEqual(window.document.head.innerHTML, ``); assert.htmlEqual(window.document.head.innerHTML, `<title>initial</title>`);
flushSync(() => { flushSync(() => {
btn1.click(); btn1.click();
@ -17,6 +17,6 @@ export default test({
btn1.click(); 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> </script>
<svelte:head>
<title>initial</title>
</svelte:head>
<button onclick={toggle}> <button onclick={toggle}>
toggle toggle
</button> </button>

Loading…
Cancel
Save