@domql/render
Advanced tools
Comparing version
@@ -33,3 +33,4 @@ "use strict"; | ||
if (tag) { | ||
if (tag === "string") return doc.createTextNode(element.text); | ||
if (tag === "string") | ||
return doc.createTextNode(element.text); | ||
else if (tag === "fragment") { | ||
@@ -39,3 +40,4 @@ return doc.createDocumentFragment(); | ||
return doc.createElementNS("http://www.w3.org/2000/svg", tag); | ||
} else return doc.createElement(tag); | ||
} else | ||
return doc.createElement(tag); | ||
} else { | ||
@@ -48,14 +50,20 @@ return doc.createElement("div"); | ||
tag = (0, import_utils.exec)(tag, element); | ||
if (tag === true) tag = key; | ||
if (tag === true) | ||
tag = key; | ||
if ((0, import_utils.isObject)(props) && (0, import_utils.isString)(props.tag)) { | ||
const tagExists = (0, import_utils.isValidHtmlTag)(props.tag); | ||
if (tagExists) return props.tag; | ||
if (tagExists) | ||
return props.tag; | ||
} | ||
if ((0, import_utils.isString)(tag)) { | ||
if ((0, import_utils.isValidHtmlTag)(tag)) return tag; | ||
if ((0, import_utils.isValidHtmlTag)(tag)) | ||
return tag; | ||
} else { | ||
let keyAsTag = key.toLowerCase(); | ||
if (keyAsTag.includes(".")) keyAsTag = keyAsTag.split(".")[0]; | ||
if (keyAsTag.includes("_")) keyAsTag = keyAsTag.split("_")[0]; | ||
if ((0, import_utils.isValidHtmlTag)(keyAsTag)) return keyAsTag; | ||
if (keyAsTag.includes(".")) | ||
keyAsTag = keyAsTag.split(".")[0]; | ||
if (keyAsTag.includes("_")) | ||
keyAsTag = keyAsTag.split("_")[0]; | ||
if ((0, import_utils.isValidHtmlTag)(keyAsTag)) | ||
return keyAsTag; | ||
} | ||
@@ -71,8 +79,11 @@ return "div"; | ||
} | ||
if (!win.nodeCaches) win.nodeCaches = {}; | ||
if (!win.nodeCaches) | ||
win.nodeCaches = {}; | ||
let cachedTag = win.nodeCaches[tag]; | ||
if (!cachedTag) cachedTag = win.nodeCaches[tag] = createHTMLNode(element); | ||
if (!cachedTag) | ||
cachedTag = win.nodeCaches[tag] = createHTMLNode(element); | ||
const clonedNode = cachedTag.cloneNode(true); | ||
if (tag === "string") clonedNode.nodeValue = element.text; | ||
if (tag === "string") | ||
clonedNode.nodeValue = element.text; | ||
return clonedNode; | ||
}; |
@@ -16,6 +16,6 @@ "use strict"; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var index_exports = {}; | ||
module.exports = __toCommonJS(index_exports); | ||
__reExport(index_exports, require("./create.js"), module.exports); | ||
__reExport(index_exports, require("./cache.js"), module.exports); | ||
__reExport(index_exports, require("./append.js"), module.exports); | ||
var render_exports = {}; | ||
module.exports = __toCommonJS(render_exports); | ||
__reExport(render_exports, require("./create.js"), module.exports); | ||
__reExport(render_exports, require("./cache.js"), module.exports); | ||
__reExport(render_exports, require("./append.js"), module.exports); |
@@ -8,3 +8,4 @@ import { report } from "@domql/report"; | ||
if (tag) { | ||
if (tag === "string") return doc.createTextNode(element.text); | ||
if (tag === "string") | ||
return doc.createTextNode(element.text); | ||
else if (tag === "fragment") { | ||
@@ -14,3 +15,4 @@ return doc.createDocumentFragment(); | ||
return doc.createElementNS("http://www.w3.org/2000/svg", tag); | ||
} else return doc.createElement(tag); | ||
} else | ||
return doc.createElement(tag); | ||
} else { | ||
@@ -23,14 +25,20 @@ return doc.createElement("div"); | ||
tag = exec(tag, element); | ||
if (tag === true) tag = key; | ||
if (tag === true) | ||
tag = key; | ||
if (isObject(props) && isString(props.tag)) { | ||
const tagExists = isValidHtmlTag(props.tag); | ||
if (tagExists) return props.tag; | ||
if (tagExists) | ||
return props.tag; | ||
} | ||
if (isString(tag)) { | ||
if (isValidHtmlTag(tag)) return tag; | ||
if (isValidHtmlTag(tag)) | ||
return tag; | ||
} else { | ||
let keyAsTag = key.toLowerCase(); | ||
if (keyAsTag.includes(".")) keyAsTag = keyAsTag.split(".")[0]; | ||
if (keyAsTag.includes("_")) keyAsTag = keyAsTag.split("_")[0]; | ||
if (isValidHtmlTag(keyAsTag)) return keyAsTag; | ||
if (keyAsTag.includes(".")) | ||
keyAsTag = keyAsTag.split(".")[0]; | ||
if (keyAsTag.includes("_")) | ||
keyAsTag = keyAsTag.split("_")[0]; | ||
if (isValidHtmlTag(keyAsTag)) | ||
return keyAsTag; | ||
} | ||
@@ -46,7 +54,10 @@ return "div"; | ||
} | ||
if (!win.nodeCaches) win.nodeCaches = {}; | ||
if (!win.nodeCaches) | ||
win.nodeCaches = {}; | ||
let cachedTag = win.nodeCaches[tag]; | ||
if (!cachedTag) cachedTag = win.nodeCaches[tag] = createHTMLNode(element); | ||
if (!cachedTag) | ||
cachedTag = win.nodeCaches[tag] = createHTMLNode(element); | ||
const clonedNode = cachedTag.cloneNode(true); | ||
if (tag === "string") clonedNode.nodeValue = element.text; | ||
if (tag === "string") | ||
clonedNode.nodeValue = element.text; | ||
return clonedNode; | ||
@@ -53,0 +64,0 @@ }; |
{ | ||
"name": "@domql/render", | ||
"version": "2.5.200", | ||
"version": "2.5.203", | ||
"license": "MIT", | ||
@@ -21,5 +21,5 @@ "type": "module", | ||
"dependencies": { | ||
"@domql/event": "^2.5.200", | ||
"@domql/report": "^2.5.186", | ||
"@domql/utils": "^2.5.200" | ||
"@domql/event": "^2.5.203", | ||
"@domql/report": "^2.5.203", | ||
"@domql/utils": "^2.5.203" | ||
}, | ||
@@ -30,6 +30,6 @@ "scripts": { | ||
"build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs", | ||
"build": "rimraf -I dist; npm run build:cjs; npm run build:esm", | ||
"prepublish": "rimraf -I dist && npm run build && npm run copy:package:cjs" | ||
"build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm", | ||
"prepublish": "npx rimraf -I dist && npm run build && npm run copy:package:cjs" | ||
}, | ||
"gitHead": "0afb63ec375f0526f47ff300885de393138b01e8" | ||
"gitHead": "f8c712416647ab3789253b7176eaa762627fc677" | ||
} |
15825
0.82%389
5.99%Updated
Updated
Updated