@domql/render
Advanced tools
Comparing version 2.5.22 to 2.5.29
@@ -12,6 +12,10 @@ 'use strict' | ||
export const insertNodeAfter = (node, siblingNode) => { | ||
siblingNode.parentNode.insertBefore(node, siblingNode.nextSibling) | ||
export const insertNodeAfter = (node, siblingNode, parentNode) => { | ||
(parentNode || siblingNode.parentNode)?.insertBefore(node, siblingNode) | ||
} | ||
export const insertNodeBefore = (node, siblingNode, parentNode) => { | ||
(parentNode || siblingNode.parentNode)?.insertBefore(node, siblingNode) | ||
} | ||
/** | ||
@@ -21,8 +25,14 @@ * Receives elements and assigns the first | ||
*/ | ||
export const assignNode = (element, parent, key, insertAfter) => { | ||
export const assignNode = (element, parent, key, attachOptions) => { | ||
parent[key || element.key] = element | ||
if (element.tag !== 'shadow') { | ||
(insertAfter ? insertNodeAfter : appendNode)(element.node, parent.node) | ||
if (attachOptions && attachOptions.position) { | ||
(attachOptions.position === 'before' | ||
? insertNodeBefore | ||
: insertNodeAfter)(element.node, attachOptions.node, attachOptions.parentNode || parent.node) | ||
} else { | ||
appendNode(element.node, parent.node) | ||
} | ||
} | ||
return element | ||
} |
@@ -23,3 +23,4 @@ "use strict"; | ||
assignNode: () => assignNode, | ||
insertNodeAfter: () => insertNodeAfter | ||
insertNodeAfter: () => insertNodeAfter, | ||
insertNodeBefore: () => insertNodeBefore | ||
}); | ||
@@ -31,11 +32,20 @@ module.exports = __toCommonJS(append_exports); | ||
}; | ||
const insertNodeAfter = (node, siblingNode) => { | ||
siblingNode.parentNode.insertBefore(node, siblingNode.nextSibling); | ||
const insertNodeAfter = (node, siblingNode, parentNode) => { | ||
var _a; | ||
(_a = parentNode || siblingNode.parentNode) == null ? void 0 : _a.insertBefore(node, siblingNode); | ||
}; | ||
const assignNode = (element, parent, key, insertAfter) => { | ||
const insertNodeBefore = (node, siblingNode, parentNode) => { | ||
var _a; | ||
(_a = parentNode || siblingNode.parentNode) == null ? void 0 : _a.insertBefore(node, siblingNode); | ||
}; | ||
const assignNode = (element, parent, key, attachOptions) => { | ||
parent[key || element.key] = element; | ||
if (element.tag !== "shadow") { | ||
(insertAfter ? insertNodeAfter : appendNode)(element.node, parent.node); | ||
if (attachOptions && attachOptions.position) { | ||
(attachOptions.position === "before" ? insertNodeBefore : insertNodeAfter)(element.node, attachOptions.node, attachOptions.parentNode || parent.node); | ||
} else { | ||
appendNode(element.node, parent.node); | ||
} | ||
} | ||
return element; | ||
}; |
{ | ||
"name": "@domql/render", | ||
"version": "2.5.22", | ||
"version": "2.5.29", | ||
"license": "MIT", | ||
@@ -31,3 +31,3 @@ "type": "module", | ||
}, | ||
"gitHead": "231fe90e14adace5408e9f5def451463ec1430ae" | ||
"gitHead": "df470e5a96cda567c9d99cc98337eac0136d0890" | ||
} |
11475
256