fix: reset title element to previous value on removal

fixes #7656
title-removal-fix
Simon Holthausen 2 months ago
parent 304d88edd0
commit c9f5147189

@ -14,11 +14,10 @@ export function TitleElement(node, context) {
context.state
);
const statement = b.stmt(b.assignment('=', b.id('$.document.title'), value));
context.state.init.push(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);
}
}

@ -1,3 +1,4 @@
import { teardown } from '../../reactivity/effects.js';
import { hydrating } from '../hydration.js';
import { clear_text_content, get_first_child } from '../operations.js';
import { queue_micro_task } from '../task.js';
@ -56,3 +57,14 @@ export function add_form_reset_listener() {
);
}
}
/**
* @param {string} text
*/
export function title(text) {
const previous = document.title;
document.title = text;
teardown(() => {
document.title = previous;
});
}

Loading…
Cancel
Save