dom-render
Advanced tools
Comparing version 1.0.33 to 1.0.34
@@ -168,5 +168,2 @@ 'use strict'; | ||
ScriptUtils.evalReturn = function (script, thisTarget) { | ||
if (!script.startsWith('this.')) { | ||
script = 'this.' + script; | ||
} | ||
return this.eval('return ' + script + ';', thisTarget); | ||
@@ -460,3 +457,3 @@ }; | ||
genNode.childNodes.forEach(function (cNode, key) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; | ||
var fag = document.createDocumentFragment(); | ||
@@ -476,2 +473,4 @@ if (cNode.nodeType === Node.TEXT_NODE) { | ||
drThis: _this.getAttributeAndDelete(element_2, RawSet.DR_THIS_NAME), | ||
drInnerHTML: _this.getAttributeAndDelete(element_2, RawSet.DR_INNERHTML_NAME), | ||
drInnerText: _this.getAttributeAndDelete(element_2, RawSet.DR_INNERTEXT_NAME), | ||
drItOption: _this.getAttributeAndDelete(element_2, RawSet.DR_IT_OPTIONNAME), | ||
@@ -525,5 +524,31 @@ drVarOption: _this.getAttributeAndDelete(element_2, RawSet.DR_VAR_OPTIONNAME), | ||
} | ||
if (drAttr.drInnerText) { | ||
var data = ScriptUtils.evalReturn(drAttr.drInnerText, obj); | ||
var newTemp = document.createElement('temp'); | ||
ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n n.innerText = this.__data;\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n ", Object.assign({ | ||
__fag: newTemp, __drStripOption: drAttr.drStripOption, __data: data, __element: element_2 | ||
}, obj)); | ||
var tempalte = document.createElement('template'); | ||
tempalte.innerHTML = newTemp.innerHTML; | ||
fag.append(tempalte.content); | ||
var rr = RawSet.checkPointCreates(fag, config); | ||
(_h = element_2.parentNode) === null || _h === void 0 ? void 0 : _h.replaceChild(fag, element_2); | ||
raws.push.apply(raws, rr); | ||
} | ||
if (drAttr.drInnerHTML) { | ||
var data = ScriptUtils.evalReturn(drAttr.drInnerHTML, obj); | ||
var newTemp = document.createElement('temp'); | ||
ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n n.innerHTML = this.__data;\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n ", Object.assign({ | ||
__fag: newTemp, __drStripOption: drAttr.drStripOption, __data: data, __element: element_2 | ||
}, obj)); | ||
var tempalte = document.createElement('template'); | ||
tempalte.innerHTML = newTemp.innerHTML; | ||
fag.append(tempalte.content); | ||
var rr = RawSet.checkPointCreates(fag, config); | ||
(_j = element_2.parentNode) === null || _j === void 0 ? void 0 : _j.replaceChild(fag, element_2); | ||
raws.push.apply(raws, rr); | ||
} | ||
if (drAttr.drFor) { | ||
var itRandom = RawSet.drItOtherEncoding(element_2); | ||
var vars = RawSet.drVarEncoding(element_2, (_h = drAttr.drVarOption) !== null && _h !== void 0 ? _h : ''); | ||
var vars = RawSet.drVarEncoding(element_2, (_k = drAttr.drVarOption) !== null && _k !== void 0 ? _k : ''); | ||
var newTemp = document.createElement('temp'); | ||
@@ -539,3 +564,3 @@ ScriptUtils.eval("\n for(" + drAttr.drFor + ") {\n const n = this.__element.cloneNode(true);\n var destIt = " + drAttr.drItOption + ";\n if (destIt !== undefined) {\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n }\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n }", Object.assign({ | ||
var rr = RawSet.checkPointCreates(fag, config); | ||
(_j = element_2.parentNode) === null || _j === void 0 ? void 0 : _j.replaceChild(fag, element_2); | ||
(_l = element_2.parentNode) === null || _l === void 0 ? void 0 : _l.replaceChild(fag, element_2); | ||
raws.push.apply(raws, rr); | ||
@@ -545,3 +570,3 @@ } | ||
var itRandom = RawSet.drItOtherEncoding(element_2); | ||
var vars = RawSet.drVarEncoding(element_2, (_k = drAttr.drVarOption) !== null && _k !== void 0 ? _k : ''); | ||
var vars = RawSet.drVarEncoding(element_2, (_m = drAttr.drVarOption) !== null && _m !== void 0 ? _m : ''); | ||
var newTemp = document.createElement('temp'); | ||
@@ -559,6 +584,6 @@ ScriptUtils.eval("var i = 0; for(const it of " + drAttr.drForOf + ") {\n var destIt = it;\n var forOfStr = `" + drAttr.drForOf + "`;\n if (/,/g.test(forOfStr)) {\n if (typeof it === 'string') {\n destIt = it;\n } else {\n destIt = forOfStr.substring(1, forOfStr.length-1).split(',')[i];\n }\n } else {\n destIt = forOfStr + '[' + i +']'\n }\n \n const n = this.__element.cloneNode(true);\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n \n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n i++;\n }", Object.assign({ | ||
var rr = RawSet.checkPointCreates(fag, config); | ||
(_l = element_2.parentNode) === null || _l === void 0 ? void 0 : _l.replaceChild(fag, element_2); | ||
(_o = element_2.parentNode) === null || _o === void 0 ? void 0 : _o.replaceChild(fag, element_2); | ||
raws.push.apply(raws, rr); | ||
} | ||
(_m = config === null || config === void 0 ? void 0 : config.targetElements) === null || _m === void 0 ? void 0 : _m.forEach(function (it) { | ||
(_p = config === null || config === void 0 ? void 0 : config.targetElements) === null || _p === void 0 ? void 0 : _p.forEach(function (it) { | ||
var _a, _b; | ||
@@ -582,3 +607,3 @@ var name = it.name; | ||
}); | ||
(_o = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _o === void 0 ? void 0 : _o.forEach(function (it) { | ||
(_q = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _q === void 0 ? void 0 : _q.forEach(function (it) { | ||
var _a, _b; | ||
@@ -791,2 +816,4 @@ var attrName = it.name; | ||
RawSet.DR_THIS_NAME = 'dr-this'; | ||
RawSet.DR_INNERHTML_NAME = 'dr-inner-html'; | ||
RawSet.DR_INNERTEXT_NAME = 'dr-inner-text'; | ||
RawSet.DR_TAGS = []; | ||
@@ -796,3 +823,3 @@ RawSet.DR_IT_OPTIONNAME = 'dr-it'; | ||
RawSet.DR_STRIP_OPTIONNAME = 'dr-strip'; | ||
RawSet.DR_ATTRIBUTES = [RawSet.DR_IF_NAME, RawSet.DR_FOR_OF_NAME, RawSet.DR_FOR_NAME, RawSet.DR_THIS_NAME, RawSet.DR]; | ||
RawSet.DR_ATTRIBUTES = [RawSet.DR, RawSet.DR_IF_NAME, RawSet.DR_FOR_OF_NAME, RawSet.DR_FOR_NAME, RawSet.DR_THIS_NAME, RawSet.DR_INNERHTML_NAME, RawSet.DR_INNERTEXT_NAME]; | ||
return RawSet; | ||
@@ -799,0 +826,0 @@ }()); |
{ | ||
"name": "dom-render", | ||
"version": "1.0.33", | ||
"version": "1.0.34", | ||
"main": "DomRender.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -15,2 +15,4 @@ import { Config } from './Config'; | ||
static readonly DR_THIS_NAME = "dr-this"; | ||
static readonly DR_INNERHTML_NAME = "dr-inner-html"; | ||
static readonly DR_INNERTEXT_NAME = "dr-inner-text"; | ||
static readonly DR_TAGS: never[]; | ||
@@ -17,0 +19,0 @@ static readonly DR_IT_OPTIONNAME = "dr-it"; |
@@ -45,3 +45,3 @@ "use strict"; | ||
genNode.childNodes.forEach(function (cNode, key) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; | ||
var fag = document.createDocumentFragment(); | ||
@@ -61,2 +61,4 @@ if (cNode.nodeType === Node.TEXT_NODE) { | ||
drThis: _this.getAttributeAndDelete(element_2, RawSet.DR_THIS_NAME), | ||
drInnerHTML: _this.getAttributeAndDelete(element_2, RawSet.DR_INNERHTML_NAME), | ||
drInnerText: _this.getAttributeAndDelete(element_2, RawSet.DR_INNERTEXT_NAME), | ||
drItOption: _this.getAttributeAndDelete(element_2, RawSet.DR_IT_OPTIONNAME), | ||
@@ -110,5 +112,31 @@ drVarOption: _this.getAttributeAndDelete(element_2, RawSet.DR_VAR_OPTIONNAME), | ||
} | ||
if (drAttr.drInnerText) { | ||
var data = ScriptUtils_1.ScriptUtils.evalReturn(drAttr.drInnerText, obj); | ||
var newTemp = document.createElement('temp'); | ||
ScriptUtils_1.ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n n.innerText = this.__data;\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n ", Object.assign({ | ||
__fag: newTemp, __drStripOption: drAttr.drStripOption, __data: data, __element: element_2 | ||
}, obj)); | ||
var tempalte = document.createElement('template'); | ||
tempalte.innerHTML = newTemp.innerHTML; | ||
fag.append(tempalte.content); | ||
var rr = RawSet.checkPointCreates(fag, config); | ||
(_h = element_2.parentNode) === null || _h === void 0 ? void 0 : _h.replaceChild(fag, element_2); | ||
raws.push.apply(raws, rr); | ||
} | ||
if (drAttr.drInnerHTML) { | ||
var data = ScriptUtils_1.ScriptUtils.evalReturn(drAttr.drInnerHTML, obj); | ||
var newTemp = document.createElement('temp'); | ||
ScriptUtils_1.ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n n.innerHTML = this.__data;\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n ", Object.assign({ | ||
__fag: newTemp, __drStripOption: drAttr.drStripOption, __data: data, __element: element_2 | ||
}, obj)); | ||
var tempalte = document.createElement('template'); | ||
tempalte.innerHTML = newTemp.innerHTML; | ||
fag.append(tempalte.content); | ||
var rr = RawSet.checkPointCreates(fag, config); | ||
(_j = element_2.parentNode) === null || _j === void 0 ? void 0 : _j.replaceChild(fag, element_2); | ||
raws.push.apply(raws, rr); | ||
} | ||
if (drAttr.drFor) { | ||
var itRandom = RawSet.drItOtherEncoding(element_2); | ||
var vars = RawSet.drVarEncoding(element_2, (_h = drAttr.drVarOption) !== null && _h !== void 0 ? _h : ''); | ||
var vars = RawSet.drVarEncoding(element_2, (_k = drAttr.drVarOption) !== null && _k !== void 0 ? _k : ''); | ||
var newTemp = document.createElement('temp'); | ||
@@ -124,3 +152,3 @@ ScriptUtils_1.ScriptUtils.eval("\n for(" + drAttr.drFor + ") {\n const n = this.__element.cloneNode(true);\n var destIt = " + drAttr.drItOption + ";\n if (destIt !== undefined) {\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n }\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n }", Object.assign({ | ||
var rr = RawSet.checkPointCreates(fag, config); | ||
(_j = element_2.parentNode) === null || _j === void 0 ? void 0 : _j.replaceChild(fag, element_2); | ||
(_l = element_2.parentNode) === null || _l === void 0 ? void 0 : _l.replaceChild(fag, element_2); | ||
raws.push.apply(raws, rr); | ||
@@ -130,3 +158,3 @@ } | ||
var itRandom = RawSet.drItOtherEncoding(element_2); | ||
var vars = RawSet.drVarEncoding(element_2, (_k = drAttr.drVarOption) !== null && _k !== void 0 ? _k : ''); | ||
var vars = RawSet.drVarEncoding(element_2, (_m = drAttr.drVarOption) !== null && _m !== void 0 ? _m : ''); | ||
var newTemp = document.createElement('temp'); | ||
@@ -144,6 +172,6 @@ ScriptUtils_1.ScriptUtils.eval("var i = 0; for(const it of " + drAttr.drForOf + ") {\n var destIt = it;\n var forOfStr = `" + drAttr.drForOf + "`;\n if (/,/g.test(forOfStr)) {\n if (typeof it === 'string') {\n destIt = it;\n } else {\n destIt = forOfStr.substring(1, forOfStr.length-1).split(',')[i];\n }\n } else {\n destIt = forOfStr + '[' + i +']'\n }\n \n const n = this.__element.cloneNode(true);\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n \n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n i++;\n }", Object.assign({ | ||
var rr = RawSet.checkPointCreates(fag, config); | ||
(_l = element_2.parentNode) === null || _l === void 0 ? void 0 : _l.replaceChild(fag, element_2); | ||
(_o = element_2.parentNode) === null || _o === void 0 ? void 0 : _o.replaceChild(fag, element_2); | ||
raws.push.apply(raws, rr); | ||
} | ||
(_m = config === null || config === void 0 ? void 0 : config.targetElements) === null || _m === void 0 ? void 0 : _m.forEach(function (it) { | ||
(_p = config === null || config === void 0 ? void 0 : config.targetElements) === null || _p === void 0 ? void 0 : _p.forEach(function (it) { | ||
var _a, _b; | ||
@@ -167,3 +195,3 @@ var name = it.name; | ||
}); | ||
(_o = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _o === void 0 ? void 0 : _o.forEach(function (it) { | ||
(_q = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _q === void 0 ? void 0 : _q.forEach(function (it) { | ||
var _a, _b; | ||
@@ -376,2 +404,4 @@ var attrName = it.name; | ||
RawSet.DR_THIS_NAME = 'dr-this'; | ||
RawSet.DR_INNERHTML_NAME = 'dr-inner-html'; | ||
RawSet.DR_INNERTEXT_NAME = 'dr-inner-text'; | ||
RawSet.DR_TAGS = []; | ||
@@ -381,5 +411,5 @@ RawSet.DR_IT_OPTIONNAME = 'dr-it'; | ||
RawSet.DR_STRIP_OPTIONNAME = 'dr-strip'; | ||
RawSet.DR_ATTRIBUTES = [RawSet.DR_IF_NAME, RawSet.DR_FOR_OF_NAME, RawSet.DR_FOR_NAME, RawSet.DR_THIS_NAME, RawSet.DR]; | ||
RawSet.DR_ATTRIBUTES = [RawSet.DR, RawSet.DR_IF_NAME, RawSet.DR_FOR_OF_NAME, RawSet.DR_FOR_NAME, RawSet.DR_THIS_NAME, RawSet.DR_INNERHTML_NAME, RawSet.DR_INNERTEXT_NAME]; | ||
return RawSet; | ||
}()); | ||
exports.RawSet = RawSet; |
@@ -37,3 +37,9 @@ dom-render | ||
</div> | ||
<h2>df-inner-text</h2> | ||
<div dr-strip="true" dr-inner-text="'<b>aa</b> <button dr-event-click=\'alert(1)\'>aa</button>'" > friend</div> | ||
<h2>df-inner-html</h2> | ||
<div dr-strip="true" dr-inner-html="'<b>aa</b> <button dr-event-click=\'alert(1)\'>aa</button>'" > friend</div> | ||
<h1>event</h1> | ||
@@ -40,0 +46,0 @@ <h2>dr-event, click, change, input, keyup, keydown</h2> |
@@ -39,5 +39,2 @@ "use strict"; | ||
ScriptUtils.evalReturn = function (script, thisTarget) { | ||
if (!script.startsWith('this.')) { | ||
script = 'this.' + script; | ||
} | ||
return this.eval('return ' + script + ';', thisTarget); | ||
@@ -44,0 +41,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123910
2392
118