Skip to content

Commit cde5af2

Browse files
committed
fix: patch up page state not updating
1 parent 6797b94 commit cde5af2

File tree

8 files changed

+43
-18
lines changed

8 files changed

+43
-18
lines changed

client/dist/engine/dom.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ export default class Dom {
44
*
55
* @param html The html to parse
66
* @param removeScripts Whether to remove scripts from the html
7-
* @returns The body of the html
7+
* @returns The body/root of the html
88
*/
9-
static getBody(html: string, removeScripts?: boolean): HTMLElement;
9+
static getBody(html: string, removeScripts?: boolean, nodeToReturn?: 'body' | 'root'): HTMLElement;
1010
/**
1111
* Wrap DOM node with a template element
1212
*/

client/dist/ui.cjs.development.js

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/dist/ui.cjs.development.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/dist/ui.cjs.production.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/dist/ui.cjs.production.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/dist/ui.esm.js

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/dist/ui.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/engine/dom.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ export default class Dom {
77
*
88
* @param html The html to parse
99
* @param removeScripts Whether to remove scripts from the html
10-
* @returns The body of the html
10+
* @returns The body/root of the html
1111
*/
1212
public static getBody(
1313
html: string,
14-
removeScripts: boolean = false
14+
removeScripts: boolean = false,
15+
nodeToReturn: 'body' | 'root' = 'body'
1516
): HTMLElement {
1617
const parser = new DOMParser();
1718
const dom = parser.parseFromString(html, 'text/html');
@@ -24,7 +25,7 @@ export default class Dom {
2425
}
2526
}
2627

27-
return dom.body;
28+
return nodeToReturn === 'body' ? dom.body : dom.documentElement;
2829
}
2930

3031
/**
@@ -77,8 +78,16 @@ export default class Dom {
7778
* @returns The diffed node
7879
*/
7980
public static diff(newNode: string, oldNode: HTMLElement): void {
81+
if (newNode.includes('<html')) {
82+
if (typeof window !== 'undefined') {
83+
oldNode = window.document.documentElement;
84+
}
85+
}
86+
8087
const structuredNewNode =
81-
oldNode.nodeName === 'BODY'
88+
oldNode instanceof HTMLHtmlElement
89+
? Dom.getBody(newNode, false, 'root')
90+
: oldNode.nodeName === 'BODY'
8291
? Dom.getBody(newNode, false)
8392
: Dom.getBody(newNode, true).children[0];
8493
const structuredOldNode = oldNode;

0 commit comments

Comments
 (0)