@domql/render 2.5.203 → 2.25.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/dist/cjs/cache.js +11 -22
- package/dist/cjs/index.js +5 -5
- package/dist/esm/cache.js +11 -22
- package/package.json +5 -5
package/dist/cjs/cache.js
CHANGED
|
@@ -30,14 +30,12 @@ const createHTMLNode = (element) => {
|
|
|
30
30
|
const { tag, context } = element;
|
|
31
31
|
const doc = context.document || import_utils.document;
|
|
32
32
|
if (tag) {
|
|
33
|
-
if (tag === "string")
|
|
34
|
-
return doc.createTextNode(element.text);
|
|
33
|
+
if (tag === "string") return doc.createTextNode(element.text);
|
|
35
34
|
else if (tag === "fragment") {
|
|
36
35
|
return doc.createDocumentFragment();
|
|
37
36
|
} else if (tag === "svg" || tag === "path") {
|
|
38
37
|
return doc.createElementNS("http://www.w3.org/2000/svg", tag);
|
|
39
|
-
} else
|
|
40
|
-
return doc.createElement(tag);
|
|
38
|
+
} else return doc.createElement(tag);
|
|
41
39
|
} else {
|
|
42
40
|
return doc.createElement("div");
|
|
43
41
|
}
|
|
@@ -45,24 +43,18 @@ const createHTMLNode = (element) => {
|
|
|
45
43
|
const detectTag = (element) => {
|
|
46
44
|
let { tag, key, props } = element;
|
|
47
45
|
tag = (0, import_utils.exec)(tag, element);
|
|
48
|
-
if (tag === true)
|
|
49
|
-
tag = key;
|
|
46
|
+
if (tag === true) tag = key;
|
|
50
47
|
if ((0, import_utils.isObject)(props) && (0, import_utils.isString)(props.tag)) {
|
|
51
48
|
const tagExists = (0, import_utils.isValidHtmlTag)(props.tag);
|
|
52
|
-
if (tagExists)
|
|
53
|
-
return props.tag;
|
|
49
|
+
if (tagExists) return props.tag;
|
|
54
50
|
}
|
|
55
51
|
if ((0, import_utils.isString)(tag)) {
|
|
56
|
-
if ((0, import_utils.isValidHtmlTag)(tag))
|
|
57
|
-
return tag;
|
|
52
|
+
if ((0, import_utils.isValidHtmlTag)(tag)) return tag;
|
|
58
53
|
} else {
|
|
59
54
|
let keyAsTag = key.toLowerCase();
|
|
60
|
-
if (keyAsTag.includes("."))
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
keyAsTag = keyAsTag.split("_")[0];
|
|
64
|
-
if ((0, import_utils.isValidHtmlTag)(keyAsTag))
|
|
65
|
-
return keyAsTag;
|
|
55
|
+
if (keyAsTag.includes(".")) keyAsTag = keyAsTag.split(".")[0];
|
|
56
|
+
if (keyAsTag.includes("_")) keyAsTag = keyAsTag.split("_")[0];
|
|
57
|
+
if ((0, import_utils.isValidHtmlTag)(keyAsTag)) return keyAsTag;
|
|
66
58
|
}
|
|
67
59
|
return "div";
|
|
68
60
|
};
|
|
@@ -73,13 +65,10 @@ const cacheNode = (element) => {
|
|
|
73
65
|
if (!(0, import_event.canRenderTag)(tag)) {
|
|
74
66
|
return (0, import_report.report)("HTMLInvalidTag", element.tag, element);
|
|
75
67
|
}
|
|
76
|
-
if (!win.nodeCaches)
|
|
77
|
-
win.nodeCaches = {};
|
|
68
|
+
if (!win.nodeCaches) win.nodeCaches = {};
|
|
78
69
|
let cachedTag = win.nodeCaches[tag];
|
|
79
|
-
if (!cachedTag)
|
|
80
|
-
cachedTag = win.nodeCaches[tag] = createHTMLNode(element);
|
|
70
|
+
if (!cachedTag) cachedTag = win.nodeCaches[tag] = createHTMLNode(element);
|
|
81
71
|
const clonedNode = cachedTag.cloneNode(true);
|
|
82
|
-
if (tag === "string")
|
|
83
|
-
clonedNode.nodeValue = element.text;
|
|
72
|
+
if (tag === "string") clonedNode.nodeValue = element.text;
|
|
84
73
|
return clonedNode;
|
|
85
74
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -13,8 +13,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
};
|
|
14
14
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var
|
|
17
|
-
module.exports = __toCommonJS(
|
|
18
|
-
__reExport(
|
|
19
|
-
__reExport(
|
|
20
|
-
__reExport(
|
|
16
|
+
var index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require("./create.js"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./cache.js"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./append.js"), module.exports);
|
package/dist/esm/cache.js
CHANGED
|
@@ -5,14 +5,12 @@ const createHTMLNode = (element) => {
|
|
|
5
5
|
const { tag, context } = element;
|
|
6
6
|
const doc = context.document || document;
|
|
7
7
|
if (tag) {
|
|
8
|
-
if (tag === "string")
|
|
9
|
-
return doc.createTextNode(element.text);
|
|
8
|
+
if (tag === "string") return doc.createTextNode(element.text);
|
|
10
9
|
else if (tag === "fragment") {
|
|
11
10
|
return doc.createDocumentFragment();
|
|
12
11
|
} else if (tag === "svg" || tag === "path") {
|
|
13
12
|
return doc.createElementNS("http://www.w3.org/2000/svg", tag);
|
|
14
|
-
} else
|
|
15
|
-
return doc.createElement(tag);
|
|
13
|
+
} else return doc.createElement(tag);
|
|
16
14
|
} else {
|
|
17
15
|
return doc.createElement("div");
|
|
18
16
|
}
|
|
@@ -20,24 +18,18 @@ const createHTMLNode = (element) => {
|
|
|
20
18
|
const detectTag = (element) => {
|
|
21
19
|
let { tag, key, props } = element;
|
|
22
20
|
tag = exec(tag, element);
|
|
23
|
-
if (tag === true)
|
|
24
|
-
tag = key;
|
|
21
|
+
if (tag === true) tag = key;
|
|
25
22
|
if (isObject(props) && isString(props.tag)) {
|
|
26
23
|
const tagExists = isValidHtmlTag(props.tag);
|
|
27
|
-
if (tagExists)
|
|
28
|
-
return props.tag;
|
|
24
|
+
if (tagExists) return props.tag;
|
|
29
25
|
}
|
|
30
26
|
if (isString(tag)) {
|
|
31
|
-
if (isValidHtmlTag(tag))
|
|
32
|
-
return tag;
|
|
27
|
+
if (isValidHtmlTag(tag)) return tag;
|
|
33
28
|
} else {
|
|
34
29
|
let keyAsTag = key.toLowerCase();
|
|
35
|
-
if (keyAsTag.includes("."))
|
|
36
|
-
|
|
37
|
-
if (keyAsTag
|
|
38
|
-
keyAsTag = keyAsTag.split("_")[0];
|
|
39
|
-
if (isValidHtmlTag(keyAsTag))
|
|
40
|
-
return keyAsTag;
|
|
30
|
+
if (keyAsTag.includes(".")) keyAsTag = keyAsTag.split(".")[0];
|
|
31
|
+
if (keyAsTag.includes("_")) keyAsTag = keyAsTag.split("_")[0];
|
|
32
|
+
if (isValidHtmlTag(keyAsTag)) return keyAsTag;
|
|
41
33
|
}
|
|
42
34
|
return "div";
|
|
43
35
|
};
|
|
@@ -48,14 +40,11 @@ const cacheNode = (element) => {
|
|
|
48
40
|
if (!canRenderTag(tag)) {
|
|
49
41
|
return report("HTMLInvalidTag", element.tag, element);
|
|
50
42
|
}
|
|
51
|
-
if (!win.nodeCaches)
|
|
52
|
-
win.nodeCaches = {};
|
|
43
|
+
if (!win.nodeCaches) win.nodeCaches = {};
|
|
53
44
|
let cachedTag = win.nodeCaches[tag];
|
|
54
|
-
if (!cachedTag)
|
|
55
|
-
cachedTag = win.nodeCaches[tag] = createHTMLNode(element);
|
|
45
|
+
if (!cachedTag) cachedTag = win.nodeCaches[tag] = createHTMLNode(element);
|
|
56
46
|
const clonedNode = cachedTag.cloneNode(true);
|
|
57
|
-
if (tag === "string")
|
|
58
|
-
clonedNode.nodeValue = element.text;
|
|
47
|
+
if (tag === "string") clonedNode.nodeValue = element.text;
|
|
59
48
|
return clonedNode;
|
|
60
49
|
};
|
|
61
50
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/render",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.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.25.2",
|
|
22
|
+
"@domql/report": "^2.25.2",
|
|
23
|
+
"@domql/utils": "^2.25.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": "b226cec424e82cebf1af9844254c6a1e7058b270"
|
|
33
33
|
}
|