@domql/render 2.5.200 → 3.0.0
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 +23 -7
- package/dist/cjs/append.js +22 -5
- package/dist/esm/append.js +22 -5
- package/package.json +5 -5
package/append.js
CHANGED
|
@@ -5,23 +5,33 @@
|
|
|
5
5
|
* and assigns them into real DOM tree
|
|
6
6
|
*/
|
|
7
7
|
export const appendNode = (node, parentNode) => {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
try {
|
|
9
|
+
parentNode.appendChild(node)
|
|
10
|
+
return node
|
|
11
|
+
} catch (e) {
|
|
12
|
+
console.error('Does not support to append', parentNode, node)
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
export const insertNodeAfter = (node, siblingNode, parentNode) => {
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
if (!node) {
|
|
18
|
+
throw new Error('Node is required')
|
|
19
|
+
}
|
|
20
|
+
const parent = parentNode || siblingNode?.parentNode
|
|
21
|
+
if (siblingNode?.nextSibling) {
|
|
15
22
|
parent && parent.insertBefore(node, siblingNode.nextSibling)
|
|
16
23
|
} else if (siblingNode?.insertAdjacentElement) {
|
|
17
24
|
siblingNode.insertAdjacentElement('afterend', node)
|
|
18
25
|
} else {
|
|
19
|
-
parent.insertBefore(node, siblingNode)
|
|
26
|
+
parent && parent.insertBefore(node, siblingNode)
|
|
20
27
|
}
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
export const insertNodeBefore = (node, siblingNode, parentNode) => {
|
|
24
|
-
|
|
31
|
+
if (!node) {
|
|
32
|
+
throw new Error('Node is required')
|
|
33
|
+
}
|
|
34
|
+
const parent = parentNode || siblingNode.parentNode
|
|
25
35
|
parent && parent.insertBefore(node, siblingNode)
|
|
26
36
|
}
|
|
27
37
|
|
|
@@ -30,10 +40,16 @@ export const insertNodeBefore = (node, siblingNode, parentNode) => {
|
|
|
30
40
|
* parameter as a child of the second one
|
|
31
41
|
*/
|
|
32
42
|
export const assignNode = (element, parent, key, attachOptions) => {
|
|
43
|
+
if (!element) {
|
|
44
|
+
throw new Error('Element is required')
|
|
45
|
+
}
|
|
46
|
+
if (!parent) {
|
|
47
|
+
throw new Error('Parent is required')
|
|
48
|
+
}
|
|
33
49
|
parent[key || element.key] = element
|
|
34
50
|
if (element.tag !== 'shadow') {
|
|
35
51
|
if (attachOptions && attachOptions.position) {
|
|
36
|
-
(attachOptions.position === 'before'
|
|
52
|
+
;(attachOptions.position === 'before'
|
|
37
53
|
? insertNodeBefore
|
|
38
54
|
: insertNodeAfter)(element.node, attachOptions.node || parent.node)
|
|
39
55
|
} else {
|
package/dist/cjs/append.js
CHANGED
|
@@ -25,27 +25,44 @@ __export(append_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(append_exports);
|
|
27
27
|
const appendNode = (node, parentNode) => {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
try {
|
|
29
|
+
parentNode.appendChild(node);
|
|
30
|
+
return node;
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.error("Does not support to append", parentNode, node);
|
|
33
|
+
}
|
|
30
34
|
};
|
|
31
35
|
const insertNodeAfter = (node, siblingNode, parentNode) => {
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
if (!node) {
|
|
37
|
+
throw new Error("Node is required");
|
|
38
|
+
}
|
|
39
|
+
const parent = parentNode || (siblingNode == null ? void 0 : siblingNode.parentNode);
|
|
40
|
+
if (siblingNode == null ? void 0 : siblingNode.nextSibling) {
|
|
34
41
|
parent && parent.insertBefore(node, siblingNode.nextSibling);
|
|
35
42
|
} else if (siblingNode == null ? void 0 : siblingNode.insertAdjacentElement) {
|
|
36
43
|
siblingNode.insertAdjacentElement("afterend", node);
|
|
37
44
|
} else {
|
|
38
|
-
parent.insertBefore(node, siblingNode);
|
|
45
|
+
parent && parent.insertBefore(node, siblingNode);
|
|
39
46
|
}
|
|
40
47
|
};
|
|
41
48
|
const insertNodeBefore = (node, siblingNode, parentNode) => {
|
|
49
|
+
if (!node) {
|
|
50
|
+
throw new Error("Node is required");
|
|
51
|
+
}
|
|
42
52
|
const parent = parentNode || siblingNode.parentNode;
|
|
43
53
|
parent && parent.insertBefore(node, siblingNode);
|
|
44
54
|
};
|
|
45
55
|
const assignNode = (element, parent, key, attachOptions) => {
|
|
56
|
+
if (!element) {
|
|
57
|
+
throw new Error("Element is required");
|
|
58
|
+
}
|
|
59
|
+
if (!parent) {
|
|
60
|
+
throw new Error("Parent is required");
|
|
61
|
+
}
|
|
46
62
|
parent[key || element.key] = element;
|
|
47
63
|
if (element.tag !== "shadow") {
|
|
48
64
|
if (attachOptions && attachOptions.position) {
|
|
65
|
+
;
|
|
49
66
|
(attachOptions.position === "before" ? insertNodeBefore : insertNodeAfter)(element.node, attachOptions.node || parent.node);
|
|
50
67
|
} else {
|
|
51
68
|
appendNode(element.node, parent.node);
|
package/dist/esm/append.js
CHANGED
|
@@ -1,25 +1,42 @@
|
|
|
1
1
|
const appendNode = (node, parentNode) => {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
try {
|
|
3
|
+
parentNode.appendChild(node);
|
|
4
|
+
return node;
|
|
5
|
+
} catch (e) {
|
|
6
|
+
console.error("Does not support to append", parentNode, node);
|
|
7
|
+
}
|
|
4
8
|
};
|
|
5
9
|
const insertNodeAfter = (node, siblingNode, parentNode) => {
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
if (!node) {
|
|
11
|
+
throw new Error("Node is required");
|
|
12
|
+
}
|
|
13
|
+
const parent = parentNode || (siblingNode == null ? void 0 : siblingNode.parentNode);
|
|
14
|
+
if (siblingNode == null ? void 0 : siblingNode.nextSibling) {
|
|
8
15
|
parent && parent.insertBefore(node, siblingNode.nextSibling);
|
|
9
16
|
} else if (siblingNode == null ? void 0 : siblingNode.insertAdjacentElement) {
|
|
10
17
|
siblingNode.insertAdjacentElement("afterend", node);
|
|
11
18
|
} else {
|
|
12
|
-
parent.insertBefore(node, siblingNode);
|
|
19
|
+
parent && parent.insertBefore(node, siblingNode);
|
|
13
20
|
}
|
|
14
21
|
};
|
|
15
22
|
const insertNodeBefore = (node, siblingNode, parentNode) => {
|
|
23
|
+
if (!node) {
|
|
24
|
+
throw new Error("Node is required");
|
|
25
|
+
}
|
|
16
26
|
const parent = parentNode || siblingNode.parentNode;
|
|
17
27
|
parent && parent.insertBefore(node, siblingNode);
|
|
18
28
|
};
|
|
19
29
|
const assignNode = (element, parent, key, attachOptions) => {
|
|
30
|
+
if (!element) {
|
|
31
|
+
throw new Error("Element is required");
|
|
32
|
+
}
|
|
33
|
+
if (!parent) {
|
|
34
|
+
throw new Error("Parent is required");
|
|
35
|
+
}
|
|
20
36
|
parent[key || element.key] = element;
|
|
21
37
|
if (element.tag !== "shadow") {
|
|
22
38
|
if (attachOptions && attachOptions.position) {
|
|
39
|
+
;
|
|
23
40
|
(attachOptions.position === "before" ? insertNodeBefore : insertNodeAfter)(element.node, attachOptions.node || parent.node);
|
|
24
41
|
} else {
|
|
25
42
|
appendNode(element.node, parent.node);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/render",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
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": "^
|
|
22
|
-
"@domql/report": "^
|
|
23
|
-
"@domql/utils": "^
|
|
21
|
+
"@domql/event": "^3.0.0",
|
|
22
|
+
"@domql/report": "^3.0.0",
|
|
23
|
+
"@domql/utils": "^3.0.0"
|
|
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": "rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
30
30
|
"prepublish": "rimraf -I dist && npm run build && npm run copy:package:cjs"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "bcbdc271a602b958de6a60ab387ea7715a935dc1"
|
|
33
33
|
}
|