dom-render 1.0.90 → 1.0.92
Sign up to get free protection for your applications and to get access to all the features.
- package/DomRender.js +5 -1
- package/DomRenderProxy.d.ts +1 -1
- package/DomRenderProxy.js +121 -63
- package/README.MD +15 -3
- package/components/ComponentSet.d.ts +5 -2
- package/components/ComponentSet.js +2 -3
- package/configs/Config.d.ts +5 -0
- package/configs/TargetElement.d.ts +1 -1
- package/dist/bundle.js +1337 -968
- package/events/EventManager.js +1 -0
- package/operators/Dr.d.ts +7 -3
- package/operators/Dr.js +64 -25
- package/operators/DrAppender.d.ts +7 -3
- package/operators/DrAppender.js +70 -28
- package/operators/DrFor.d.ts +7 -3
- package/operators/DrFor.js +67 -25
- package/operators/DrForOf.d.ts +7 -3
- package/operators/DrForOf.js +70 -28
- package/operators/DrForm.d.ts +7 -3
- package/operators/DrForm.js +93 -55
- package/operators/DrIf.d.ts +7 -3
- package/operators/DrIf.js +71 -35
- package/operators/DrInnerHTML.d.ts +7 -3
- package/operators/DrInnerHTML.js +62 -23
- package/operators/DrInnerText.d.ts +7 -3
- package/operators/DrInnerText.js +60 -21
- package/operators/DrPre.d.ts +6 -3
- package/operators/DrPre.js +49 -6
- package/operators/DrRepeat.d.ts +7 -3
- package/operators/DrRepeat.js +67 -25
- package/operators/DrTargetAttr.d.ts +6 -3
- package/operators/DrTargetAttr.js +72 -29
- package/operators/DrTargetElement.d.ts +6 -3
- package/operators/DrTargetElement.js +86 -64
- package/operators/DrThis.d.ts +4 -3
- package/operators/DrThis.js +77 -33
- package/operators/OperatorExecuter.d.ts +49 -0
- package/operators/OperatorExecuter.js +89 -0
- package/operators/OperatorExecuterAttrRequire.d.ts +8 -0
- package/operators/OperatorExecuterAttrRequire.js +79 -0
- package/package.json +1 -1
- package/rawsets/RawSet.d.ts +4 -4
- package/rawsets/RawSet.js +460 -317
- package/routers/HashRouter.js +1 -1
- package/routers/PathRouter.js +1 -1
- package/routers/Router.d.ts +3 -0
- package/routers/Router.js +10 -0
- package/operators/OperatorRender.d.ts +0 -45
- package/operators/OperatorRender.js +0 -21
package/operators/DrPre.js
CHANGED
@@ -14,17 +14,60 @@ var __extends = (this && this.__extends) || (function () {
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
15
|
};
|
16
16
|
})();
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
24
|
+
});
|
25
|
+
};
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
30
|
+
function step(op) {
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
32
|
+
while (_) try {
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
35
|
+
switch (op[0]) {
|
36
|
+
case 0: case 1: t = op; break;
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
40
|
+
default:
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
45
|
+
if (t[2]) _.ops.pop();
|
46
|
+
_.trys.pop(); continue;
|
47
|
+
}
|
48
|
+
op = body.call(thisArg, _);
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
51
|
+
}
|
52
|
+
};
|
17
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
18
54
|
exports.DrPre = void 0;
|
19
|
-
var
|
55
|
+
var OperatorExecuter_1 = require("./OperatorExecuter");
|
20
56
|
var DrPre = /** @class */ (function (_super) {
|
21
57
|
__extends(DrPre, _super);
|
22
|
-
function DrPre() {
|
23
|
-
|
58
|
+
function DrPre(rawSet, render, returnContainer, elementSource, source, afterCallBack) {
|
59
|
+
var _this = this;
|
60
|
+
source.operatorAround = undefined;
|
61
|
+
_this = _super.call(this, rawSet, render, returnContainer, elementSource, source, afterCallBack) || this;
|
62
|
+
return _this;
|
24
63
|
}
|
25
|
-
DrPre.prototype.
|
26
|
-
return (this
|
64
|
+
DrPre.prototype.execute = function (value) {
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
66
|
+
return __generator(this, function (_a) {
|
67
|
+
return [2 /*return*/, (value != null) ? OperatorExecuter_1.ExecuteState.EXECUTE : OperatorExecuter_1.ExecuteState.NO_EXECUTE];
|
68
|
+
});
|
69
|
+
});
|
27
70
|
};
|
28
71
|
return DrPre;
|
29
|
-
}(
|
72
|
+
}(OperatorExecuter_1.OperatorExecuter));
|
30
73
|
exports.DrPre = DrPre;
|
package/operators/DrRepeat.d.ts
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import { OperatorExecuterAttrRequire } from './OperatorExecuterAttrRequire';
|
2
|
+
import { RawSet } from '../rawsets/RawSet';
|
3
|
+
import { Render } from '../rawsets/Render';
|
4
|
+
import { AfterCallBack, ElementSource, ExecuteState, ReturnContainer, Source } from './OperatorExecuter';
|
5
|
+
export declare class DrRepeat extends OperatorExecuterAttrRequire<string> {
|
6
|
+
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
7
|
+
executeAttrRequire(attr: string): Promise<ExecuteState>;
|
4
8
|
}
|
package/operators/DrRepeat.js
CHANGED
@@ -25,39 +25,81 @@ var __assign = (this && this.__assign) || function () {
|
|
25
25
|
};
|
26
26
|
return __assign.apply(this, arguments);
|
27
27
|
};
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
35
|
+
});
|
36
|
+
};
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
41
|
+
function step(op) {
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
43
|
+
while (_) try {
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
46
|
+
switch (op[0]) {
|
47
|
+
case 0: case 1: t = op; break;
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
51
|
+
default:
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
56
|
+
if (t[2]) _.ops.pop();
|
57
|
+
_.trys.pop(); continue;
|
58
|
+
}
|
59
|
+
op = body.call(thisArg, _);
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
62
|
+
}
|
63
|
+
};
|
28
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
65
|
exports.DrRepeat = void 0;
|
30
|
-
var
|
66
|
+
var OperatorExecuterAttrRequire_1 = require("./OperatorExecuterAttrRequire");
|
31
67
|
var ScriptUtils_1 = require("../utils/script/ScriptUtils");
|
32
68
|
var RawSet_1 = require("../rawsets/RawSet");
|
33
69
|
var EventManager_1 = require("../events/EventManager");
|
70
|
+
var OperatorExecuter_1 = require("./OperatorExecuter");
|
34
71
|
var DrRepeat = /** @class */ (function (_super) {
|
35
72
|
__extends(DrRepeat, _super);
|
36
|
-
function DrRepeat() {
|
37
|
-
|
73
|
+
function DrRepeat(rawSet, render, returnContainer, elementSource, source, afterCallBack) {
|
74
|
+
var _this = this;
|
75
|
+
source.operatorAround = undefined;
|
76
|
+
_this = _super.call(this, rawSet, render, returnContainer, elementSource, source, afterCallBack, false) || this;
|
77
|
+
return _this;
|
38
78
|
}
|
39
|
-
DrRepeat.prototype.
|
40
|
-
var _a;
|
41
|
-
|
42
|
-
|
43
|
-
var
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
79
|
+
DrRepeat.prototype.executeAttrRequire = function (attr) {
|
80
|
+
var _a, _b, _c, _d;
|
81
|
+
return __awaiter(this, void 0, void 0, function () {
|
82
|
+
var itRandom, vars, newTemp, tempalte, rr;
|
83
|
+
var _e;
|
84
|
+
return __generator(this, function (_f) {
|
85
|
+
itRandom = RawSet_1.RawSet.drItOtherEncoding(this.elementSource.element);
|
86
|
+
vars = RawSet_1.RawSet.drVarEncoding(this.elementSource.element, (_a = this.elementSource.attrs.drVarOption) !== null && _a !== void 0 ? _a : '');
|
87
|
+
newTemp = this.source.config.window.document.createElement('temp');
|
88
|
+
ScriptUtils_1.ScriptUtils.eval("\n ".concat(this.render.bindScript, "\n ").concat((_b = this.elementSource.attrs.drBeforeOption) !== null && _b !== void 0 ? _b : '', "\n var i = 0; \n const repeat = ").concat(attr, ";\n const repeatStr = `").concat(attr, "`;\n let range = repeat;\n if (typeof repeat === 'number') {\n range = ").concat(EventManager_1.EventManager.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).replace(/\\#nearRangeIt\\#/g, destIt).replace(/\\#nearRangeIndex\\#/g, destIt)))\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt).replace(/\\#index\\#/g, destIt);\n \n if (this.__render.drStripOption === 'true') {\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 ").concat((_c = this.elementSource.attrs.drAfterOption) !== null && _c !== void 0 ? _c : '', "\n "), Object.assign(this.source.obj, {
|
89
|
+
__render: Object.freeze(__assign({ fag: newTemp, drStripOption: this.elementSource.attrs.drStripOption }, this.render))
|
90
|
+
}));
|
91
|
+
RawSet_1.RawSet.drVarDecoding(newTemp, vars);
|
92
|
+
RawSet_1.RawSet.drItOtherDecoding(newTemp, itRandom);
|
93
|
+
tempalte = this.source.config.window.document.createElement('template');
|
94
|
+
tempalte.innerHTML = newTemp.innerHTML;
|
95
|
+
this.returnContainer.fag.append(tempalte.content);
|
96
|
+
rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
|
97
|
+
(_d = this.elementSource.element.parentNode) === null || _d === void 0 ? void 0 : _d.replaceChild(this.returnContainer.fag, this.elementSource.element);
|
98
|
+
(_e = this.returnContainer.raws).push.apply(_e, rr);
|
99
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.EXECUTE];
|
100
|
+
});
|
101
|
+
});
|
60
102
|
};
|
61
103
|
return DrRepeat;
|
62
|
-
}(
|
104
|
+
}(OperatorExecuterAttrRequire_1.OperatorExecuterAttrRequire));
|
63
105
|
exports.DrRepeat = DrRepeat;
|
@@ -1,4 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import { RawSet } from '../rawsets/RawSet';
|
2
|
+
import { AfterCallBack, ElementSource, ExecuteState, OperatorExecuter, ReturnContainer, Source } from './OperatorExecuter';
|
3
|
+
import { Render } from '../rawsets/Render';
|
4
|
+
export declare class DrTargetAttr extends OperatorExecuter<void> {
|
5
|
+
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
6
|
+
execute(): Promise<ExecuteState>;
|
4
7
|
}
|
@@ -14,42 +14,85 @@ var __extends = (this && this.__extends) || (function () {
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
15
|
};
|
16
16
|
})();
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
24
|
+
});
|
25
|
+
};
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
30
|
+
function step(op) {
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
32
|
+
while (_) try {
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
35
|
+
switch (op[0]) {
|
36
|
+
case 0: case 1: t = op; break;
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
40
|
+
default:
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
45
|
+
if (t[2]) _.ops.pop();
|
46
|
+
_.trys.pop(); continue;
|
47
|
+
}
|
48
|
+
op = body.call(thisArg, _);
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
51
|
+
}
|
52
|
+
};
|
17
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
18
54
|
exports.DrTargetAttr = void 0;
|
19
|
-
var OperatorRender_1 = require("./OperatorRender");
|
20
55
|
var RawSet_1 = require("../rawsets/RawSet");
|
56
|
+
var OperatorExecuter_1 = require("./OperatorExecuter");
|
21
57
|
var DrTargetAttr = /** @class */ (function (_super) {
|
22
58
|
__extends(DrTargetAttr, _super);
|
23
|
-
function DrTargetAttr() {
|
24
|
-
|
59
|
+
function DrTargetAttr(rawSet, render, returnContainer, elementSource, source, afterCallBack) {
|
60
|
+
var _this = this;
|
61
|
+
source.operatorAround = undefined;
|
62
|
+
_this = _super.call(this, rawSet, render, returnContainer, elementSource, source, afterCallBack, false) || this;
|
63
|
+
return _this;
|
25
64
|
}
|
26
|
-
DrTargetAttr.prototype.
|
27
|
-
var _a;
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
65
|
+
DrTargetAttr.prototype.execute = function () {
|
66
|
+
var _a, _b, _c, _d;
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
68
|
+
var attributeNames, targetAttr, attrName, attrValue, documentFragment, rr;
|
69
|
+
var _e;
|
70
|
+
return __generator(this, function (_f) {
|
71
|
+
attributeNames = this.elementSource.element.getAttributeNames();
|
72
|
+
targetAttr = (_b = (_a = this.source.config) === null || _a === void 0 ? void 0 : _a.targetAttrs) === null || _b === void 0 ? void 0 : _b.find(function (it) { return attributeNames.includes(it.name); });
|
73
|
+
if (targetAttr) {
|
74
|
+
attrName = targetAttr.name;
|
75
|
+
attrValue = this.rawSet.getAttributeAndDelete(this.elementSource.element, attrName);
|
76
|
+
if (attrValue && attrName && (!this.elementSource.attrs.drForOf && !this.elementSource.attrs.drFor && !this.elementSource.attrs.drRepeat)) {
|
77
|
+
documentFragment = targetAttr.callBack(this.elementSource.element, attrValue, this.source.obj, this.rawSet);
|
78
|
+
if (documentFragment) {
|
79
|
+
rr = RawSet_1.RawSet.checkPointCreates(documentFragment, this.source.obj, this.source.config);
|
80
|
+
(_c = this.elementSource.element.parentNode) === null || _c === void 0 ? void 0 : _c.replaceChild(documentFragment, this.elementSource.element);
|
81
|
+
(_e = this.returnContainer.raws).push.apply(_e, rr);
|
82
|
+
this.afterCallBack.onAttrInitCallBacks.push({
|
83
|
+
attrName: attrName,
|
84
|
+
attrValue: attrValue,
|
85
|
+
obj: this.source.obj
|
86
|
+
});
|
87
|
+
(_d = targetAttr === null || targetAttr === void 0 ? void 0 : targetAttr.complete) === null || _d === void 0 ? void 0 : _d.call(targetAttr, this.elementSource.element, attrValue, this.source.obj, this.rawSet);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.EXECUTE];
|
47
91
|
}
|
48
|
-
|
49
|
-
|
50
|
-
}
|
51
|
-
return OperatorRender_1.ExecuteState.NO_EXECUTE;
|
92
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.NO_EXECUTE];
|
93
|
+
});
|
94
|
+
});
|
52
95
|
};
|
53
96
|
return DrTargetAttr;
|
54
|
-
}(
|
97
|
+
}(OperatorExecuter_1.OperatorExecuter));
|
55
98
|
exports.DrTargetAttr = DrTargetAttr;
|
@@ -1,4 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import { RawSet } from '../rawsets/RawSet';
|
2
|
+
import { AfterCallBack, ElementSource, ExecuteState, OperatorExecuter, ReturnContainer, Source } from './OperatorExecuter';
|
3
|
+
import { Render } from '../rawsets/Render';
|
4
|
+
export declare class DrTargetElement extends OperatorExecuter<void> {
|
5
|
+
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
6
|
+
execute(): Promise<ExecuteState>;
|
4
7
|
}
|
@@ -14,79 +14,101 @@ var __extends = (this && this.__extends) || (function () {
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
15
|
};
|
16
16
|
})();
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
24
|
+
});
|
25
|
+
};
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
30
|
+
function step(op) {
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
32
|
+
while (_) try {
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
35
|
+
switch (op[0]) {
|
36
|
+
case 0: case 1: t = op; break;
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
40
|
+
default:
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
45
|
+
if (t[2]) _.ops.pop();
|
46
|
+
_.trys.pop(); continue;
|
47
|
+
}
|
48
|
+
op = body.call(thisArg, _);
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
51
|
+
}
|
52
|
+
};
|
17
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
18
54
|
exports.DrTargetElement = void 0;
|
19
|
-
var OperatorRender_1 = require("./OperatorRender");
|
20
55
|
var ScriptUtils_1 = require("../utils/script/ScriptUtils");
|
21
56
|
var RawSet_1 = require("../rawsets/RawSet");
|
57
|
+
var OperatorExecuter_1 = require("./OperatorExecuter");
|
22
58
|
var DrTargetElement = /** @class */ (function (_super) {
|
23
59
|
__extends(DrTargetElement, _super);
|
24
|
-
function DrTargetElement() {
|
25
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
26
|
-
}
|
27
|
-
DrTargetElement.prototype.execRender = function () {
|
28
|
-
var _a;
|
60
|
+
function DrTargetElement(rawSet, render, returnContainer, elementSource, source, afterCallBack) {
|
29
61
|
var _this = this;
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
62
|
+
source.operatorAround = undefined;
|
63
|
+
_this = _super.call(this, rawSet, render, returnContainer, elementSource, source, afterCallBack, false) || this;
|
64
|
+
return _this;
|
65
|
+
}
|
66
|
+
DrTargetElement.prototype.execute = function () {
|
67
|
+
var _a, _b, _c, _d;
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
69
|
+
var targetElement, documentFragment, detectAction_1, render_1, rr;
|
70
|
+
var _e;
|
71
|
+
var _this = this;
|
72
|
+
return __generator(this, function (_f) {
|
73
|
+
switch (_f.label) {
|
74
|
+
case 0:
|
75
|
+
targetElement = (_b = (_a = this.source.config) === null || _a === void 0 ? void 0 : _a.targetElements) === null || _b === void 0 ? void 0 : _b.find(function (it) { return it.name.toLowerCase() === _this.elementSource.element.tagName.toLowerCase(); });
|
76
|
+
if (!targetElement) return [3 /*break*/, 2];
|
77
|
+
return [4 /*yield*/, targetElement.callBack(this.elementSource.element, this.source.obj, this.rawSet, this.elementSource.attrs, this.source.config)];
|
78
|
+
case 1:
|
79
|
+
documentFragment = _f.sent();
|
80
|
+
if (documentFragment) {
|
81
|
+
detectAction_1 = this.elementSource.element.getAttribute(RawSet_1.RawSet.DR_DETECT_NAME);
|
82
|
+
render_1 = documentFragment.render;
|
83
|
+
this.rawSet.fragment = documentFragment;
|
84
|
+
this.rawSet.data = render_1.component;
|
85
|
+
if (detectAction_1 && render_1) {
|
86
|
+
this.rawSet.detect = {
|
87
|
+
action: function () {
|
88
|
+
var script = "var $component = this.__render.component; var $element = this.__render.element; var $innerHTML = this.__render.innerHTML; var $attribute = this.__render.attribute; ".concat(detectAction_1, " ");
|
89
|
+
ScriptUtils_1.ScriptUtils.eval(script, Object.assign(_this.source.obj, {
|
90
|
+
__render: render_1
|
91
|
+
}));
|
92
|
+
}
|
93
|
+
};
|
94
|
+
}
|
95
|
+
rr = RawSet_1.RawSet.checkPointCreates(documentFragment, this.source.obj, this.source.config);
|
96
|
+
(_c = this.elementSource.element.parentNode) === null || _c === void 0 ? void 0 : _c.replaceChild(documentFragment, this.elementSource.element);
|
97
|
+
(_e = this.returnContainer.raws).push.apply(_e, rr);
|
98
|
+
this.afterCallBack.onElementInitCallBacks.push({
|
99
|
+
name: targetElement.name.toLowerCase(),
|
100
|
+
obj: this.source.obj,
|
101
|
+
targetElement: targetElement,
|
102
|
+
creatorMetaData: targetElement.__creatorMetaData
|
103
|
+
});
|
104
|
+
(_d = targetElement === null || targetElement === void 0 ? void 0 : targetElement.complete) === null || _d === void 0 ? void 0 : _d.call(targetElement, this.elementSource.element, this.source.obj, this.rawSet);
|
70
105
|
}
|
71
|
-
|
106
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.EXECUTE];
|
107
|
+
case 2: return [2 /*return*/, OperatorExecuter_1.ExecuteState.NO_EXECUTE];
|
72
108
|
}
|
73
|
-
|
74
|
-
|
75
|
-
(_d = this.elementSource.element.parentNode) === null || _d === void 0 ? void 0 : _d.replaceChild(documentFragment, this.elementSource.element);
|
76
|
-
(_a = this.returnContainer.raws).push.apply(_a, rr);
|
77
|
-
this.afterCallBack.onElementInitCallBacks.push({
|
78
|
-
name: targetElement.name.toLowerCase(),
|
79
|
-
obj: this.source.obj,
|
80
|
-
targetElement: targetElement,
|
81
|
-
creatorMetaData: targetElement.__creatorMetaData
|
82
|
-
});
|
83
|
-
// console.log(document.body.innerHTML);
|
84
|
-
(_e = targetElement === null || targetElement === void 0 ? void 0 : targetElement.complete) === null || _e === void 0 ? void 0 : _e.call(targetElement, this.elementSource.element, this.source.obj, this.rawSet);
|
85
|
-
}
|
86
|
-
return OperatorRender_1.ExecuteState.EXECUTE;
|
87
|
-
}
|
88
|
-
return OperatorRender_1.ExecuteState.NO_EXECUTE;
|
109
|
+
});
|
110
|
+
});
|
89
111
|
};
|
90
112
|
return DrTargetElement;
|
91
|
-
}(
|
113
|
+
}(OperatorExecuter_1.OperatorExecuter));
|
92
114
|
exports.DrTargetElement = DrTargetElement;
|
package/operators/DrThis.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import { OperatorExecuterAttrRequire } from './OperatorExecuterAttrRequire';
|
2
|
+
import { ExecuteState } from './OperatorExecuter';
|
3
|
+
export declare class DrThis extends OperatorExecuterAttrRequire<string> {
|
4
|
+
executeAttrRequire(attr: any): Promise<ExecuteState>;
|
4
5
|
}
|