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.50 to 1.0.51

dist/iterators/Range.d.ts

7

dist/RawSet.d.ts

@@ -14,3 +14,5 @@ import { Config, TargetElement } from './Config';

static readonly DR_FOR_NAME = "dr-for";
static readonly DR_REPEAT_NAME = "dr-repeat";
static readonly DR_THIS_NAME = "dr-this";
static readonly DR_FORM_NAME = "dr-form";
static readonly DR_INNERHTML_NAME = "dr-inner-html";

@@ -29,2 +31,6 @@ static readonly DR_INNERTEXT_NAME = "dr-inner-text";

static readonly RAWSET_VARNAME = "$rawset";
static readonly RANGE_VARNAME = "$range";
static readonly ELEMENT_VARNAME = "$element";
static readonly TARGET_VARNAME = "$target";
static readonly VARNAMES: string[];
constructor(uuid: string, point: {

@@ -46,2 +52,3 @@ start: Comment;

static drThisDecoding(element: Element, thisRandom: string): void;
static drFormOtherMoveAttr(element: Element, as: string, to: string): void;
static drVarEncoding(element: Element, drVarOption: string): {

@@ -48,0 +55,0 @@ name: string;

7

dist/validations/Validation.d.ts
export declare abstract class Validation {
value: string;
value?: string;
constructor(value?: string);
abstract valid(): boolean;
childValid(): boolean;
childInValid(): boolean;
valids(): boolean;
inValids(): boolean;
get length(): number;
[name: string]: Validation | string | undefined | Element | any;
}

@@ -132,2 +132,3 @@ import { RawSet } from './RawSet';

var _a, _b, _c, _d;
console.log('set--?', p, target, value);
if (typeof p === 'string') {

@@ -134,0 +135,0 @@ value = this.proxy(receiver, value, p);

@@ -0,1 +1,28 @@

var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
import { ScriptUtils } from '../utils/script/ScriptUtils';

@@ -80,2 +107,3 @@ import { DomUtils } from '../utils/dom/DomUtils';

if (varName) {
console.log('--value-link-->', _this.getValue(obj, varName), 'value->', it.value);
var value = _this.getValue(obj, varName);

@@ -86,5 +114,11 @@ if (typeof value === 'function' && value) {

else {
_this.setValue(obj, varName, it.value);
if (value) {
_this.setValue(obj, varName, value);
}
else {
_this.setValue(obj, varName, it.value);
}
}
it.addEventListener('input', function (eit) {
console.log('input change--->link', eit.target.value);
if (typeof _this.getValue(obj, varName) === 'function') {

@@ -122,2 +156,3 @@ _this.getValue(obj, varName)(it.value, eit);

this.procAttr(elements, this.attrPrefix + 'attr', function (it, attribute) {
var e_1, _a;
var script = attribute;

@@ -135,3 +170,3 @@ if (script) {

data.split(',').forEach(function (sit) {
var _a = sit.split('='), key = _a[0], value = _a[1];
var _a = __read(sit.split('='), 2), key = _a[0], value = _a[1];
it.setAttribute(key.trim(), value.trim());

@@ -142,3 +177,3 @@ });

data.forEach(function (sit) {
var _a = sit.split('='), key = _a[0], value = _a[1];
var _a = __read(sit.split('='), 2), key = _a[0], value = _a[1];
it.setAttribute(key.trim(), value.trim());

@@ -148,6 +183,15 @@ });

else {
for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
it.setAttribute(key, String(value));
try {
for (var _b = __values(Object.entries(data)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
it.setAttribute(key, String(value));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
}

@@ -157,2 +201,3 @@ }

this.procAttr(elements, this.attrPrefix + 'style', function (it, attribute) {
var e_2, _a;
var script = attribute;

@@ -175,8 +220,17 @@ if (script) {

else {
for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
if (it instanceof HTMLElement) {
it.style[key] = String(value);
try {
for (var _b = __values(Object.entries(data)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
if (it instanceof HTMLElement) {
it.style[key] = String(value);
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_2) throw e_2.error; }
}
}

@@ -186,2 +240,3 @@ }

this.procAttr(elements, this.attrPrefix + 'class', function (it, attribute) {
var e_3, _a;
var script = attribute;

@@ -204,13 +259,22 @@ if (script) {

else {
for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
if (it instanceof HTMLElement) {
if (value) {
it.classList.add(key);
try {
for (var _b = __values(Object.entries(data)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
if (it instanceof HTMLElement) {
if (value) {
it.classList.add(key);
}
else {
it.classList.remove(key);
}
}
else {
it.classList.remove(key);
}
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_3) throw e_3.error; }
}
}

@@ -241,6 +305,6 @@ }

Object.entries(attributes).filter(function (_a) {
var k = _a[0], v = _a[1];
var _b = __read(_a, 2), k = _b[0], v = _b[1];
return k.startsWith(prefix_1);
}).forEach(function (_a) {
var k = _a[0], v = _a[1];
var _b = __read(_a, 2), k = _b[0], v = _b[1];
params_1[k.slice(prefix_1.length)] = v;

@@ -247,0 +311,0 @@ });

{
"name": "dom-render",
"version": "1.0.50",
"version": "1.0.51",
"main": "DomRender.js",

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

@@ -14,3 +14,5 @@ import { Config, TargetElement } from './Config';

static readonly DR_FOR_NAME = "dr-for";
static readonly DR_REPEAT_NAME = "dr-repeat";
static readonly DR_THIS_NAME = "dr-this";
static readonly DR_FORM_NAME = "dr-form";
static readonly DR_INNERHTML_NAME = "dr-inner-html";

@@ -29,2 +31,6 @@ static readonly DR_INNERTEXT_NAME = "dr-inner-text";

static readonly RAWSET_VARNAME = "$rawset";
static readonly RANGE_VARNAME = "$range";
static readonly ELEMENT_VARNAME = "$element";
static readonly TARGET_VARNAME = "$target";
static readonly VARNAMES: string[];
constructor(uuid: string, point: {

@@ -46,2 +52,3 @@ start: Comment;

static drThisDecoding(element: Element, thisRandom: string): void;
static drFormOtherMoveAttr(element: Element, as: string, to: string): void;
static drVarEncoding(element: Element, drVarOption: string): {

@@ -48,0 +55,0 @@ name: string;

@@ -0,1 +1,37 @@

var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
import { RandomUtils } from './utils/random/RandomUtils';

@@ -5,2 +41,3 @@ import { StringUtils } from './utils/string/StringUtils';

import { eventManager } from './events/EventManager';
import { Range } from './iterators/Range';
var RawSet = (function () {

@@ -35,4 +72,5 @@ function RawSet(uuid, point, fragment, data) {

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);
RawSet.VARNAMES.forEach(function (it) {
script = script.replace(RegExp(it.replace('$', '\\$'), 'g'), "this?.___" + it);
});
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); });

@@ -51,3 +89,3 @@ }

genNode.childNodes.forEach(function (cNode, key) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
var fag = document.createDocumentFragment();

@@ -66,3 +104,3 @@ if (cNode.nodeType === Node.TEXT_NODE) {

var element_2 = cNode;
var drAttr = {
var drAttr_1 = {
dr: _this.getAttributeAndDelete(element_2, RawSet.DR),

@@ -72,3 +110,5 @@ drIf: _this.getAttributeAndDelete(element_2, RawSet.DR_IF_NAME),

drForOf: _this.getAttributeAndDelete(element_2, RawSet.DR_FOR_OF_NAME),
drRepeat: _this.getAttributeAndDelete(element_2, RawSet.DR_REPEAT_NAME),
drThis: _this.getAttributeAndDelete(element_2, RawSet.DR_THIS_NAME),
drForm: _this.getAttributeAndDelete(element_2, RawSet.DR_FORM_NAME),
drInnerHTML: _this.getAttributeAndDelete(element_2, RawSet.DR_INNERHTML_NAME),

@@ -83,11 +123,11 @@ drInnerText: _this.getAttributeAndDelete(element_2, RawSet.DR_INNERTEXT_NAME),

};
drAttrs.push(drAttr);
if (drAttr.dr !== null && drAttr.dr.length >= 0) {
drAttrs.push(drAttr_1);
if (drAttr_1.dr !== null && drAttr_1.dr.length >= 0) {
var itRandom = RawSet.drItOtherEncoding(element_2);
var vars = RawSet.drVarEncoding(element_2, (_b = drAttr.drVarOption) !== null && _b !== void 0 ? _b : '');
var vars = RawSet.drVarEncoding(element_2, (_b = drAttr_1.drVarOption) !== null && _b !== void 0 ? _b : '');
var newTemp = document.createElement('temp');
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.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt)))\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, {
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_1.drItOption + ";\n if (destIt !== undefined) {\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt)))\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,
drStripOption: drAttr_1.drStripOption,
element: element_2,

@@ -105,12 +145,12 @@ rawset: _this,

(_c = element_2.parentNode) === null || _c === void 0 ? void 0 : _c.replaceChild(fag, element_2);
raws.push.apply(raws, rr);
raws.push.apply(raws, __spreadArray([], __read(rr), false));
}
if (drAttr.drIf) {
if (drAttr_1.drIf) {
var itRandom = RawSet.drItOtherEncoding(element_2);
var vars = RawSet.drVarEncoding(element_2, (_d = drAttr.drVarOption) !== null && _d !== void 0 ? _d : '');
var vars = RawSet.drVarEncoding(element_2, (_d = drAttr_1.drVarOption) !== null && _d !== void 0 ? _d : '');
var newTemp = document.createElement('temp');
ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n " + ((_e = drAttr.drBeforeOption) !== null && _e !== void 0 ? _e : '') + "\n if(" + drAttr.drIf + ") {\n const n = this.__render.element.cloneNode(true);\n var destIt = " + drAttr.drItOption + ";\n if (destIt !== undefined) {\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt)))\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 }\n " + ((_f = drAttr.drAfterOption) !== null && _f !== void 0 ? _f : '') + "\n ", Object.assign(obj, {
ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n " + ((_e = drAttr_1.drBeforeOption) !== null && _e !== void 0 ? _e : '') + "\n if(" + drAttr_1.drIf + ") {\n const n = this.__render.element.cloneNode(true);\n var destIt = " + drAttr_1.drItOption + ";\n if (destIt !== undefined) {\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt)))\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 }\n " + ((_f = drAttr_1.drAfterOption) !== null && _f !== void 0 ? _f : '') + "\n ", Object.assign(obj, {
__render: Object.freeze({
fag: newTemp,
drStripOption: drAttr.drStripOption,
drStripOption: drAttr_1.drStripOption,
element: element_2,

@@ -128,11 +168,11 @@ rawset: _this,

(_g = element_2.parentNode) === null || _g === void 0 ? void 0 : _g.replaceChild(fag, element_2);
raws.push.apply(raws, rr);
raws.push.apply(raws, __spreadArray([], __read(rr), false));
}
if (drAttr.drThis) {
var r = ScriptUtils.evalReturn(drAttr.drThis, obj);
if (drAttr_1.drThis) {
var r = ScriptUtils.evalReturn(drAttr_1.drThis, obj);
if (r) {
fag.append(RawSet.drThisCreate(element_2, drAttr.drThis, (_h = drAttr.drVarOption) !== null && _h !== void 0 ? _h : '', drAttr.drStripOption, obj));
fag.append(RawSet.drThisCreate(element_2, drAttr_1.drThis, (_h = drAttr_1.drVarOption) !== null && _h !== void 0 ? _h : '', drAttr_1.drStripOption, obj));
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);
raws.push.apply(raws, __spreadArray([], __read(rr), false));
}

@@ -143,8 +183,18 @@ else {

}
if (drAttr.drInnerText) {
var data = ScriptUtils.evalReturn(drAttr.drInnerText, obj);
if (drAttr_1.drForm) {
RawSet.drFormOtherMoveAttr(element_2, 'name', 'temp-name');
element_2.querySelectorAll('[name]').forEach(function (it) {
var _a;
var eventName = (_a = it.getAttribute('dr-form:event')) !== null && _a !== void 0 ? _a : 'change';
it.setAttribute(eventManager.attrPrefix + 'event-' + eventName, drAttr_1.drForm + '.' + it.getAttribute('name') + ' = $target.value');
});
RawSet.drFormOtherMoveAttr(element_2, 'temp-name', 'name');
raws.push.apply(raws, __spreadArray([], __read(RawSet.checkPointCreates(element_2, config)), false));
}
if (drAttr_1.drInnerText) {
var data = ScriptUtils.evalReturn(drAttr_1.drInnerText, obj);
var newTemp = document.createElement('temp');
ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n " + ((_k = drAttr.drBeforeOption) !== null && _k !== void 0 ? _k : '') + "\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 " + ((_l = drAttr.drAfterOption) !== null && _l !== void 0 ? _l : '') + "\n ", Object.assign({
ScriptUtils.eval(" \n const n = this.__element.cloneNode(true); \n " + ((_k = drAttr_1.drBeforeOption) !== null && _k !== void 0 ? _k : '') + "\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 " + ((_l = drAttr_1.drAfterOption) !== null && _l !== void 0 ? _l : '') + "\n ", Object.assign({
__fag: newTemp,
__drStripOption: drAttr.drStripOption,
__drStripOption: drAttr_1.drStripOption,
__data: data,

@@ -158,10 +208,10 @@ __element: element_2

(_m = element_2.parentNode) === null || _m === void 0 ? void 0 : _m.replaceChild(fag, element_2);
raws.push.apply(raws, rr);
raws.push.apply(raws, __spreadArray([], __read(rr), false));
}
if (drAttr.drInnerHTML) {
var data = ScriptUtils.evalReturn(drAttr.drInnerHTML, obj);
if (drAttr_1.drInnerHTML) {
var data = ScriptUtils.evalReturn(drAttr_1.drInnerHTML, obj);
var newTemp = document.createElement('temp');
ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n " + ((_o = drAttr.drBeforeOption) !== null && _o !== void 0 ? _o : '') + "\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 " + ((_p = drAttr.drAfterOption) !== null && _p !== void 0 ? _p : '') + "\n ", Object.assign({
ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n " + ((_o = drAttr_1.drBeforeOption) !== null && _o !== void 0 ? _o : '') + "\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 " + ((_p = drAttr_1.drAfterOption) !== null && _p !== void 0 ? _p : '') + "\n ", Object.assign({
__fag: newTemp,
__drStripOption: drAttr.drStripOption,
__drStripOption: drAttr_1.drStripOption,
__data: data,

@@ -175,12 +225,13 @@ __element: element_2

(_q = element_2.parentNode) === null || _q === void 0 ? void 0 : _q.replaceChild(fag, element_2);
raws.push.apply(raws, rr);
raws.push.apply(raws, __spreadArray([], __read(rr), false));
}
if (drAttr.drFor) {
if (drAttr_1.drFor) {
var itRandom = RawSet.drItOtherEncoding(element_2);
var vars = RawSet.drVarEncoding(element_2, (_r = drAttr.drVarOption) !== null && _r !== void 0 ? _r : '');
var vars = RawSet.drVarEncoding(element_2, (_r = drAttr_1.drVarOption) !== null && _r !== void 0 ? _r : '');
var newTemp = document.createElement('temp');
ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n " + ((_s = drAttr.drBeforeOption) !== null && _s !== void 0 ? _s : '') + "\n for(" + drAttr.drFor + ") {\n const n = this.__render.element.cloneNode(true);\n var destIt = " + drAttr.drItOption + ";\n if (destIt !== undefined) {\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt))) \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 }\n " + ((_t = drAttr.drAfterOption) !== null && _t !== void 0 ? _t : '') + "\n ", Object.assign(obj, {
ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RANGE_VARNAME + " = this.__render.range;\n const " + RawSet.ELEMENT_VARNAME + " = this.__render.element;\n " + ((_s = drAttr_1.drBeforeOption) !== null && _s !== void 0 ? _s : '') + "\n for(" + drAttr_1.drFor + ") {\n const n = this.__render.element.cloneNode(true);\n var destIt = " + drAttr_1.drItOption + ";\n if (destIt !== undefined) {\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt))) \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 }\n " + ((_t = drAttr_1.drAfterOption) !== null && _t !== void 0 ? _t : '') + "\n ", Object.assign(obj, {
__render: Object.freeze({
range: Range.range,
fag: newTemp,
drStripOption: drAttr.drStripOption,
drStripOption: drAttr_1.drStripOption,
element: element_2,

@@ -197,12 +248,13 @@ scripts: RawSet.setBindProperty(config === null || config === void 0 ? void 0 : config.scripts, obj)

(_u = element_2.parentNode) === null || _u === void 0 ? void 0 : _u.replaceChild(fag, element_2);
raws.push.apply(raws, rr);
raws.push.apply(raws, __spreadArray([], __read(rr), false));
}
if (drAttr.drForOf) {
if (drAttr_1.drForOf) {
var itRandom = RawSet.drItOtherEncoding(element_2);
var vars = RawSet.drVarEncoding(element_2, (_v = drAttr.drVarOption) !== null && _v !== void 0 ? _v : '');
var vars = RawSet.drVarEncoding(element_2, (_v = drAttr_1.drVarOption) !== null && _v !== void 0 ? _v : '');
var newTemp = document.createElement('temp');
ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n " + ((_w = drAttr.drBeforeOption) !== null && _w !== void 0 ? _w : '') + "\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.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt)))\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 }\n " + ((_x = drAttr.drAfterOption) !== null && _x !== void 0 ? _x : '') + "\n ", Object.assign(obj, {
ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RANGE_VARNAME + " = this.__render.range;\n const " + RawSet.ELEMENT_VARNAME + " = this.__render.element;\n " + ((_w = drAttr_1.drBeforeOption) !== null && _w !== void 0 ? _w : '') + "\n var i = 0; \n const forOf = " + drAttr_1.drForOf + ";\n const forOfStr = `" + drAttr_1.drForOf + "`.trim();\n for(const it of forOf) {\n var destIt = it;\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 if (forOf.isRange) {\n destIt = it;\n } else {\n destIt = forOfStr + '[' + i +']'\n }\n const n = this.__render.element.cloneNode(true);\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt)))\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\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 }\n " + ((_x = drAttr_1.drAfterOption) !== null && _x !== void 0 ? _x : '') + "\n ", Object.assign(obj, {
__render: Object.freeze({
rawset: _this,
drStripOption: drAttr.drStripOption,
range: Range.range,
drStripOption: drAttr_1.drStripOption,
fag: newTemp,

@@ -220,5 +272,27 @@ element: element_2,

(_y = element_2.parentNode) === null || _y === void 0 ? void 0 : _y.replaceChild(fag, element_2);
raws.push.apply(raws, rr);
raws.push.apply(raws, __spreadArray([], __read(rr), false));
}
(_z = config === null || config === void 0 ? void 0 : config.targetElements) === null || _z === void 0 ? void 0 : _z.forEach(function (it) {
if (drAttr_1.drRepeat) {
var itRandom = RawSet.drItOtherEncoding(element_2);
var vars = RawSet.drVarEncoding(element_2, (_z = drAttr_1.drVarOption) !== null && _z !== void 0 ? _z : '');
var newTemp = document.createElement('temp');
ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RANGE_VARNAME + " = this.__render.range;\n const " + RawSet.ELEMENT_VARNAME + " = this.__render.element;\n " + ((_0 = drAttr_1.drBeforeOption) !== null && _0 !== void 0 ? _0 : '') + "\n var i = 0; \n const repeat = " + drAttr_1.drRepeat + ";\n const repeatStr = `" + drAttr_1.drRepeat + "`;\n let range = repeat;\n if (typeof repeat === 'number') {\n range = " + RawSet.RANGE_VARNAME + "(repeat);\n } \n for(const it of range) {\n var destIt = it;\n if (range.isRange) {\n destIt = it;\n } else {\n destIt = repeatStr + '[' + i +']'\n }\n const n = this.__render.element.cloneNode(true);\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt)))\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 }\n " + ((_1 = drAttr_1.drAfterOption) !== null && _1 !== void 0 ? _1 : '') + "\n ", Object.assign(obj, {
__render: Object.freeze({
range: Range.range,
fag: newTemp,
drStripOption: drAttr_1.drStripOption,
element: element_2,
scripts: RawSet.setBindProperty(config === null || config === void 0 ? void 0 : config.scripts, obj)
})
}));
RawSet.drVarDecoding(newTemp, vars);
RawSet.drItOtherDecoding(newTemp, itRandom);
var tempalte = document.createElement('template');
tempalte.innerHTML = newTemp.innerHTML;
fag.append(tempalte.content);
var rr = RawSet.checkPointCreates(fag, config);
(_2 = element_2.parentNode) === null || _2 === void 0 ? void 0 : _2.replaceChild(fag, element_2);
raws.push.apply(raws, __spreadArray([], __read(rr), false));
}
(_3 = config === null || config === void 0 ? void 0 : config.targetElements) === null || _3 === void 0 ? void 0 : _3.forEach(function (it) {
var _a, _b;

@@ -236,3 +310,3 @@ var name = it.name;

}
raws.push.apply(raws, rr);
raws.push.apply(raws, __spreadArray([], __read(rr), false));
onElementInitCallBack.push({

@@ -246,3 +320,3 @@ name: name,

});
(_0 = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _0 === void 0 ? void 0 : _0.forEach(function (it) {
(_4 = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _4 === void 0 ? void 0 : _4.forEach(function (it) {
var _a, _b;

@@ -257,3 +331,3 @@ var attrName = it.name;

(_a = element_2.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(fag, element_2);
raws.push.apply(raws, rr);
raws.push.apply(raws, __spreadArray([], __read(rr), false));
onAttrInitCallBack.push({

@@ -385,3 +459,3 @@ attrName: attrName,

var regex = /#it#/g;
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "]").forEach(function (it) {
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "], [" + RawSet.DR_REPEAT_NAME + "]").forEach(function (it) {
it.innerHTML = it.innerHTML.replace(regex, random);

@@ -392,3 +466,3 @@ });

RawSet.drItOtherDecoding = function (element, random) {
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "]").forEach(function (it) {
element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "], [" + RawSet.DR_REPEAT_NAME + "]").forEach(function (it) {
it.innerHTML = it.innerHTML.replace(RegExp(random, 'g'), '#it#');

@@ -420,2 +494,24 @@ });

};
RawSet.drFormOtherMoveAttr = function (element, as, to) {
element.querySelectorAll("[" + RawSet.DR_FORM_NAME + "]").forEach(function (subElement) {
var _a;
var nodeIterator = document.createNodeIterator(subElement, NodeFilter.SHOW_ELEMENT, {
acceptNode: function (node) {
if (node.nodeType === Node.ELEMENT_NODE) {
var element_4 = node;
return element_4.hasAttribute(as) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
}
else {
return NodeFilter.FILTER_REJECT;
}
}
});
var node;
while (node = nodeIterator.nextNode()) {
var element_5 = node;
element_5.setAttribute(to, (_a = element_5.getAttribute(as)) !== null && _a !== void 0 ? _a : '');
element_5.removeAttribute(as);
}
});
};
RawSet.drVarEncoding = function (element, drVarOption) {

@@ -465,10 +561,20 @@ var _a;

RawSet.setBindProperty = function (scripts, obj) {
var e_1, _a;
if (scripts) {
var newScripts = Object.assign({}, scripts);
for (var _i = 0, _a = Object.entries(newScripts); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
if (typeof value === 'function') {
newScripts[key] = value.bind(obj);
try {
for (var _b = __values(Object.entries(newScripts)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
if (typeof value === 'function') {
newScripts[key] = value.bind(obj);
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
return newScripts;

@@ -525,3 +631,5 @@ }

RawSet.DR_FOR_NAME = 'dr-for';
RawSet.DR_REPEAT_NAME = 'dr-repeat';
RawSet.DR_THIS_NAME = 'dr-this';
RawSet.DR_FORM_NAME = 'dr-form';
RawSet.DR_INNERHTML_NAME = 'dr-inner-html';

@@ -536,8 +644,12 @@ RawSet.DR_INNERTEXT_NAME = 'dr-inner-text';

RawSet.DR_STRIP_OPTIONNAME = 'dr-strip';
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.DR_ATTRIBUTES = [RawSet.DR, RawSet.DR_IF_NAME, RawSet.DR_FOR_OF_NAME, RawSet.DR_FOR_NAME, RawSet.DR_THIS_NAME, RawSet.DR_FORM_NAME, RawSet.DR_INNERHTML_NAME, RawSet.DR_INNERTEXT_NAME, RawSet.DR_REPEAT_NAME];
RawSet.SCRIPTS_VARNAME = '$scripts';
RawSet.FAG_VARNAME = '$fag';
RawSet.RAWSET_VARNAME = '$rawset';
RawSet.RANGE_VARNAME = '$range';
RawSet.ELEMENT_VARNAME = '$element';
RawSet.TARGET_VARNAME = '$target';
RawSet.VARNAMES = [RawSet.SCRIPTS_VARNAME, RawSet.FAG_VARNAME, RawSet.RAWSET_VARNAME, RawSet.RANGE_VARNAME, RawSet.ELEMENT_VARNAME, RawSet.TARGET_VARNAME];
return RawSet;
}());
export { RawSet };

@@ -43,2 +43,3 @@ ![Single Page Application Framworks](assets/banner.png)

<div dr-for-of="this.friends"> ${#it#.name}</div>
<div dr-for-of="$range(10, 20)"><div>${#it#}</div><div>
<div dr-for="var i = 1 ; i <= 9 ; i++" dr-it="i">

@@ -52,2 +53,10 @@ ${#it#} *

## dr-repeat
```html
<div dr-repeat="10"><div>#it#</div></div>
<div dr-repeat="$range(10, 20)"><div>#it#</div></div>
<div dr-repeat="$range(10, 20, 5)"><div>#it#</div></div>
<div dr-repeat="$range('10..5, 2')"><div>#it#</div></div>
```
## dr-inner-text, dr-inner-html

@@ -210,2 +219,23 @@ ```html

# dr-form
- event: change
- modify change: dr-form:event="input"
```typescript
class User {
form = {};
submit() {
const form = (this.form as any)
console.log('submit->', form, form.name, form.age, form.addr);
}
}
```
```html
<form dr-form="this.form" dr-event-submit="this.submit(); $event.preventDefault();">
name: <input name="name">
age: <input name="age">
addr: <input dr-form:event="input" name="addr">
<button type="submit"> aa</button>
</form>
```
# validation

@@ -212,0 +242,0 @@ ```html

@@ -0,1 +1,28 @@

var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var ScriptUtils = (function () {

@@ -44,9 +71,19 @@ function ScriptUtils() {

return new Promise(function (resolve, reject) {
var e_1, _a;
var tag = document.createElement(name);
tag.onload = resolve;
tag.onerror = reject;
for (var _i = 0, _a = Object.entries(attribute); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
tag.setAttribute(key, value);
try {
for (var _b = __values(Object.entries(attribute)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
tag.setAttribute(key, value);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
target.append(tag);

@@ -53,0 +90,0 @@ });

export declare abstract class Validation {
value: string;
value?: string;
constructor(value?: string);
abstract valid(): boolean;
childValid(): boolean;
childInValid(): boolean;
valids(): boolean;
inValids(): boolean;
get length(): number;
[name: string]: Validation | string | undefined | Element | any;
}

@@ -0,11 +1,42 @@

var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var Validation = (function () {
function Validation() {
this.value = '';
function Validation(value) {
this.value = value;
}
Validation.prototype.childValid = function () {
return !this.childInValid();
Validation.prototype.valids = function () {
return !this.inValids();
};
Validation.prototype.childInValid = function () {
Validation.prototype.inValids = function () {
var inValid = Object.entries(this).filter(function (_a) {
var k = _a[0], v = _a[1];
var _b = __read(_a, 2), k = _b[0], v = _b[1];
return (v instanceof Validation) && !v.valid();

@@ -26,1 +57,12 @@ });

export { Validation };
var a = new (function (_super) {
__extends(class_1, _super);
function class_1() {
return _super !== null && _super.apply(this, arguments) || this;
}
class_1.prototype.valid = function () {
return false;
};
return class_1;
}(Validation))('a');
console.log('--', a);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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