@domql/render 2.27.18 → 2.28.2
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 +21 -4
- package/dist/cjs/append.js +17 -1
- package/dist/esm/append.js +17 -1
- package/package.json +5 -5
package/append.js
CHANGED
|
@@ -5,12 +5,29 @@
|
|
|
5
5
|
* and assigns them into real DOM tree
|
|
6
6
|
*/
|
|
7
7
|
export const appendNode = (node, parentNode) => {
|
|
8
|
-
|
|
8
|
+
try {
|
|
9
|
+
if (parentNode && typeof parentNode.appendChild === 'function') {
|
|
10
|
+
parentNode.appendChild(node)
|
|
11
|
+
} else {
|
|
12
|
+
throw new Error(
|
|
13
|
+
'Invalid parentNode: appendChild is not supported on this node type.'
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
} catch (e) {
|
|
17
|
+
// Fallback for older browsers
|
|
18
|
+
if (node && node.parentNode) {
|
|
19
|
+
node.parentNode.removeChild(node)
|
|
20
|
+
}
|
|
21
|
+
if (node && parentNode) {
|
|
22
|
+
parentNode.appendChild(node)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
9
25
|
return node
|
|
10
26
|
}
|
|
11
27
|
|
|
28
|
+
//q23
|
|
12
29
|
export const insertNodeAfter = (node, siblingNode, parentNode) => {
|
|
13
|
-
const parent =
|
|
30
|
+
const parent = parentNode || siblingNode.parentNode
|
|
14
31
|
if (siblingNode.nextSibling) {
|
|
15
32
|
parent && parent.insertBefore(node, siblingNode.nextSibling)
|
|
16
33
|
} else if (siblingNode?.insertAdjacentElement) {
|
|
@@ -21,7 +38,7 @@ export const insertNodeAfter = (node, siblingNode, parentNode) => {
|
|
|
21
38
|
}
|
|
22
39
|
|
|
23
40
|
export const insertNodeBefore = (node, siblingNode, parentNode) => {
|
|
24
|
-
const parent =
|
|
41
|
+
const parent = parentNode || siblingNode.parentNode
|
|
25
42
|
parent && parent.insertBefore(node, siblingNode)
|
|
26
43
|
}
|
|
27
44
|
|
|
@@ -33,7 +50,7 @@ export const assignNode = (element, parent, key, attachOptions) => {
|
|
|
33
50
|
parent[key || element.key] = element
|
|
34
51
|
if (element.tag !== 'shadow') {
|
|
35
52
|
if (attachOptions && attachOptions.position) {
|
|
36
|
-
(attachOptions.position === 'before'
|
|
53
|
+
;(attachOptions.position === 'before'
|
|
37
54
|
? insertNodeBefore
|
|
38
55
|
: insertNodeAfter)(element.node, attachOptions.node || parent.node)
|
|
39
56
|
} else {
|
package/dist/cjs/append.js
CHANGED
|
@@ -25,7 +25,22 @@ __export(append_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(append_exports);
|
|
27
27
|
const appendNode = (node, parentNode) => {
|
|
28
|
-
|
|
28
|
+
try {
|
|
29
|
+
if (parentNode && typeof parentNode.appendChild === "function") {
|
|
30
|
+
parentNode.appendChild(node);
|
|
31
|
+
} else {
|
|
32
|
+
throw new Error(
|
|
33
|
+
"Invalid parentNode: appendChild is not supported on this node type."
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
} catch (e) {
|
|
37
|
+
if (node && node.parentNode) {
|
|
38
|
+
node.parentNode.removeChild(node);
|
|
39
|
+
}
|
|
40
|
+
if (node && parentNode) {
|
|
41
|
+
parentNode.appendChild(node);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
29
44
|
return node;
|
|
30
45
|
};
|
|
31
46
|
const insertNodeAfter = (node, siblingNode, parentNode) => {
|
|
@@ -46,6 +61,7 @@ const assignNode = (element, parent, key, attachOptions) => {
|
|
|
46
61
|
parent[key || element.key] = element;
|
|
47
62
|
if (element.tag !== "shadow") {
|
|
48
63
|
if (attachOptions && attachOptions.position) {
|
|
64
|
+
;
|
|
49
65
|
(attachOptions.position === "before" ? insertNodeBefore : insertNodeAfter)(element.node, attachOptions.node || parent.node);
|
|
50
66
|
} else {
|
|
51
67
|
appendNode(element.node, parent.node);
|
package/dist/esm/append.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
const appendNode = (node, parentNode) => {
|
|
2
|
-
|
|
2
|
+
try {
|
|
3
|
+
if (parentNode && typeof parentNode.appendChild === "function") {
|
|
4
|
+
parentNode.appendChild(node);
|
|
5
|
+
} else {
|
|
6
|
+
throw new Error(
|
|
7
|
+
"Invalid parentNode: appendChild is not supported on this node type."
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
} catch (e) {
|
|
11
|
+
if (node && node.parentNode) {
|
|
12
|
+
node.parentNode.removeChild(node);
|
|
13
|
+
}
|
|
14
|
+
if (node && parentNode) {
|
|
15
|
+
parentNode.appendChild(node);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
3
18
|
return node;
|
|
4
19
|
};
|
|
5
20
|
const insertNodeAfter = (node, siblingNode, parentNode) => {
|
|
@@ -20,6 +35,7 @@ const assignNode = (element, parent, key, attachOptions) => {
|
|
|
20
35
|
parent[key || element.key] = element;
|
|
21
36
|
if (element.tag !== "shadow") {
|
|
22
37
|
if (attachOptions && attachOptions.position) {
|
|
38
|
+
;
|
|
23
39
|
(attachOptions.position === "before" ? insertNodeBefore : insertNodeAfter)(element.node, attachOptions.node || parent.node);
|
|
24
40
|
} else {
|
|
25
41
|
appendNode(element.node, parent.node);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/render",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@domql/event": "^2.
|
|
22
|
-
"@domql/report": "^2.
|
|
23
|
-
"@domql/utils": "^2.
|
|
21
|
+
"@domql/event": "^2.28.2",
|
|
22
|
+
"@domql/report": "^2.28.2",
|
|
23
|
+
"@domql/utils": "^2.28.2"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
30
30
|
"prepublish": "npx rimraf -I dist && npm run build && npm run copy:package:cjs"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "3c5e8b68269799a0e2382f9c79c51e41f33863bf"
|
|
33
33
|
}
|