Skip to content

Commit 166f1a6

Browse files
committed
[fix] Custom Element initialization in HTML string rendering
(https://blog.dwac.dev/posts/streamable-html-fragments/#upgrade-timing)
1 parent 52eab1b commit 166f1a6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dom-renderer",
3-
"version": "2.6.3",
3+
"version": "2.6.4",
44
"license": "LGPL-3.0-or-later",
55
"author": "shiy2008@gmail.com",
66
"description": "A light-weight DOM Renderer supports Web components standard & TypeScript language",

source/dist/VDOM.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,13 @@ export class VNode extends VNodeMeta {
100100
const { tagName, props, style, children, node } = this;
101101

102102
if (tagName.includes('-') && elementTypeOf(tagName) === 'html') {
103-
const { body } = (node?.ownerDocument || document).implementation.createHTMLDocument();
103+
const currentDocument = node?.ownerDocument || globalThis.document;
104+
const { body } = currentDocument.implementation.createHTMLDocument();
104105

105106
new DOMRenderer().render(this, body);
106107

108+
currentDocument.importNode(body, true);
109+
107110
const shadowRoots = [...findShadowRoots(body)];
108111

109112
yield body.getHTML({ serializableShadowRoots: true, shadowRoots });

0 commit comments

Comments
 (0)