@pfern/elements 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/elements.js +8 -1
- package/package.json +1 -1
package/elements.js
CHANGED
|
@@ -218,6 +218,11 @@ const renderTree = (node, isRoot = true) => {
|
|
|
218
218
|
? document.createElementNS(svgNS, tag)
|
|
219
219
|
: document.createElement(tag)
|
|
220
220
|
|
|
221
|
+
if (!el && (tag === 'head' || tag === 'body')) {
|
|
222
|
+
el = document.createElement(tag)
|
|
223
|
+
document.documentElement.appendChild(el)
|
|
224
|
+
}
|
|
225
|
+
|
|
221
226
|
el.__vnode = node
|
|
222
227
|
|
|
223
228
|
if (isRoot && tag !== 'html' && tag !== 'head' && tag !== 'body') {
|
|
@@ -289,7 +294,9 @@ export const render = (vtree, container = null) => {
|
|
|
289
294
|
if (!prevVNode) {
|
|
290
295
|
const dom = renderTree(vtree)
|
|
291
296
|
if (target === document.documentElement) {
|
|
292
|
-
|
|
297
|
+
if (dom !== document.documentElement) {
|
|
298
|
+
document.replaceChild(dom, document.documentElement)
|
|
299
|
+
}
|
|
293
300
|
} else {
|
|
294
301
|
target.appendChild(dom)
|
|
295
302
|
}
|