@domql/render 2.5.22 → 2.5.30
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/append.js +19 -4
- package/dist/cjs/append.js +19 -5
- package/package.json +2 -2
package/append.js
CHANGED
|
@@ -9,18 +9,33 @@ export const appendNode = (node, parentNode) => {
|
|
|
9
9
|
return node
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const insertNodeAfter = (node, siblingNode) => {
|
|
13
|
-
|
|
12
|
+
export const insertNodeAfter = (node, siblingNode, parentNode) => {
|
|
13
|
+
const parent = (parentNode || siblingNode.parentNode)
|
|
14
|
+
if (siblingNode.nextSibling) {
|
|
15
|
+
parent?.insertBefore(node, siblingNode.nextSibling)
|
|
16
|
+
} else {
|
|
17
|
+
siblingNode?.insertAdjacentElement('afterend', node)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const insertNodeBefore = (node, siblingNode, parentNode) => {
|
|
22
|
+
(parentNode || siblingNode.parentNode)?.insertBefore(node, siblingNode)
|
|
14
23
|
}
|
|
15
24
|
|
|
16
25
|
/**
|
|
17
26
|
* Receives elements and assigns the first
|
|
18
27
|
* parameter as a child of the second one
|
|
19
28
|
*/
|
|
20
|
-
export const assignNode = (element, parent, key,
|
|
29
|
+
export const assignNode = (element, parent, key, attachOptions) => {
|
|
21
30
|
parent[key || element.key] = element
|
|
22
31
|
if (element.tag !== 'shadow') {
|
|
23
|
-
(
|
|
32
|
+
if (attachOptions && attachOptions.position) {
|
|
33
|
+
(attachOptions.position === 'before'
|
|
34
|
+
? insertNodeBefore
|
|
35
|
+
: insertNodeAfter)(element.node, attachOptions.node, attachOptions.parentNode || parent.node)
|
|
36
|
+
} else {
|
|
37
|
+
appendNode(element.node, parent.node)
|
|
38
|
+
}
|
|
24
39
|
}
|
|
25
40
|
return element
|
|
26
41
|
}
|
package/dist/cjs/append.js
CHANGED
|
@@ -20,20 +20,34 @@ var append_exports = {};
|
|
|
20
20
|
__export(append_exports, {
|
|
21
21
|
appendNode: () => appendNode,
|
|
22
22
|
assignNode: () => assignNode,
|
|
23
|
-
insertNodeAfter: () => insertNodeAfter
|
|
23
|
+
insertNodeAfter: () => insertNodeAfter,
|
|
24
|
+
insertNodeBefore: () => insertNodeBefore
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(append_exports);
|
|
26
27
|
const appendNode = (node, parentNode) => {
|
|
27
28
|
parentNode.appendChild(node);
|
|
28
29
|
return node;
|
|
29
30
|
};
|
|
30
|
-
const insertNodeAfter = (node, siblingNode) => {
|
|
31
|
-
|
|
31
|
+
const insertNodeAfter = (node, siblingNode, parentNode) => {
|
|
32
|
+
const parent = parentNode || siblingNode.parentNode;
|
|
33
|
+
if (siblingNode.nextSibling) {
|
|
34
|
+
parent == null ? void 0 : parent.insertBefore(node, siblingNode.nextSibling);
|
|
35
|
+
} else {
|
|
36
|
+
siblingNode == null ? void 0 : siblingNode.insertAdjacentElement("afterend", node);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const insertNodeBefore = (node, siblingNode, parentNode) => {
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = parentNode || siblingNode.parentNode) == null ? void 0 : _a.insertBefore(node, siblingNode);
|
|
32
42
|
};
|
|
33
|
-
const assignNode = (element, parent, key,
|
|
43
|
+
const assignNode = (element, parent, key, attachOptions) => {
|
|
34
44
|
parent[key || element.key] = element;
|
|
35
45
|
if (element.tag !== "shadow") {
|
|
36
|
-
(
|
|
46
|
+
if (attachOptions && attachOptions.position) {
|
|
47
|
+
(attachOptions.position === "before" ? insertNodeBefore : insertNodeAfter)(element.node, attachOptions.node, attachOptions.parentNode || parent.node);
|
|
48
|
+
} else {
|
|
49
|
+
appendNode(element.node, parent.node);
|
|
50
|
+
}
|
|
37
51
|
}
|
|
38
52
|
return element;
|
|
39
53
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/render",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.30",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"build": "yarn build:cjs",
|
|
29
29
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "c1547b94101ec41cb0ef08dbee37b81a2a541126"
|
|
32
32
|
}
|