File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
compiler/phases/3-transform/client/visitors
internal/client/dom/elements Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,10 @@ export function TitleElement(node, context) {
1414 context . state
1515 ) ;
1616
17- const statement = b . stmt ( b . assignment ( '=' , b . id ( '$.document. title' ) , value ) ) ;
17+ context . state . init . push ( b . stmt ( b . call ( '$.title' , value ) ) ) ;
1818
1919 if ( has_state ) {
20+ const statement = b . stmt ( b . assignment ( '=' , b . id ( '$.document.title' ) , value ) ) ;
2021 context . state . update . push ( statement ) ;
21- } else {
22- context . state . init . push ( statement ) ;
2322 }
2423}
Original file line number Diff line number Diff line change 1+ import { teardown } from '../../reactivity/effects.js' ;
12import { hydrating } from '../hydration.js' ;
23import { clear_text_content , get_first_child } from '../operations.js' ;
34import { queue_micro_task } from '../task.js' ;
@@ -56,3 +57,14 @@ export function add_form_reset_listener() {
5657 ) ;
5758 }
5859}
60+
61+ /**
62+ * @param {string } text
63+ */
64+ export function title ( text ) {
65+ const previous = document . title ;
66+ document . title = text ;
67+ teardown ( ( ) => {
68+ document . title = previous ;
69+ } ) ;
70+ }
You can’t perform that action at this time.
0 commit comments