Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dom-render

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-render - npm Package Compare versions

Comparing version 1.0.35 to 1.0.36

3

Config.d.ts

@@ -19,2 +19,5 @@ import { ConstructorType } from './types/Types';

proxyExcludeTyps?: ConstructorType<any>[];
scripts?: {
[n: string]: any;
};
applyEvents?: {

@@ -21,0 +24,0 @@ attrName: string;

92

dist/dom-render.js

@@ -438,4 +438,5 @@ 'use strict';

var _a, _b, _c;
var script = '';
if (cNode.nodeType === Node.TEXT_NODE) {
ScriptUtils.getVariablePaths("`" + ((_a = cNode.textContent) !== null && _a !== void 0 ? _a : '') + "`").forEach(function (it) { return usingTriggerVariables.add(it); });
script = "`" + ((_a = cNode.textContent) !== null && _a !== void 0 ? _a : '') + "`";
}

@@ -445,4 +446,9 @@ else if (cNode.nodeType === Node.ELEMENT_NODE) {

var targetAttrNames = ((_c = (_b = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _b === void 0 ? void 0 : _b.map(function (it) { return it.name; })) !== null && _c !== void 0 ? _c : []).concat(RawSet.DR_ATTRIBUTES);
ScriptUtils.getVariablePaths(targetAttrNames.map(function (it) { return (element_1.getAttribute(it)); }).filter(function (it) { return it; }).join(';')).forEach(function (it) { return usingTriggerVariables.add(it); });
script = targetAttrNames.map(function (it) { return (element_1.getAttribute(it)); }).filter(function (it) { return it; }).join(';');
}
if (script) {
script = script.replace(RegExp(RawSet.SCRIPTS_VARNAME.replace('$', '\\$'), 'g'), "this?.___" + RawSet.SCRIPTS_VARNAME);
script = script.replace(RegExp(RawSet.RAWSET_VARNAME.replace('$', '\\$'), 'g'), "this?.___" + RawSet.RAWSET_VARNAME);
Array.from(ScriptUtils.getVariablePaths(script)).filter(function (it) { return !it.startsWith("___" + RawSet.SCRIPTS_VARNAME) && !it.startsWith("___" + RawSet.SCRIPTS_VARNAME); }).forEach(function (it) { return usingTriggerVariables.add(it); });
}
});

@@ -462,3 +468,3 @@ return usingTriggerVariables;

var textContent = cNode.textContent;
var n = document.createTextNode(ScriptUtils.eval("return `" + textContent + "`", obj));
var n = document.createTextNode(ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n return `" + textContent + "`\n ", (config === null || config === void 0 ? void 0 : config.scripts) ? Object.assign(obj, { __render: Object.freeze({ rawset: _this, scripts: config === null || config === void 0 ? void 0 : config.scripts }) }) : obj));
(_a = cNode.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(n, cNode);

@@ -484,5 +490,3 @@ }

var newTemp = document.createElement('temp');
ScriptUtils.eval("\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 }", Object.assign({
__fag: newTemp, __drStripOption: drAttr.drStripOption, __element: element_2
}, obj));
ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n const n = this.__render.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.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__render.fag.append(n);\n }", Object.assign(obj, { __render: Object.freeze({ fag: newTemp, drStripOption: drAttr.drStripOption, element: element_2, rawset: _this, scripts: config === null || config === void 0 ? void 0 : config.scripts }) }));
RawSet.drVarDecoding(newTemp, vars);

@@ -501,5 +505,3 @@ RawSet.drItOtherDecoding(newTemp, itRandom);

var newTemp = document.createElement('temp');
ScriptUtils.eval("\n if(" + drAttr.drIf + ") {\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({
__fag: newTemp, __drStripOption: drAttr.drStripOption, __element: element_2
}, obj));
ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n if(" + drAttr.drIf + ") {\n const n = this.__render.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.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n }", Object.assign(obj, { __render: Object.freeze({ fag: newTemp, drStripOption: drAttr.drStripOption, element: element_2, rawset: _this, scripts: config === null || config === void 0 ? void 0 : config.scripts }) }));
RawSet.drVarDecoding(newTemp, vars);

@@ -556,5 +558,3 @@ RawSet.drItOtherDecoding(newTemp, itRandom);

var newTemp = document.createElement('temp');
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({
__fag: newTemp, __drStripOption: drAttr.drStripOption, __element: element_2
}, obj));
ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n for(" + drAttr.drFor + ") {\n const n = this.__render.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.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n }", Object.assign(obj, { __render: Object.freeze({ fag: newTemp, drStripOption: drAttr.drStripOption, element: element_2, scripts: config === null || config === void 0 ? void 0 : config.scripts }) }));
RawSet.drVarDecoding(newTemp, vars);

@@ -573,7 +573,3 @@ RawSet.drItOtherDecoding(newTemp, itRandom);

var newTemp = document.createElement('temp');
ScriptUtils.eval("var i = 0; for(const it of " + drAttr.drForOf + ") {\n //alert(1)\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({
__drStripOption: drAttr.drStripOption,
__fag: newTemp,
__element: element_2
}, obj));
ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n var i = 0; \n 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.__render.element.cloneNode(true);\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n \n if (this.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n i++;\n }", Object.assign(obj, { __render: Object.freeze({ drStripOption: drAttr.drStripOption, fag: newTemp, element: element_2 }) }));
RawSet.drVarDecoding(newTemp, vars);

@@ -667,38 +663,21 @@ RawSet.drItOtherDecoding(newTemp, itRandom);

if (currentNode.nodeType === Node.TEXT_NODE) {
var text_1 = (_a = currentNode.textContent) !== null && _a !== void 0 ? _a : '';
var text = (_a = currentNode.textContent) !== null && _a !== void 0 ? _a : '';
var template_1 = document.createElement('template');
var a = StringUtils.regexExec(/\$\{.*?\}/g, text_1);
var map = a.reverse().map(function (it) { return { uuid: '', content: '', regexArr: it }; });
var a = StringUtils.regexExec(/\$\{.*?\}/g, text);
var map = a.map(function (it) { return { uuid: RandomUtils.uuid(), content: it[0], regexArr: it }; });
var lasterIndex_1 = 0;
map.forEach(function (it) {
var uuid = RandomUtils.uuid();
it.uuid = uuid;
it.content = it.regexArr[0];
text_1 = text_1.substr(0, it.regexArr.index) + text_1.substr(it.regexArr.index).replace(it.regexArr[0], "<!--start text " + uuid + "--><!--end text " + uuid + "-->");
var regexArr = it.regexArr;
var preparedText = regexArr.input.substring(lasterIndex_1, regexArr.index);
var start = document.createComment("start text " + it.uuid);
var end = document.createComment("end text " + it.uuid);
template_1.content.append(document.createTextNode(preparedText));
template_1.content.append(start);
template_1.content.append(end);
var fragment = document.createDocumentFragment();
fragment.append(document.createTextNode(it.content));
pars.push(new RawSet(it.uuid, { start: start, end: end }, fragment));
lasterIndex_1 = regexArr.index + it.content.length;
});
template_1.innerHTML = text_1;
map.forEach(function (it) {
var _a, _b;
var subNodeIterator = document.createNodeIterator(template_1.content, NodeFilter.SHOW_COMMENT, {
acceptNode: function (node) {
var text = node.textContent;
return (text === "start text " + it.uuid || text === "end text " + it.uuid) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
}
});
var start;
var end;
var subNode;
while (subNode = subNodeIterator.nextNode()) {
if (((_a = subNode.textContent) !== null && _a !== void 0 ? _a : '').startsWith('start')) {
start = subNode;
}
if (((_b = subNode.textContent) !== null && _b !== void 0 ? _b : '').startsWith('end')) {
end = subNode;
}
}
if (start && end) {
var fragment = document.createDocumentFragment();
fragment.append(document.createTextNode(it.content));
pars.push(new RawSet(it.uuid, { start: start, end: end }, fragment));
}
});
template_1.content.append(document.createTextNode(text.substring(lasterIndex_1, text.length)));
(_b = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(template_1.content, currentNode);

@@ -823,2 +802,4 @@ }

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];
RawSet.SCRIPTS_VARNAME = '$scripts';
RawSet.RAWSET_VARNAME = '$rawset';
return RawSet;

@@ -892,10 +873,15 @@ }());

});
this.render(this.getRawSets());
(_b = (_a = this._domRender_proxy) === null || _a === void 0 ? void 0 : _a.onInitRender) === null || _b === void 0 ? void 0 : _b.call(_a);
};
DomRenderProxy.prototype.getRawSets = function () {
var set = new Set();
this._rawSets.forEach(function (v, k) {
_this.render(Array.from(v));
v.forEach(function (it) { return set.add(it); });
});
(_b = (_a = this._domRender_proxy) === null || _a === void 0 ? void 0 : _a.onInitRender) === null || _b === void 0 ? void 0 : _b.call(_a);
return Array.from(set);
};
DomRenderProxy.prototype.render = function (raws) {
var _this = this;
raws.forEach(function (it) {
(raws !== null && raws !== void 0 ? raws : this.getRawSets()).forEach(function (it) {
if (it.point.start.isConnected && it.point.start.isConnected) {

@@ -902,0 +888,0 @@ var rawSets = it.render(_this._domRender_proxy, _this.config);

@@ -15,3 +15,4 @@ import { RawSet } from './RawSet';

initRender(target: Node): void;
render(raws: RawSet[]): void;
getRawSets(): RawSet[];
render(raws?: RawSet[]): void;
root(paths: string[], value: any): void;

@@ -18,0 +19,0 @@ set(target: T, p: string | symbol, value: any, receiver: T): boolean;

@@ -67,10 +67,15 @@ "use strict";

});
this.render(this.getRawSets());
(_b = (_a = this._domRender_proxy) === null || _a === void 0 ? void 0 : _a.onInitRender) === null || _b === void 0 ? void 0 : _b.call(_a);
};
DomRenderProxy.prototype.getRawSets = function () {
var set = new Set();
this._rawSets.forEach(function (v, k) {
_this.render(Array.from(v));
v.forEach(function (it) { return set.add(it); });
});
(_b = (_a = this._domRender_proxy) === null || _a === void 0 ? void 0 : _a.onInitRender) === null || _b === void 0 ? void 0 : _b.call(_a);
return Array.from(set);
};
DomRenderProxy.prototype.render = function (raws) {
var _this = this;
raws.forEach(function (it) {
(raws !== null && raws !== void 0 ? raws : this.getRawSets()).forEach(function (it) {
if (it.point.start.isConnected && it.point.start.isConnected) {

@@ -77,0 +82,0 @@ var rawSets = it.render(_this._domRender_proxy, _this.config);

{
"name": "dom-render",
"version": "1.0.35",
"version": "1.0.36",
"main": "DomRender.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -22,2 +22,4 @@ import { Config } from './Config';

static readonly DR_ATTRIBUTES: string[];
static readonly SCRIPTS_VARNAME = "$scripts";
static readonly RAWSET_VARNAME = "$rawset";
constructor(uuid: string, point: {

@@ -24,0 +26,0 @@ start: Comment;

@@ -27,4 +27,5 @@ "use strict";

var _a, _b, _c;
var script = '';
if (cNode.nodeType === Node.TEXT_NODE) {
ScriptUtils_1.ScriptUtils.getVariablePaths("`" + ((_a = cNode.textContent) !== null && _a !== void 0 ? _a : '') + "`").forEach(function (it) { return usingTriggerVariables.add(it); });
script = "`" + ((_a = cNode.textContent) !== null && _a !== void 0 ? _a : '') + "`";
}

@@ -34,4 +35,9 @@ else if (cNode.nodeType === Node.ELEMENT_NODE) {

var targetAttrNames = ((_c = (_b = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _b === void 0 ? void 0 : _b.map(function (it) { return it.name; })) !== null && _c !== void 0 ? _c : []).concat(RawSet.DR_ATTRIBUTES);
ScriptUtils_1.ScriptUtils.getVariablePaths(targetAttrNames.map(function (it) { return (element_1.getAttribute(it)); }).filter(function (it) { return it; }).join(';')).forEach(function (it) { return usingTriggerVariables.add(it); });
script = targetAttrNames.map(function (it) { return (element_1.getAttribute(it)); }).filter(function (it) { return it; }).join(';');
}
if (script) {
script = script.replace(RegExp(RawSet.SCRIPTS_VARNAME.replace('$', '\\$'), 'g'), "this?.___" + RawSet.SCRIPTS_VARNAME);
script = script.replace(RegExp(RawSet.RAWSET_VARNAME.replace('$', '\\$'), 'g'), "this?.___" + RawSet.RAWSET_VARNAME);
Array.from(ScriptUtils_1.ScriptUtils.getVariablePaths(script)).filter(function (it) { return !it.startsWith("___" + RawSet.SCRIPTS_VARNAME) && !it.startsWith("___" + RawSet.SCRIPTS_VARNAME); }).forEach(function (it) { return usingTriggerVariables.add(it); });
}
});

@@ -51,3 +57,3 @@ return usingTriggerVariables;

var textContent = cNode.textContent;
var n = document.createTextNode(ScriptUtils_1.ScriptUtils.eval("return `" + textContent + "`", obj));
var n = document.createTextNode(ScriptUtils_1.ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n return `" + textContent + "`\n ", (config === null || config === void 0 ? void 0 : config.scripts) ? Object.assign(obj, { __render: Object.freeze({ rawset: _this, scripts: config === null || config === void 0 ? void 0 : config.scripts }) }) : obj));
(_a = cNode.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(n, cNode);

@@ -73,5 +79,3 @@ }

var newTemp = document.createElement('temp');
ScriptUtils_1.ScriptUtils.eval("\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 }", Object.assign({
__fag: newTemp, __drStripOption: drAttr.drStripOption, __element: element_2
}, obj));
ScriptUtils_1.ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n const n = this.__render.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.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__render.fag.append(n);\n }", Object.assign(obj, { __render: Object.freeze({ fag: newTemp, drStripOption: drAttr.drStripOption, element: element_2, rawset: _this, scripts: config === null || config === void 0 ? void 0 : config.scripts }) }));
RawSet.drVarDecoding(newTemp, vars);

@@ -90,5 +94,3 @@ RawSet.drItOtherDecoding(newTemp, itRandom);

var newTemp = document.createElement('temp');
ScriptUtils_1.ScriptUtils.eval("\n if(" + drAttr.drIf + ") {\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({
__fag: newTemp, __drStripOption: drAttr.drStripOption, __element: element_2
}, obj));
ScriptUtils_1.ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n if(" + drAttr.drIf + ") {\n const n = this.__render.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.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n }", Object.assign(obj, { __render: Object.freeze({ fag: newTemp, drStripOption: drAttr.drStripOption, element: element_2, rawset: _this, scripts: config === null || config === void 0 ? void 0 : config.scripts }) }));
RawSet.drVarDecoding(newTemp, vars);

@@ -145,5 +147,3 @@ RawSet.drItOtherDecoding(newTemp, itRandom);

var newTemp = document.createElement('temp');
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({
__fag: newTemp, __drStripOption: drAttr.drStripOption, __element: element_2
}, obj));
ScriptUtils_1.ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n for(" + drAttr.drFor + ") {\n const n = this.__render.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.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n }", Object.assign(obj, { __render: Object.freeze({ fag: newTemp, drStripOption: drAttr.drStripOption, element: element_2, scripts: config === null || config === void 0 ? void 0 : config.scripts }) }));
RawSet.drVarDecoding(newTemp, vars);

@@ -162,7 +162,3 @@ RawSet.drItOtherDecoding(newTemp, itRandom);

var newTemp = document.createElement('temp');
ScriptUtils_1.ScriptUtils.eval("var i = 0; for(const it of " + drAttr.drForOf + ") {\n //alert(1)\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({
__drStripOption: drAttr.drStripOption,
__fag: newTemp,
__element: element_2
}, obj));
ScriptUtils_1.ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n var i = 0; \n 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.__render.element.cloneNode(true);\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n \n if (this.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n i++;\n }", Object.assign(obj, { __render: Object.freeze({ drStripOption: drAttr.drStripOption, fag: newTemp, element: element_2 }) }));
RawSet.drVarDecoding(newTemp, vars);

@@ -256,38 +252,21 @@ RawSet.drItOtherDecoding(newTemp, itRandom);

if (currentNode.nodeType === Node.TEXT_NODE) {
var text_1 = (_a = currentNode.textContent) !== null && _a !== void 0 ? _a : '';
var text = (_a = currentNode.textContent) !== null && _a !== void 0 ? _a : '';
var template_1 = document.createElement('template');
var a = StringUtils_1.StringUtils.regexExec(/\$\{.*?\}/g, text_1);
var map = a.reverse().map(function (it) { return { uuid: '', content: '', regexArr: it }; });
var a = StringUtils_1.StringUtils.regexExec(/\$\{.*?\}/g, text);
var map = a.map(function (it) { return { uuid: RandomUtils_1.RandomUtils.uuid(), content: it[0], regexArr: it }; });
var lasterIndex_1 = 0;
map.forEach(function (it) {
var uuid = RandomUtils_1.RandomUtils.uuid();
it.uuid = uuid;
it.content = it.regexArr[0];
text_1 = text_1.substr(0, it.regexArr.index) + text_1.substr(it.regexArr.index).replace(it.regexArr[0], "<!--start text " + uuid + "--><!--end text " + uuid + "-->");
var regexArr = it.regexArr;
var preparedText = regexArr.input.substring(lasterIndex_1, regexArr.index);
var start = document.createComment("start text " + it.uuid);
var end = document.createComment("end text " + it.uuid);
template_1.content.append(document.createTextNode(preparedText));
template_1.content.append(start);
template_1.content.append(end);
var fragment = document.createDocumentFragment();
fragment.append(document.createTextNode(it.content));
pars.push(new RawSet(it.uuid, { start: start, end: end }, fragment));
lasterIndex_1 = regexArr.index + it.content.length;
});
template_1.innerHTML = text_1;
map.forEach(function (it) {
var _a, _b;
var subNodeIterator = document.createNodeIterator(template_1.content, NodeFilter.SHOW_COMMENT, {
acceptNode: function (node) {
var text = node.textContent;
return (text === "start text " + it.uuid || text === "end text " + it.uuid) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
}
});
var start;
var end;
var subNode;
while (subNode = subNodeIterator.nextNode()) {
if (((_a = subNode.textContent) !== null && _a !== void 0 ? _a : '').startsWith('start')) {
start = subNode;
}
if (((_b = subNode.textContent) !== null && _b !== void 0 ? _b : '').startsWith('end')) {
end = subNode;
}
}
if (start && end) {
var fragment = document.createDocumentFragment();
fragment.append(document.createTextNode(it.content));
pars.push(new RawSet(it.uuid, { start: start, end: end }, fragment));
}
});
template_1.content.append(document.createTextNode(text.substring(lasterIndex_1, text.length)));
(_b = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(template_1.content, currentNode);

@@ -412,4 +391,6 @@ }

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];
RawSet.SCRIPTS_VARNAME = '$scripts';
RawSet.RAWSET_VARNAME = '$rawset';
return RawSet;
}());
exports.RawSet = RawSet;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc