@domql/render
Advanced tools
Comparing version
@@ -8,9 +8,16 @@ 'use strict' | ||
export const appendNode = (node, parentNode) => { | ||
parentNode.appendChild(node) | ||
return node | ||
try { | ||
parentNode.appendChild(node) | ||
return node | ||
} catch (e) { | ||
console.error('Does not support to append', parentNode, node) | ||
} | ||
} | ||
export const insertNodeAfter = (node, siblingNode, parentNode) => { | ||
const parent = (parentNode || siblingNode.parentNode) | ||
if (siblingNode.nextSibling) { | ||
if (!node) { | ||
throw new Error('Node is required') | ||
} | ||
const parent = parentNode || siblingNode?.parentNode | ||
if (siblingNode?.nextSibling) { | ||
parent && parent.insertBefore(node, siblingNode.nextSibling) | ||
@@ -20,3 +27,3 @@ } else if (siblingNode?.insertAdjacentElement) { | ||
} else { | ||
parent.insertBefore(node, siblingNode) | ||
parent && parent.insertBefore(node, siblingNode) | ||
} | ||
@@ -26,3 +33,6 @@ } | ||
export const insertNodeBefore = (node, siblingNode, parentNode) => { | ||
const parent = (parentNode || siblingNode.parentNode) | ||
if (!node) { | ||
throw new Error('Node is required') | ||
} | ||
const parent = parentNode || siblingNode.parentNode | ||
parent && parent.insertBefore(node, siblingNode) | ||
@@ -36,6 +46,12 @@ } | ||
export const assignNode = (element, parent, key, attachOptions) => { | ||
if (!element) { | ||
throw new Error('Element is required') | ||
} | ||
if (!parent) { | ||
throw new Error('Parent is required') | ||
} | ||
parent[key || element.key] = element | ||
if (element.tag !== 'shadow') { | ||
if (attachOptions && attachOptions.position) { | ||
(attachOptions.position === 'before' | ||
;(attachOptions.position === 'before' | ||
? insertNodeBefore | ||
@@ -42,0 +58,0 @@ : insertNodeAfter)(element.node, attachOptions.node || parent.node) |
@@ -28,8 +28,15 @@ "use strict"; | ||
const appendNode = (node, parentNode) => { | ||
parentNode.appendChild(node); | ||
return node; | ||
try { | ||
parentNode.appendChild(node); | ||
return node; | ||
} catch (e) { | ||
console.error("Does not support to append", parentNode, node); | ||
} | ||
}; | ||
const insertNodeAfter = (node, siblingNode, parentNode) => { | ||
const parent = parentNode || siblingNode.parentNode; | ||
if (siblingNode.nextSibling) { | ||
if (!node) { | ||
throw new Error("Node is required"); | ||
} | ||
const parent = parentNode || (siblingNode == null ? void 0 : siblingNode.parentNode); | ||
if (siblingNode == null ? void 0 : siblingNode.nextSibling) { | ||
parent && parent.insertBefore(node, siblingNode.nextSibling); | ||
@@ -39,6 +46,9 @@ } else if (siblingNode == null ? void 0 : siblingNode.insertAdjacentElement) { | ||
} else { | ||
parent.insertBefore(node, siblingNode); | ||
parent && parent.insertBefore(node, siblingNode); | ||
} | ||
}; | ||
const insertNodeBefore = (node, siblingNode, parentNode) => { | ||
if (!node) { | ||
throw new Error("Node is required"); | ||
} | ||
const parent = parentNode || siblingNode.parentNode; | ||
@@ -48,5 +58,12 @@ parent && parent.insertBefore(node, siblingNode); | ||
const assignNode = (element, parent, key, attachOptions) => { | ||
if (!element) { | ||
throw new Error("Element is required"); | ||
} | ||
if (!parent) { | ||
throw new Error("Parent is required"); | ||
} | ||
parent[key || element.key] = element; | ||
if (element.tag !== "shadow") { | ||
if (attachOptions && attachOptions.position) { | ||
; | ||
(attachOptions.position === "before" ? insertNodeBefore : insertNodeAfter)(element.node, attachOptions.node || parent.node); | ||
@@ -53,0 +70,0 @@ } else { |
const appendNode = (node, parentNode) => { | ||
parentNode.appendChild(node); | ||
return node; | ||
try { | ||
parentNode.appendChild(node); | ||
return node; | ||
} catch (e) { | ||
console.error("Does not support to append", parentNode, node); | ||
} | ||
}; | ||
const insertNodeAfter = (node, siblingNode, parentNode) => { | ||
const parent = parentNode || siblingNode.parentNode; | ||
if (siblingNode.nextSibling) { | ||
if (!node) { | ||
throw new Error("Node is required"); | ||
} | ||
const parent = parentNode || (siblingNode == null ? void 0 : siblingNode.parentNode); | ||
if (siblingNode == null ? void 0 : siblingNode.nextSibling) { | ||
parent && parent.insertBefore(node, siblingNode.nextSibling); | ||
@@ -12,6 +19,9 @@ } else if (siblingNode == null ? void 0 : siblingNode.insertAdjacentElement) { | ||
} else { | ||
parent.insertBefore(node, siblingNode); | ||
parent && parent.insertBefore(node, siblingNode); | ||
} | ||
}; | ||
const insertNodeBefore = (node, siblingNode, parentNode) => { | ||
if (!node) { | ||
throw new Error("Node is required"); | ||
} | ||
const parent = parentNode || siblingNode.parentNode; | ||
@@ -21,5 +31,12 @@ parent && parent.insertBefore(node, siblingNode); | ||
const assignNode = (element, parent, key, attachOptions) => { | ||
if (!element) { | ||
throw new Error("Element is required"); | ||
} | ||
if (!parent) { | ||
throw new Error("Parent is required"); | ||
} | ||
parent[key || element.key] = element; | ||
if (element.tag !== "shadow") { | ||
if (attachOptions && attachOptions.position) { | ||
; | ||
(attachOptions.position === "before" ? insertNodeBefore : insertNodeAfter)(element.node, attachOptions.node || parent.node); | ||
@@ -26,0 +43,0 @@ } else { |
{ | ||
"name": "@domql/render", | ||
"version": "2.5.200", | ||
"version": "3.0.0", | ||
"license": "MIT", | ||
@@ -21,5 +21,5 @@ "type": "module", | ||
"dependencies": { | ||
"@domql/event": "^2.5.200", | ||
"@domql/report": "^2.5.186", | ||
"@domql/utils": "^2.5.200" | ||
"@domql/event": "^3.0.0", | ||
"@domql/report": "^3.0.0", | ||
"@domql/utils": "^3.0.0" | ||
}, | ||
@@ -33,3 +33,3 @@ "scripts": { | ||
}, | ||
"gitHead": "0afb63ec375f0526f47ff300885de393138b01e8" | ||
"gitHead": "bcbdc271a602b958de6a60ab387ea7715a935dc1" | ||
} |
16903
7.69%417
13.62%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated
Updated
Updated