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