vsn 0.1.123 → 0.1.125
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo/demo.html +4 -1
- package/demo/examples/cascading-function-sheets.html +28 -0
- package/demo/resources/xhr-animations.html +24 -0
- package/demo/resources/xhr-cfs.html +1 -0
- package/demo/resources/xhr-lazy.html +10 -1
- package/demo/service.html +3 -3
- package/demo/silly-animations.html +12 -24
- package/demo/vsn.js +2 -2
- package/dist/AST/ArrayNode.js +70 -18
- package/dist/AST/ArrayNode.js.map +1 -1
- package/dist/AST/AssignmentNode.js +92 -35
- package/dist/AST/AssignmentNode.js.map +1 -1
- package/dist/AST/BlockNode.js +17 -1
- package/dist/AST/BlockNode.js.map +1 -1
- package/dist/AST/ClassNode.js +231 -90
- package/dist/AST/ClassNode.js.map +1 -1
- package/dist/AST/DispatchEventNode.d.ts +3 -1
- package/dist/AST/DispatchEventNode.js +48 -14
- package/dist/AST/DispatchEventNode.js.map +1 -1
- package/dist/AST/ElementAttributeNode.js +55 -29
- package/dist/AST/ElementAttributeNode.js.map +1 -1
- package/dist/AST/ElementStyleNode.js +48 -22
- package/dist/AST/ElementStyleNode.js.map +1 -1
- package/dist/AST/FunctionArgumentNode.js +57 -15
- package/dist/AST/FunctionArgumentNode.js.map +1 -1
- package/dist/AST/FunctionCallNode.js +120 -52
- package/dist/AST/FunctionCallNode.js.map +1 -1
- package/dist/AST/FunctionNode.js +57 -14
- package/dist/AST/FunctionNode.js.map +1 -1
- package/dist/AST/IfStatementNode.js +52 -12
- package/dist/AST/IfStatementNode.js.map +1 -1
- package/dist/AST/IndexNode.js +24 -3
- package/dist/AST/IndexNode.js.map +1 -1
- package/dist/AST/ModifierNode.js +1 -1
- package/dist/AST/ModifierNode.js.map +1 -1
- package/dist/AST/Node.d.ts +3 -2
- package/dist/AST/Node.js +132 -39
- package/dist/AST/Node.js.map +1 -1
- package/dist/AST/ObjectNode.js +17 -1
- package/dist/AST/ObjectNode.js.map +1 -1
- package/dist/AST/OnNode.js +23 -2
- package/dist/AST/OnNode.js.map +1 -1
- package/dist/AST/ScopeMemberNode.js +44 -16
- package/dist/AST/ScopeMemberNode.js.map +1 -1
- package/dist/AST/ScopeNodeAbstract.js +29 -8
- package/dist/AST/ScopeNodeAbstract.js.map +1 -1
- package/dist/AST/StringFormatNode.js +42 -5
- package/dist/AST/StringFormatNode.js.map +1 -1
- package/dist/AST/WASM/Function.js +20 -4
- package/dist/AST/WASM/Function.js.map +1 -1
- package/dist/AST/WASM.js +26 -10
- package/dist/AST/WASM.js.map +1 -1
- package/dist/AST/WithNode.js +81 -41
- package/dist/AST/WithNode.js.map +1 -1
- package/dist/AST.js +91 -37
- package/dist/AST.js.map +1 -1
- package/dist/Attribute.d.ts +3 -0
- package/dist/Attribute.js +43 -19
- package/dist/Attribute.js.map +1 -1
- package/dist/Bencmark.js +77 -20
- package/dist/Bencmark.js.map +1 -1
- package/dist/Component.js +49 -15
- package/dist/Component.js.map +1 -1
- package/dist/DOM/DOMObject.d.ts +6 -1
- package/dist/DOM/DOMObject.js +22 -1
- package/dist/DOM/DOMObject.js.map +1 -1
- package/dist/DOM.js +450 -193
- package/dist/DOM.js.map +1 -1
- package/dist/EventDispatcher.js +153 -39
- package/dist/EventDispatcher.js.map +1 -1
- package/dist/MessageList.js +37 -6
- package/dist/MessageList.js.map +1 -1
- package/dist/Model.js +27 -6
- package/dist/Model.js.map +1 -1
- package/dist/Modifiers.d.ts +17 -0
- package/dist/Modifiers.js +100 -0
- package/dist/Modifiers.js.map +1 -0
- package/dist/Scope/DynamicScopeData.js +38 -7
- package/dist/Scope/DynamicScopeData.js.map +1 -1
- package/dist/Scope/ObjectAccessor.d.ts +7 -0
- package/dist/Scope/ObjectAccessor.js +40 -0
- package/dist/Scope/ObjectAccessor.js.map +1 -0
- package/dist/Scope/ScopeAbstract.d.ts +9 -0
- package/dist/Scope/ScopeAbstract.js +28 -0
- package/dist/Scope/ScopeAbstract.js.map +1 -0
- package/dist/Scope/ScopeData.js +29 -8
- package/dist/Scope/ScopeData.js.map +1 -1
- package/dist/Scope/ScopeDataAbstract.js +103 -27
- package/dist/Scope/ScopeDataAbstract.js.map +1 -1
- package/dist/Scope/WrappedArray.js +112 -26
- package/dist/Scope/WrappedArray.js.map +1 -1
- package/dist/Scope/properties/ArrayProperty.js +17 -1
- package/dist/Scope/properties/ArrayProperty.js.map +1 -1
- package/dist/Scope/properties/Property.js +38 -7
- package/dist/Scope/properties/Property.js.map +1 -1
- package/dist/Scope.d.ts +3 -2
- package/dist/Scope.js +98 -14
- package/dist/Scope.js.map +1 -1
- package/dist/SimplePromise.js +71 -30
- package/dist/SimplePromise.js.map +1 -1
- package/dist/Tag/TagList.js +22 -1
- package/dist/Tag/TagList.js.map +1 -1
- package/dist/Tag.d.ts +5 -9
- package/dist/Tag.js +512 -195
- package/dist/Tag.js.map +1 -1
- package/dist/attributes/KeyAbstract.js +1 -1
- package/dist/attributes/KeyAbstract.js.map +1 -1
- package/dist/attributes/KeyDown.js +1 -1
- package/dist/attributes/KeyDown.js.map +1 -1
- package/dist/attributes/KeyUp.js +1 -1
- package/dist/attributes/KeyUp.js.map +1 -1
- package/dist/attributes/LazyAttribute.js +4 -2
- package/dist/attributes/LazyAttribute.js.map +1 -1
- package/dist/attributes/List.js +77 -30
- package/dist/attributes/List.js.map +1 -1
- package/dist/attributes/On.d.ts +1 -1
- package/dist/attributes/On.js +10 -10
- package/dist/attributes/On.js.map +1 -1
- package/dist/attributes/RootAttribute.js +29 -8
- package/dist/attributes/RootAttribute.js.map +1 -1
- package/dist/attributes/ScopeAttribute.js +30 -9
- package/dist/attributes/ScopeAttribute.js.map +1 -1
- package/dist/attributes/SetAttribute.js +32 -11
- package/dist/attributes/SetAttribute.js.map +1 -1
- package/dist/attributes/StyleAttribute.js +27 -6
- package/dist/attributes/StyleAttribute.js.map +1 -1
- package/dist/attributes/XHRAttribute.js +28 -7
- package/dist/attributes/XHRAttribute.js.map +1 -1
- package/dist/helpers/ElementHelper.js +25 -4
- package/dist/helpers/ElementHelper.js.map +1 -1
- package/dist/helpers/decorators.js +22 -1
- package/dist/helpers/decorators.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/vsn.js +1 -2
- package/dist/vsn.js.map +1 -1
- package/package.json +1 -1
- package/src/AST/ClassNode.ts +6 -3
- package/src/AST/DispatchEventNode.ts +19 -11
- package/src/AST/FunctionNode.ts +2 -0
- package/src/AST/ModifierNode.ts +1 -1
- package/src/AST/Node.ts +10 -5
- package/src/AST/OnNode.ts +1 -1
- package/src/AST/ScopeMemberNode.ts +4 -0
- package/src/AST/ScopeNodeAbstract.ts +3 -3
- package/src/AST.ts +1 -1
- package/src/Attribute.ts +19 -8
- package/src/DOM/DOMObject.ts +4 -1
- package/src/Modifiers.ts +54 -0
- package/src/Scope/ObjectAccessor.ts +21 -0
- package/src/Scope/ScopeAbstract.ts +11 -0
- package/src/Scope.ts +14 -1
- package/src/Tag.ts +66 -37
- package/src/attributes/KeyAbstract.ts +1 -1
- package/src/attributes/KeyDown.ts +1 -1
- package/src/attributes/KeyUp.ts +1 -1
- package/src/attributes/LazyAttribute.ts +6 -2
- package/src/attributes/On.ts +10 -9
- package/src/attributes/XHRAttribute.ts +2 -2
- package/src/version.ts +1 -1
- package/src/vsn.ts +1 -2
- package/test/AST/ClassNode.spec.ts +22 -0
- package/tsconfig.base.json +2 -1
package/dist/Tag.js
CHANGED
|
@@ -50,6 +50,33 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
+
var __values = (this && this.__values) || function(o) {
|
|
54
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
55
|
+
if (m) return m.call(o);
|
|
56
|
+
if (o && typeof o.length === "number") return {
|
|
57
|
+
next: function () {
|
|
58
|
+
if (o && i >= o.length) o = void 0;
|
|
59
|
+
return { value: o && o[i++], done: !o };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
63
|
+
};
|
|
64
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
65
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
66
|
+
if (!m) return o;
|
|
67
|
+
var i = m.call(o), r, ar = [], e;
|
|
68
|
+
try {
|
|
69
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
70
|
+
}
|
|
71
|
+
catch (error) { e = { error: error }; }
|
|
72
|
+
finally {
|
|
73
|
+
try {
|
|
74
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
75
|
+
}
|
|
76
|
+
finally { if (e) throw e.error; }
|
|
77
|
+
}
|
|
78
|
+
return ar;
|
|
79
|
+
};
|
|
53
80
|
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
54
81
|
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
55
82
|
to[j] = from[i];
|
|
@@ -68,6 +95,7 @@ var Registry_1 = require("./Registry");
|
|
|
68
95
|
var DOMObject_1 = require("./DOM/DOMObject");
|
|
69
96
|
var AST_1 = require("./AST");
|
|
70
97
|
var StyleAttribute_1 = require("./attributes/StyleAttribute");
|
|
98
|
+
var Modifiers_1 = require("./Modifiers");
|
|
71
99
|
var TagState;
|
|
72
100
|
(function (TagState) {
|
|
73
101
|
TagState[TagState["Instantiated"] = 0] = "Instantiated";
|
|
@@ -88,6 +116,7 @@ var Tag = /** @class */ (function (_super) {
|
|
|
88
116
|
var _this = _super.call(this, element, props) || this;
|
|
89
117
|
_this.dom = dom;
|
|
90
118
|
_this.deferredAttributes = [];
|
|
119
|
+
_this.attributes = new Map();
|
|
91
120
|
_this._nonDeferredAttributes = [];
|
|
92
121
|
_this._children = [];
|
|
93
122
|
_this.inputTags = [
|
|
@@ -98,8 +127,6 @@ var Tag = /** @class */ (function (_super) {
|
|
|
98
127
|
element[Tag.TaggedVariable] = _this;
|
|
99
128
|
_this.rawAttributes = {};
|
|
100
129
|
_this.parsedAttributes = {};
|
|
101
|
-
_this.attributes = [];
|
|
102
|
-
_this.attributeMap = {};
|
|
103
130
|
_this.onEventHandlers = {};
|
|
104
131
|
_this.analyzeElementAttributes();
|
|
105
132
|
_this._state = TagState.Instantiated;
|
|
@@ -127,13 +154,44 @@ var Tag = /** @class */ (function (_super) {
|
|
|
127
154
|
this._nonDeferredAttributes.length = 0;
|
|
128
155
|
};
|
|
129
156
|
Tag.prototype.getAttributesWithState = function (state) {
|
|
130
|
-
|
|
157
|
+
var e_1, _a;
|
|
158
|
+
var attrs = [];
|
|
159
|
+
try {
|
|
160
|
+
for (var _b = __values(this.attributes.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
161
|
+
var attr = _c.value;
|
|
162
|
+
if (attr.state === state)
|
|
163
|
+
attrs.push(attr);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
167
|
+
finally {
|
|
168
|
+
try {
|
|
169
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
170
|
+
}
|
|
171
|
+
finally { if (e_1) throw e_1.error; }
|
|
172
|
+
}
|
|
173
|
+
return attrs;
|
|
131
174
|
};
|
|
132
175
|
Object.defineProperty(Tag.prototype, "nonDeferredAttributes", {
|
|
133
176
|
get: function () {
|
|
177
|
+
var e_2, _a;
|
|
134
178
|
if (this._nonDeferredAttributes.length > 0)
|
|
135
179
|
return this._nonDeferredAttributes;
|
|
136
|
-
var attrs =
|
|
180
|
+
var attrs = [];
|
|
181
|
+
try {
|
|
182
|
+
for (var _b = __values(this.attributes.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
183
|
+
var attr = _c.value;
|
|
184
|
+
if (attr.state !== Attribute_1.AttributeState.Deferred)
|
|
185
|
+
attrs.push(attr);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
189
|
+
finally {
|
|
190
|
+
try {
|
|
191
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
192
|
+
}
|
|
193
|
+
finally { if (e_2) throw e_2.error; }
|
|
194
|
+
}
|
|
137
195
|
this._nonDeferredAttributes = attrs;
|
|
138
196
|
return attrs;
|
|
139
197
|
},
|
|
@@ -189,29 +247,42 @@ var Tag = /** @class */ (function (_super) {
|
|
|
189
247
|
};
|
|
190
248
|
Tag.prototype.evaluate = function () {
|
|
191
249
|
return __awaiter(this, void 0, void 0, function () {
|
|
192
|
-
var
|
|
193
|
-
|
|
194
|
-
|
|
250
|
+
var _a, _b, attr, e_3_1;
|
|
251
|
+
var e_3, _c;
|
|
252
|
+
return __generator(this, function (_d) {
|
|
253
|
+
switch (_d.label) {
|
|
195
254
|
case 0:
|
|
196
|
-
|
|
197
|
-
|
|
255
|
+
_d.trys.push([0, 5, 6, 7]);
|
|
256
|
+
_a = __values(this.nonDeferredAttributes), _b = _a.next();
|
|
257
|
+
_d.label = 1;
|
|
198
258
|
case 1:
|
|
199
|
-
if (
|
|
200
|
-
attr =
|
|
259
|
+
if (!!_b.done) return [3 /*break*/, 4];
|
|
260
|
+
attr = _b.value;
|
|
201
261
|
return [4 /*yield*/, attr.evaluate()];
|
|
202
262
|
case 2:
|
|
203
|
-
|
|
204
|
-
|
|
263
|
+
_d.sent();
|
|
264
|
+
_d.label = 3;
|
|
205
265
|
case 3:
|
|
206
|
-
|
|
266
|
+
_b = _a.next();
|
|
207
267
|
return [3 /*break*/, 1];
|
|
208
|
-
case 4: return [
|
|
268
|
+
case 4: return [3 /*break*/, 7];
|
|
269
|
+
case 5:
|
|
270
|
+
e_3_1 = _d.sent();
|
|
271
|
+
e_3 = { error: e_3_1 };
|
|
272
|
+
return [3 /*break*/, 7];
|
|
273
|
+
case 6:
|
|
274
|
+
try {
|
|
275
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
276
|
+
}
|
|
277
|
+
finally { if (e_3) throw e_3.error; }
|
|
278
|
+
return [7 /*endfinally*/];
|
|
279
|
+
case 7: return [2 /*return*/];
|
|
209
280
|
}
|
|
210
281
|
});
|
|
211
282
|
});
|
|
212
283
|
};
|
|
213
284
|
Tag.prototype.mutate = function (mutation) {
|
|
214
|
-
this.attributes.
|
|
285
|
+
this.attributes.forEach(function (attr) { return attr.mutate(mutation); });
|
|
215
286
|
this.dispatch('mutate', mutation);
|
|
216
287
|
};
|
|
217
288
|
Tag.prototype.get = function (attr) {
|
|
@@ -246,9 +317,6 @@ var Tag = /** @class */ (function (_super) {
|
|
|
246
317
|
}
|
|
247
318
|
return null;
|
|
248
319
|
};
|
|
249
|
-
Tag.prototype.getAttributeModifiers = function (attr) {
|
|
250
|
-
return attr.split('|').splice(1);
|
|
251
|
-
};
|
|
252
320
|
Object.defineProperty(Tag.prototype, "isInput", {
|
|
253
321
|
get: function () {
|
|
254
322
|
return this.inputTags.indexOf(this.element.tagName.toLowerCase()) > -1;
|
|
@@ -283,11 +351,21 @@ var Tag = /** @class */ (function (_super) {
|
|
|
283
351
|
}
|
|
284
352
|
},
|
|
285
353
|
set: function (value) {
|
|
354
|
+
var e_4, _a;
|
|
286
355
|
if (this.isInput) {
|
|
287
356
|
if (this.isMultipleSelect) {
|
|
288
|
-
|
|
289
|
-
var
|
|
290
|
-
|
|
357
|
+
try {
|
|
358
|
+
for (var _b = __values(Array.from(this.element.options)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
359
|
+
var option = _c.value;
|
|
360
|
+
option.selected = value.indexOf(option.value) > -1;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
364
|
+
finally {
|
|
365
|
+
try {
|
|
366
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
367
|
+
}
|
|
368
|
+
finally { if (e_4) throw e_4.error; }
|
|
291
369
|
}
|
|
292
370
|
}
|
|
293
371
|
else {
|
|
@@ -334,7 +412,7 @@ var Tag = /** @class */ (function (_super) {
|
|
|
334
412
|
};
|
|
335
413
|
Object.defineProperty(Tag.prototype, "children", {
|
|
336
414
|
get: function () {
|
|
337
|
-
return __spreadArray([], this._children);
|
|
415
|
+
return __spreadArray([], __read(this._children));
|
|
338
416
|
},
|
|
339
417
|
enumerable: false,
|
|
340
418
|
configurable: true
|
|
@@ -441,13 +519,23 @@ var Tag = /** @class */ (function (_super) {
|
|
|
441
519
|
return this.parentTag ? this.parentTag.findAncestorByAttribute(attr, true) : null;
|
|
442
520
|
};
|
|
443
521
|
Tag.prototype.findDescendantsByAttribute = function (attr, includeSelf) {
|
|
522
|
+
var e_5, _a;
|
|
444
523
|
if (includeSelf === void 0) { includeSelf = false; }
|
|
445
524
|
var tags = [];
|
|
446
525
|
if (includeSelf && this.hasAttribute(attr))
|
|
447
526
|
tags.push(this);
|
|
448
|
-
|
|
449
|
-
var
|
|
450
|
-
|
|
527
|
+
try {
|
|
528
|
+
for (var _b = __values(this.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
529
|
+
var child = _c.value;
|
|
530
|
+
tags.concat(child.findDescendantsByAttribute(attr, true));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
534
|
+
finally {
|
|
535
|
+
try {
|
|
536
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
537
|
+
}
|
|
538
|
+
finally { if (e_5) throw e_5.error; }
|
|
451
539
|
}
|
|
452
540
|
return tags;
|
|
453
541
|
};
|
|
@@ -459,18 +547,28 @@ var Tag = /** @class */ (function (_super) {
|
|
|
459
547
|
};
|
|
460
548
|
Tag.prototype.getAttribute = function (key) {
|
|
461
549
|
return __awaiter(this, void 0, void 0, function () {
|
|
462
|
-
var cls,
|
|
463
|
-
|
|
464
|
-
|
|
550
|
+
var cls, _a, _b, attr;
|
|
551
|
+
var e_6, _c;
|
|
552
|
+
return __generator(this, function (_d) {
|
|
553
|
+
switch (_d.label) {
|
|
465
554
|
case 0: return [4 /*yield*/, Registry_1.Registry.instance.attributes.get(key)];
|
|
466
555
|
case 1:
|
|
467
|
-
cls =
|
|
556
|
+
cls = _d.sent();
|
|
468
557
|
if (!cls)
|
|
469
558
|
return [2 /*return*/];
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
559
|
+
try {
|
|
560
|
+
for (_a = __values(this.attributes.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
561
|
+
attr = _b.value;
|
|
562
|
+
if (attr instanceof cls)
|
|
563
|
+
return [2 /*return*/, attr];
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
567
|
+
finally {
|
|
568
|
+
try {
|
|
569
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
570
|
+
}
|
|
571
|
+
finally { if (e_6) throw e_6.error; }
|
|
474
572
|
}
|
|
475
573
|
return [2 /*return*/];
|
|
476
574
|
}
|
|
@@ -494,10 +592,10 @@ var Tag = /** @class */ (function (_super) {
|
|
|
494
592
|
else if (key === '@value')
|
|
495
593
|
this.value = value;
|
|
496
594
|
else if (key === '@class' && value) {
|
|
497
|
-
(_a = this.element.classList).remove.apply(_a, Array.from(this.element.classList));
|
|
595
|
+
(_a = this.element.classList).remove.apply(_a, __spreadArray([], __read(Array.from(this.element.classList))));
|
|
498
596
|
var classes = value instanceof Array ? value : [value];
|
|
499
597
|
if (classes.length)
|
|
500
|
-
(_b = this.element.classList).add.apply(_b, classes);
|
|
598
|
+
(_b = this.element.classList).add.apply(_b, __spreadArray([], __read(classes)));
|
|
501
599
|
}
|
|
502
600
|
else if (Tag.flagAttributes.indexOf(key) > -1) {
|
|
503
601
|
var attrKey = key.replace('@', '');
|
|
@@ -558,7 +656,8 @@ var Tag = /** @class */ (function (_super) {
|
|
|
558
656
|
};
|
|
559
657
|
Tag.prototype.buildAttributes = function () {
|
|
560
658
|
return __awaiter(this, void 0, void 0, function () {
|
|
561
|
-
var requiresScope, defer, isMobile, tags, slot,
|
|
659
|
+
var requiresScope, defer, isMobile, tags, slot, tags_1, tags_1_1, tag, _a, _b, _i, attr, attrClass, attrObj, e_7_1;
|
|
660
|
+
var e_7, _c;
|
|
562
661
|
return __generator(this, function (_d) {
|
|
563
662
|
switch (_d.label) {
|
|
564
663
|
case 0:
|
|
@@ -574,55 +673,68 @@ var Tag = /** @class */ (function (_super) {
|
|
|
574
673
|
case 1:
|
|
575
674
|
tags = _d.sent();
|
|
576
675
|
slot = this.isSlot ? this : null;
|
|
577
|
-
_i = 0, tags_1 = tags;
|
|
578
676
|
_d.label = 2;
|
|
579
677
|
case 2:
|
|
580
|
-
|
|
581
|
-
|
|
678
|
+
_d.trys.push([2, 11, 12, 13]);
|
|
679
|
+
tags_1 = __values(tags), tags_1_1 = tags_1.next();
|
|
680
|
+
_d.label = 3;
|
|
681
|
+
case 3:
|
|
682
|
+
if (!!tags_1_1.done) return [3 /*break*/, 10];
|
|
683
|
+
tag = tags_1_1.value;
|
|
582
684
|
_a = [];
|
|
583
685
|
for (_b in this.rawAttributes)
|
|
584
686
|
_a.push(_b);
|
|
585
|
-
|
|
586
|
-
_d.label =
|
|
587
|
-
case
|
|
588
|
-
if (!(
|
|
589
|
-
attr = _a[
|
|
590
|
-
if (tag.
|
|
591
|
-
return [3 /*break*/,
|
|
687
|
+
_i = 0;
|
|
688
|
+
_d.label = 4;
|
|
689
|
+
case 4:
|
|
690
|
+
if (!(_i < _a.length)) return [3 /*break*/, 8];
|
|
691
|
+
attr = _a[_i];
|
|
692
|
+
if (tag.attributes.has(attr))
|
|
693
|
+
return [3 /*break*/, 7];
|
|
592
694
|
if (this.hasModifier(attr, 'mobile') && !isMobile)
|
|
593
|
-
return [3 /*break*/,
|
|
695
|
+
return [3 /*break*/, 7];
|
|
594
696
|
if (this.hasModifier(attr, 'desktop') && isMobile)
|
|
595
|
-
return [3 /*break*/,
|
|
697
|
+
return [3 /*break*/, 7];
|
|
596
698
|
return [4 /*yield*/, this.getAttributeClass(attr)];
|
|
597
|
-
case
|
|
699
|
+
case 5:
|
|
598
700
|
attrClass = _d.sent();
|
|
599
|
-
if (!attrClass) return [3 /*break*/,
|
|
701
|
+
if (!attrClass) return [3 /*break*/, 7];
|
|
600
702
|
if (attrClass.scoped)
|
|
601
703
|
requiresScope = true;
|
|
602
704
|
attrObj = attrClass.create(tag, attr, attrClass, slot);
|
|
603
|
-
tag.attributes.
|
|
604
|
-
|
|
605
|
-
if (!(defer && attrClass.canDefer)) return [3 /*break*/, 6];
|
|
705
|
+
tag.attributes.set(attr, attrObj);
|
|
706
|
+
if (!(defer && attrClass.canDefer)) return [3 /*break*/, 7];
|
|
606
707
|
return [4 /*yield*/, attrObj.defer()];
|
|
607
|
-
case
|
|
708
|
+
case 6:
|
|
608
709
|
_d.sent();
|
|
609
710
|
tag.deferredAttributes.push(attrObj);
|
|
610
711
|
attrObj.on('state', tag.onAttributeStateChange, tag);
|
|
611
|
-
_d.label =
|
|
612
|
-
case 6:
|
|
613
|
-
_c++;
|
|
614
|
-
return [3 /*break*/, 3];
|
|
712
|
+
_d.label = 7;
|
|
615
713
|
case 7:
|
|
714
|
+
_i++;
|
|
715
|
+
return [3 /*break*/, 4];
|
|
716
|
+
case 8:
|
|
616
717
|
if (tag.element.getAttribute('id'))
|
|
617
718
|
requiresScope = true;
|
|
618
719
|
if (requiresScope && !tag.uniqueScope) {
|
|
619
720
|
tag._uniqueScope = true;
|
|
620
721
|
}
|
|
621
|
-
_d.label =
|
|
622
|
-
case 8:
|
|
623
|
-
_i++;
|
|
624
|
-
return [3 /*break*/, 2];
|
|
722
|
+
_d.label = 9;
|
|
625
723
|
case 9:
|
|
724
|
+
tags_1_1 = tags_1.next();
|
|
725
|
+
return [3 /*break*/, 3];
|
|
726
|
+
case 10: return [3 /*break*/, 13];
|
|
727
|
+
case 11:
|
|
728
|
+
e_7_1 = _d.sent();
|
|
729
|
+
e_7 = { error: e_7_1 };
|
|
730
|
+
return [3 /*break*/, 13];
|
|
731
|
+
case 12:
|
|
732
|
+
try {
|
|
733
|
+
if (tags_1_1 && !tags_1_1.done && (_c = tags_1.return)) _c.call(tags_1);
|
|
734
|
+
}
|
|
735
|
+
finally { if (e_7) throw e_7.error; }
|
|
736
|
+
return [7 /*endfinally*/];
|
|
737
|
+
case 13:
|
|
626
738
|
this._state = TagState.AttributesBuilt;
|
|
627
739
|
return [2 /*return*/];
|
|
628
740
|
}
|
|
@@ -631,33 +743,62 @@ var Tag = /** @class */ (function (_super) {
|
|
|
631
743
|
};
|
|
632
744
|
Tag.prototype.compileAttributes = function () {
|
|
633
745
|
return __awaiter(this, void 0, void 0, function () {
|
|
634
|
-
var tags,
|
|
635
|
-
|
|
636
|
-
|
|
746
|
+
var tags, tags_2, tags_2_1, tag, _a, _b, attr, e_8_1, e_9_1;
|
|
747
|
+
var e_9, _c, e_8, _d;
|
|
748
|
+
return __generator(this, function (_e) {
|
|
749
|
+
switch (_e.label) {
|
|
637
750
|
case 0: return [4 /*yield*/, this.getTagsToBuild()];
|
|
638
751
|
case 1:
|
|
639
|
-
tags =
|
|
640
|
-
|
|
641
|
-
_c.label = 2;
|
|
752
|
+
tags = _e.sent();
|
|
753
|
+
_e.label = 2;
|
|
642
754
|
case 2:
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
_c.label = 3;
|
|
755
|
+
_e.trys.push([2, 13, 14, 15]);
|
|
756
|
+
tags_2 = __values(tags), tags_2_1 = tags_2.next();
|
|
757
|
+
_e.label = 3;
|
|
647
758
|
case 3:
|
|
648
|
-
if (
|
|
649
|
-
|
|
650
|
-
|
|
759
|
+
if (!!tags_2_1.done) return [3 /*break*/, 12];
|
|
760
|
+
tag = tags_2_1.value;
|
|
761
|
+
_e.label = 4;
|
|
651
762
|
case 4:
|
|
652
|
-
|
|
653
|
-
|
|
763
|
+
_e.trys.push([4, 9, 10, 11]);
|
|
764
|
+
_a = (e_8 = void 0, __values(tag.getAttributesWithState(Attribute_1.AttributeState.Instantiated))), _b = _a.next();
|
|
765
|
+
_e.label = 5;
|
|
654
766
|
case 5:
|
|
655
|
-
|
|
656
|
-
|
|
767
|
+
if (!!_b.done) return [3 /*break*/, 8];
|
|
768
|
+
attr = _b.value;
|
|
769
|
+
return [4 /*yield*/, attr.compile()];
|
|
657
770
|
case 6:
|
|
658
|
-
|
|
659
|
-
|
|
771
|
+
_e.sent();
|
|
772
|
+
_e.label = 7;
|
|
660
773
|
case 7:
|
|
774
|
+
_b = _a.next();
|
|
775
|
+
return [3 /*break*/, 5];
|
|
776
|
+
case 8: return [3 /*break*/, 11];
|
|
777
|
+
case 9:
|
|
778
|
+
e_8_1 = _e.sent();
|
|
779
|
+
e_8 = { error: e_8_1 };
|
|
780
|
+
return [3 /*break*/, 11];
|
|
781
|
+
case 10:
|
|
782
|
+
try {
|
|
783
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
784
|
+
}
|
|
785
|
+
finally { if (e_8) throw e_8.error; }
|
|
786
|
+
return [7 /*endfinally*/];
|
|
787
|
+
case 11:
|
|
788
|
+
tags_2_1 = tags_2.next();
|
|
789
|
+
return [3 /*break*/, 3];
|
|
790
|
+
case 12: return [3 /*break*/, 15];
|
|
791
|
+
case 13:
|
|
792
|
+
e_9_1 = _e.sent();
|
|
793
|
+
e_9 = { error: e_9_1 };
|
|
794
|
+
return [3 /*break*/, 15];
|
|
795
|
+
case 14:
|
|
796
|
+
try {
|
|
797
|
+
if (tags_2_1 && !tags_2_1.done && (_c = tags_2.return)) _c.call(tags_2);
|
|
798
|
+
}
|
|
799
|
+
finally { if (e_9) throw e_9.error; }
|
|
800
|
+
return [7 /*endfinally*/];
|
|
801
|
+
case 15:
|
|
661
802
|
this._state = TagState.AttributesCompiled;
|
|
662
803
|
return [2 /*return*/];
|
|
663
804
|
}
|
|
@@ -666,33 +807,62 @@ var Tag = /** @class */ (function (_super) {
|
|
|
666
807
|
};
|
|
667
808
|
Tag.prototype.setupAttributes = function () {
|
|
668
809
|
return __awaiter(this, void 0, void 0, function () {
|
|
669
|
-
var tags,
|
|
670
|
-
|
|
671
|
-
|
|
810
|
+
var tags, tags_3, tags_3_1, tag, _a, _b, attr, e_10_1, e_11_1;
|
|
811
|
+
var e_11, _c, e_10, _d;
|
|
812
|
+
return __generator(this, function (_e) {
|
|
813
|
+
switch (_e.label) {
|
|
672
814
|
case 0: return [4 /*yield*/, this.getTagsToBuild()];
|
|
673
815
|
case 1:
|
|
674
|
-
tags =
|
|
675
|
-
|
|
676
|
-
_c.label = 2;
|
|
816
|
+
tags = _e.sent();
|
|
817
|
+
_e.label = 2;
|
|
677
818
|
case 2:
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
_c.label = 3;
|
|
819
|
+
_e.trys.push([2, 13, 14, 15]);
|
|
820
|
+
tags_3 = __values(tags), tags_3_1 = tags_3.next();
|
|
821
|
+
_e.label = 3;
|
|
682
822
|
case 3:
|
|
683
|
-
if (
|
|
684
|
-
|
|
685
|
-
|
|
823
|
+
if (!!tags_3_1.done) return [3 /*break*/, 12];
|
|
824
|
+
tag = tags_3_1.value;
|
|
825
|
+
_e.label = 4;
|
|
686
826
|
case 4:
|
|
687
|
-
|
|
688
|
-
|
|
827
|
+
_e.trys.push([4, 9, 10, 11]);
|
|
828
|
+
_a = (e_10 = void 0, __values(tag.getAttributesWithState(Attribute_1.AttributeState.Compiled))), _b = _a.next();
|
|
829
|
+
_e.label = 5;
|
|
689
830
|
case 5:
|
|
690
|
-
|
|
691
|
-
|
|
831
|
+
if (!!_b.done) return [3 /*break*/, 8];
|
|
832
|
+
attr = _b.value;
|
|
833
|
+
return [4 /*yield*/, attr.setup()];
|
|
692
834
|
case 6:
|
|
693
|
-
|
|
694
|
-
|
|
835
|
+
_e.sent();
|
|
836
|
+
_e.label = 7;
|
|
695
837
|
case 7:
|
|
838
|
+
_b = _a.next();
|
|
839
|
+
return [3 /*break*/, 5];
|
|
840
|
+
case 8: return [3 /*break*/, 11];
|
|
841
|
+
case 9:
|
|
842
|
+
e_10_1 = _e.sent();
|
|
843
|
+
e_10 = { error: e_10_1 };
|
|
844
|
+
return [3 /*break*/, 11];
|
|
845
|
+
case 10:
|
|
846
|
+
try {
|
|
847
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
848
|
+
}
|
|
849
|
+
finally { if (e_10) throw e_10.error; }
|
|
850
|
+
return [7 /*endfinally*/];
|
|
851
|
+
case 11:
|
|
852
|
+
tags_3_1 = tags_3.next();
|
|
853
|
+
return [3 /*break*/, 3];
|
|
854
|
+
case 12: return [3 /*break*/, 15];
|
|
855
|
+
case 13:
|
|
856
|
+
e_11_1 = _e.sent();
|
|
857
|
+
e_11 = { error: e_11_1 };
|
|
858
|
+
return [3 /*break*/, 15];
|
|
859
|
+
case 14:
|
|
860
|
+
try {
|
|
861
|
+
if (tags_3_1 && !tags_3_1.done && (_c = tags_3.return)) _c.call(tags_3);
|
|
862
|
+
}
|
|
863
|
+
finally { if (e_11) throw e_11.error; }
|
|
864
|
+
return [7 /*endfinally*/];
|
|
865
|
+
case 15:
|
|
696
866
|
if (!this.isSlot)
|
|
697
867
|
this.dom.registerElementInRoot(this);
|
|
698
868
|
this._state = TagState.AttributesSetup;
|
|
@@ -704,33 +874,62 @@ var Tag = /** @class */ (function (_super) {
|
|
|
704
874
|
};
|
|
705
875
|
Tag.prototype.extractAttributes = function () {
|
|
706
876
|
return __awaiter(this, void 0, void 0, function () {
|
|
707
|
-
var tags,
|
|
708
|
-
|
|
709
|
-
|
|
877
|
+
var tags, tags_4, tags_4_1, tag, _a, _b, attr, e_12_1, e_13_1;
|
|
878
|
+
var e_13, _c, e_12, _d;
|
|
879
|
+
return __generator(this, function (_e) {
|
|
880
|
+
switch (_e.label) {
|
|
710
881
|
case 0: return [4 /*yield*/, this.getTagsToBuild()];
|
|
711
882
|
case 1:
|
|
712
|
-
tags =
|
|
713
|
-
|
|
714
|
-
_c.label = 2;
|
|
883
|
+
tags = _e.sent();
|
|
884
|
+
_e.label = 2;
|
|
715
885
|
case 2:
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
_c.label = 3;
|
|
886
|
+
_e.trys.push([2, 13, 14, 15]);
|
|
887
|
+
tags_4 = __values(tags), tags_4_1 = tags_4.next();
|
|
888
|
+
_e.label = 3;
|
|
720
889
|
case 3:
|
|
721
|
-
if (
|
|
722
|
-
|
|
723
|
-
|
|
890
|
+
if (!!tags_4_1.done) return [3 /*break*/, 12];
|
|
891
|
+
tag = tags_4_1.value;
|
|
892
|
+
_e.label = 4;
|
|
724
893
|
case 4:
|
|
725
|
-
|
|
726
|
-
|
|
894
|
+
_e.trys.push([4, 9, 10, 11]);
|
|
895
|
+
_a = (e_12 = void 0, __values(tag.getAttributesWithState(Attribute_1.AttributeState.Setup))), _b = _a.next();
|
|
896
|
+
_e.label = 5;
|
|
727
897
|
case 5:
|
|
728
|
-
|
|
729
|
-
|
|
898
|
+
if (!!_b.done) return [3 /*break*/, 8];
|
|
899
|
+
attr = _b.value;
|
|
900
|
+
return [4 /*yield*/, attr.extract()];
|
|
730
901
|
case 6:
|
|
731
|
-
|
|
732
|
-
|
|
902
|
+
_e.sent();
|
|
903
|
+
_e.label = 7;
|
|
733
904
|
case 7:
|
|
905
|
+
_b = _a.next();
|
|
906
|
+
return [3 /*break*/, 5];
|
|
907
|
+
case 8: return [3 /*break*/, 11];
|
|
908
|
+
case 9:
|
|
909
|
+
e_12_1 = _e.sent();
|
|
910
|
+
e_12 = { error: e_12_1 };
|
|
911
|
+
return [3 /*break*/, 11];
|
|
912
|
+
case 10:
|
|
913
|
+
try {
|
|
914
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
915
|
+
}
|
|
916
|
+
finally { if (e_12) throw e_12.error; }
|
|
917
|
+
return [7 /*endfinally*/];
|
|
918
|
+
case 11:
|
|
919
|
+
tags_4_1 = tags_4.next();
|
|
920
|
+
return [3 /*break*/, 3];
|
|
921
|
+
case 12: return [3 /*break*/, 15];
|
|
922
|
+
case 13:
|
|
923
|
+
e_13_1 = _e.sent();
|
|
924
|
+
e_13 = { error: e_13_1 };
|
|
925
|
+
return [3 /*break*/, 15];
|
|
926
|
+
case 14:
|
|
927
|
+
try {
|
|
928
|
+
if (tags_4_1 && !tags_4_1.done && (_c = tags_4.return)) _c.call(tags_4);
|
|
929
|
+
}
|
|
930
|
+
finally { if (e_13) throw e_13.error; }
|
|
931
|
+
return [7 /*endfinally*/];
|
|
932
|
+
case 15:
|
|
734
933
|
this._state = TagState.AttributesExtracted;
|
|
735
934
|
this.callOnWrapped('$extracted');
|
|
736
935
|
return [2 /*return*/];
|
|
@@ -740,36 +939,65 @@ var Tag = /** @class */ (function (_super) {
|
|
|
740
939
|
};
|
|
741
940
|
Tag.prototype.connectAttributes = function () {
|
|
742
941
|
return __awaiter(this, void 0, void 0, function () {
|
|
743
|
-
var tags,
|
|
744
|
-
|
|
745
|
-
|
|
942
|
+
var tags, tags_5, tags_5_1, tag, _a, _b, attr, e_14_1, e_15_1;
|
|
943
|
+
var e_15, _c, e_14, _d;
|
|
944
|
+
return __generator(this, function (_e) {
|
|
945
|
+
switch (_e.label) {
|
|
746
946
|
case 0: return [4 /*yield*/, this.getTagsToBuild()];
|
|
747
947
|
case 1:
|
|
748
|
-
tags =
|
|
749
|
-
|
|
750
|
-
_c.label = 2;
|
|
948
|
+
tags = _e.sent();
|
|
949
|
+
_e.label = 2;
|
|
751
950
|
case 2:
|
|
752
|
-
|
|
753
|
-
|
|
951
|
+
_e.trys.push([2, 13, 14, 15]);
|
|
952
|
+
tags_5 = __values(tags), tags_5_1 = tags_5.next();
|
|
953
|
+
_e.label = 3;
|
|
954
|
+
case 3:
|
|
955
|
+
if (!!tags_5_1.done) return [3 /*break*/, 12];
|
|
956
|
+
tag = tags_5_1.value;
|
|
754
957
|
if (tag.isInput) {
|
|
755
|
-
tag.addEventHandler('input',
|
|
958
|
+
tag.addEventHandler('input', null, tag.inputMutation, tag);
|
|
756
959
|
}
|
|
757
|
-
|
|
758
|
-
_c.label = 3;
|
|
759
|
-
case 3:
|
|
760
|
-
if (!(_a < _b.length)) return [3 /*break*/, 6];
|
|
761
|
-
attr = _b[_a];
|
|
762
|
-
return [4 /*yield*/, attr.connect()];
|
|
960
|
+
_e.label = 4;
|
|
763
961
|
case 4:
|
|
764
|
-
|
|
765
|
-
|
|
962
|
+
_e.trys.push([4, 9, 10, 11]);
|
|
963
|
+
_a = (e_14 = void 0, __values(tag.getAttributesWithState(Attribute_1.AttributeState.Extracted))), _b = _a.next();
|
|
964
|
+
_e.label = 5;
|
|
766
965
|
case 5:
|
|
767
|
-
|
|
768
|
-
|
|
966
|
+
if (!!_b.done) return [3 /*break*/, 8];
|
|
967
|
+
attr = _b.value;
|
|
968
|
+
return [4 /*yield*/, attr.connect()];
|
|
769
969
|
case 6:
|
|
770
|
-
|
|
771
|
-
|
|
970
|
+
_e.sent();
|
|
971
|
+
_e.label = 7;
|
|
772
972
|
case 7:
|
|
973
|
+
_b = _a.next();
|
|
974
|
+
return [3 /*break*/, 5];
|
|
975
|
+
case 8: return [3 /*break*/, 11];
|
|
976
|
+
case 9:
|
|
977
|
+
e_14_1 = _e.sent();
|
|
978
|
+
e_14 = { error: e_14_1 };
|
|
979
|
+
return [3 /*break*/, 11];
|
|
980
|
+
case 10:
|
|
981
|
+
try {
|
|
982
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
983
|
+
}
|
|
984
|
+
finally { if (e_14) throw e_14.error; }
|
|
985
|
+
return [7 /*endfinally*/];
|
|
986
|
+
case 11:
|
|
987
|
+
tags_5_1 = tags_5.next();
|
|
988
|
+
return [3 /*break*/, 3];
|
|
989
|
+
case 12: return [3 /*break*/, 15];
|
|
990
|
+
case 13:
|
|
991
|
+
e_15_1 = _e.sent();
|
|
992
|
+
e_15 = { error: e_15_1 };
|
|
993
|
+
return [3 /*break*/, 15];
|
|
994
|
+
case 14:
|
|
995
|
+
try {
|
|
996
|
+
if (tags_5_1 && !tags_5_1.done && (_c = tags_5.return)) _c.call(tags_5);
|
|
997
|
+
}
|
|
998
|
+
finally { if (e_15) throw e_15.error; }
|
|
999
|
+
return [7 /*endfinally*/];
|
|
1000
|
+
case 15:
|
|
773
1001
|
this._state = TagState.AttributesConnected;
|
|
774
1002
|
this.callOnWrapped('$bound');
|
|
775
1003
|
return [2 /*return*/];
|
|
@@ -778,20 +1006,30 @@ var Tag = /** @class */ (function (_super) {
|
|
|
778
1006
|
});
|
|
779
1007
|
};
|
|
780
1008
|
Tag.prototype.inputMutation = function (e) {
|
|
1009
|
+
var e_16, _a;
|
|
781
1010
|
if (this.isSelect) {
|
|
782
1011
|
var selected = this.element.selectedOptions;
|
|
783
1012
|
var values = [];
|
|
784
1013
|
for (var i = 0; i < selected.length; i++) {
|
|
785
1014
|
values.push(selected[i].value);
|
|
786
1015
|
}
|
|
787
|
-
|
|
788
|
-
var
|
|
789
|
-
|
|
790
|
-
option.
|
|
1016
|
+
try {
|
|
1017
|
+
for (var _b = __values(Array.from(this.element.options)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1018
|
+
var option = _c.value;
|
|
1019
|
+
if (values.indexOf(option.value) > -1) {
|
|
1020
|
+
option.setAttribute('selected', '');
|
|
1021
|
+
}
|
|
1022
|
+
else {
|
|
1023
|
+
option.removeAttribute('selected');
|
|
1024
|
+
}
|
|
791
1025
|
}
|
|
792
|
-
|
|
793
|
-
|
|
1026
|
+
}
|
|
1027
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
1028
|
+
finally {
|
|
1029
|
+
try {
|
|
1030
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
794
1031
|
}
|
|
1032
|
+
finally { if (e_16) throw e_16.error; }
|
|
795
1033
|
}
|
|
796
1034
|
this.value = values.join(',');
|
|
797
1035
|
}
|
|
@@ -817,24 +1055,75 @@ var Tag = /** @class */ (function (_super) {
|
|
|
817
1055
|
args[_i - 1] = arguments[_i];
|
|
818
1056
|
}
|
|
819
1057
|
if (this._uniqueScope && this.scope && this.scope.wrapped && this.scope.wrapped[method]) {
|
|
820
|
-
(_a = this.scope.wrapped)[method].apply(_a, args);
|
|
1058
|
+
(_a = this.scope.wrapped)[method].apply(_a, __spreadArray([], __read(args)));
|
|
821
1059
|
return true;
|
|
822
1060
|
}
|
|
823
1061
|
return false;
|
|
824
1062
|
};
|
|
825
1063
|
Tag.prototype.handleEvent = function (eventType, e) {
|
|
1064
|
+
var e_17, _a;
|
|
1065
|
+
var _this = this;
|
|
826
1066
|
if (e)
|
|
827
1067
|
e.stopPropagation();
|
|
828
1068
|
if (!this.onEventHandlers[eventType])
|
|
829
1069
|
return;
|
|
830
1070
|
this.scope.set('$event', e);
|
|
831
1071
|
this.scope.set('$value', this.value);
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
handler.
|
|
1072
|
+
var preventedDefault = false;
|
|
1073
|
+
var _loop_1 = function (handler) {
|
|
1074
|
+
if (!preventedDefault && handler.modifiers.has('preventdefault') && e.cancelable) {
|
|
1075
|
+
e.preventDefault();
|
|
1076
|
+
preventedDefault = true;
|
|
1077
|
+
}
|
|
1078
|
+
if (handler.modifiers.has('once'))
|
|
1079
|
+
this_1.removeEventHandler(handler.event, handler.handler, handler.context);
|
|
1080
|
+
if (handler.modifiers.has('throttle')) {
|
|
1081
|
+
var modifierArguments = handler.modifiers.get('throttle').getArguments(['1000']);
|
|
1082
|
+
var throttleTime = parseInt(modifierArguments[0]);
|
|
1083
|
+
var now = Math.floor(Date.now());
|
|
1084
|
+
if (!handler.state.lastCalled || handler.state.lastCalled + throttleTime < now) {
|
|
1085
|
+
handler.state.lastCalled = now;
|
|
1086
|
+
}
|
|
1087
|
+
else {
|
|
1088
|
+
return "continue";
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
if (handler.modifiers.has('debounce')) {
|
|
1092
|
+
clearTimeout(handler.state.debounceTimeout);
|
|
1093
|
+
var modifierArguments = handler.modifiers.get('debounce').getArguments(['1000']);
|
|
1094
|
+
var debounceTime = parseInt(modifierArguments[0]);
|
|
1095
|
+
handler.state.debounceTimeout = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1096
|
+
return __generator(this, function (_a) {
|
|
1097
|
+
switch (_a.label) {
|
|
1098
|
+
case 0: return [4 /*yield*/, handler.handler.call(handler.context, e)];
|
|
1099
|
+
case 1:
|
|
1100
|
+
_a.sent();
|
|
1101
|
+
return [2 /*return*/];
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
1104
|
+
}); }, debounceTime);
|
|
1105
|
+
}
|
|
1106
|
+
else {
|
|
1107
|
+
handler.handler.call(handler.context, e);
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
var this_1 = this;
|
|
1111
|
+
try {
|
|
1112
|
+
for (var _b = __values(this.onEventHandlers[eventType]), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1113
|
+
var handler = _c.value;
|
|
1114
|
+
_loop_1(handler);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
1118
|
+
finally {
|
|
1119
|
+
try {
|
|
1120
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1121
|
+
}
|
|
1122
|
+
finally { if (e_17) throw e_17.error; }
|
|
835
1123
|
}
|
|
836
1124
|
};
|
|
837
1125
|
Tag.prototype.hasModifier = function (attribute, modifier) {
|
|
1126
|
+
this.attributes;
|
|
838
1127
|
return attribute.indexOf("|" + modifier) > -1;
|
|
839
1128
|
};
|
|
840
1129
|
Tag.prototype.stripModifier = function (attribute, modifier) {
|
|
@@ -843,24 +1132,27 @@ var Tag = /** @class */ (function (_super) {
|
|
|
843
1132
|
Tag.prototype.addEventHandler = function (eventType, modifiers, handler, context) {
|
|
844
1133
|
if (context === void 0) { context = null; }
|
|
845
1134
|
var passiveValue = null;
|
|
846
|
-
|
|
1135
|
+
modifiers = modifiers || new Modifiers_1.Modifiers();
|
|
1136
|
+
if (modifiers.has('active')) {
|
|
847
1137
|
passiveValue = false;
|
|
848
1138
|
}
|
|
849
|
-
else if (modifiers.
|
|
1139
|
+
else if (modifiers.has('passive')) {
|
|
850
1140
|
passiveValue = true;
|
|
851
1141
|
}
|
|
852
1142
|
if (!this.onEventHandlers[eventType]) {
|
|
853
1143
|
this.onEventHandlers[eventType] = [];
|
|
854
1144
|
var element = On_1.On.WindowEvents.indexOf(eventType) > -1 && window ? window : this.element;
|
|
855
|
-
var
|
|
1145
|
+
var eventListenerOpts = {};
|
|
856
1146
|
if (eventType.indexOf('touch') > -1 || passiveValue !== null)
|
|
857
|
-
|
|
858
|
-
element.addEventListener(eventType, this.handleEvent.bind(this, eventType),
|
|
1147
|
+
eventListenerOpts['passive'] = passiveValue === null && true || passiveValue;
|
|
1148
|
+
element.addEventListener(eventType, this.handleEvent.bind(this, eventType), eventListenerOpts);
|
|
859
1149
|
}
|
|
860
1150
|
this.onEventHandlers[eventType].push({
|
|
861
1151
|
handler: handler,
|
|
862
1152
|
event: eventType,
|
|
863
1153
|
context: context,
|
|
1154
|
+
modifiers: modifiers,
|
|
1155
|
+
state: {}
|
|
864
1156
|
});
|
|
865
1157
|
};
|
|
866
1158
|
Tag.prototype.removeEventHandler = function (eventType, handler, context) {
|
|
@@ -876,14 +1168,33 @@ var Tag = /** @class */ (function (_super) {
|
|
|
876
1168
|
}
|
|
877
1169
|
};
|
|
878
1170
|
Tag.prototype.removeContextEventHandlers = function (context) {
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
for (var
|
|
882
|
-
var
|
|
883
|
-
|
|
884
|
-
this.
|
|
1171
|
+
var e_18, _a, e_19, _b;
|
|
1172
|
+
try {
|
|
1173
|
+
for (var _c = __values(Object.keys(this.onEventHandlers)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1174
|
+
var eventType = _d.value;
|
|
1175
|
+
try {
|
|
1176
|
+
for (var _e = (e_19 = void 0, __values(this.onEventHandlers[eventType])), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
1177
|
+
var handler = _f.value;
|
|
1178
|
+
if (handler.context === context) {
|
|
1179
|
+
this.removeEventHandler(eventType, handler.handler, context);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
885
1182
|
}
|
|
1183
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
1184
|
+
finally {
|
|
1185
|
+
try {
|
|
1186
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
1187
|
+
}
|
|
1188
|
+
finally { if (e_19) throw e_19.error; }
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
1193
|
+
finally {
|
|
1194
|
+
try {
|
|
1195
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
886
1196
|
}
|
|
1197
|
+
finally { if (e_18) throw e_18.error; }
|
|
887
1198
|
}
|
|
888
1199
|
};
|
|
889
1200
|
Tag.prototype.createScope = function (force) {
|
|
@@ -901,22 +1212,19 @@ var Tag = /** @class */ (function (_super) {
|
|
|
901
1212
|
};
|
|
902
1213
|
Tag.prototype.watchAttribute = function (attributeName) {
|
|
903
1214
|
return __awaiter(this, void 0, void 0, function () {
|
|
904
|
-
var
|
|
905
|
-
return __generator(this, function (
|
|
906
|
-
switch (
|
|
1215
|
+
var standardAttribute;
|
|
1216
|
+
return __generator(this, function (_a) {
|
|
1217
|
+
switch (_a.label) {
|
|
907
1218
|
case 0:
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
if (attribute instanceof StandardAttribute_1.StandardAttribute && attribute.attributeName == attributeName) {
|
|
911
|
-
return [2 /*return*/, attribute];
|
|
912
|
-
}
|
|
1219
|
+
if (this.attributes.has(attributeName) && this.attributes.get(attributeName) instanceof StandardAttribute_1.StandardAttribute) {
|
|
1220
|
+
return [2 /*return*/, this.attributes.get(attributeName)];
|
|
913
1221
|
}
|
|
914
1222
|
this.createScope(true);
|
|
915
1223
|
standardAttribute = new StandardAttribute_1.StandardAttribute(this, attributeName);
|
|
916
|
-
this.attributes.
|
|
1224
|
+
this.attributes.set(attributeName, standardAttribute);
|
|
917
1225
|
return [4 /*yield*/, this.setupAttribute(standardAttribute)];
|
|
918
1226
|
case 1:
|
|
919
|
-
|
|
1227
|
+
_a.sent();
|
|
920
1228
|
return [2 /*return*/, standardAttribute];
|
|
921
1229
|
}
|
|
922
1230
|
});
|
|
@@ -924,22 +1232,18 @@ var Tag = /** @class */ (function (_super) {
|
|
|
924
1232
|
};
|
|
925
1233
|
Tag.prototype.watchStyle = function (styleName) {
|
|
926
1234
|
return __awaiter(this, void 0, void 0, function () {
|
|
927
|
-
var
|
|
928
|
-
return __generator(this, function (
|
|
929
|
-
switch (
|
|
1235
|
+
var styleAttribute;
|
|
1236
|
+
return __generator(this, function (_a) {
|
|
1237
|
+
switch (_a.label) {
|
|
930
1238
|
case 0:
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
if (attribute instanceof StyleAttribute_1.StyleAttribute) {
|
|
934
|
-
return [2 /*return*/, attribute];
|
|
935
|
-
}
|
|
936
|
-
}
|
|
1239
|
+
if (this.attributes.has('style'))
|
|
1240
|
+
return [2 /*return*/, this.attributes.get('style')];
|
|
937
1241
|
this.createScope(true);
|
|
938
1242
|
styleAttribute = new StyleAttribute_1.StyleAttribute(this, 'style');
|
|
939
|
-
this.attributes.
|
|
1243
|
+
this.attributes.set('style', styleAttribute);
|
|
940
1244
|
return [4 /*yield*/, this.setupAttribute(styleAttribute)];
|
|
941
1245
|
case 1:
|
|
942
|
-
|
|
1246
|
+
_a.sent();
|
|
943
1247
|
return [2 /*return*/, styleAttribute];
|
|
944
1248
|
}
|
|
945
1249
|
});
|
|
@@ -968,23 +1272,36 @@ var Tag = /** @class */ (function (_super) {
|
|
|
968
1272
|
};
|
|
969
1273
|
Tag.prototype.setupDeferredAttributes = function () {
|
|
970
1274
|
return __awaiter(this, void 0, void 0, function () {
|
|
971
|
-
var
|
|
972
|
-
|
|
973
|
-
|
|
1275
|
+
var _a, _b, attr, e_20_1;
|
|
1276
|
+
var e_20, _c;
|
|
1277
|
+
return __generator(this, function (_d) {
|
|
1278
|
+
switch (_d.label) {
|
|
974
1279
|
case 0:
|
|
975
|
-
|
|
976
|
-
|
|
1280
|
+
_d.trys.push([0, 5, 6, 7]);
|
|
1281
|
+
_a = __values(this.deferredAttributes), _b = _a.next();
|
|
1282
|
+
_d.label = 1;
|
|
977
1283
|
case 1:
|
|
978
|
-
if (
|
|
979
|
-
attr =
|
|
1284
|
+
if (!!_b.done) return [3 /*break*/, 4];
|
|
1285
|
+
attr = _b.value;
|
|
980
1286
|
return [4 /*yield*/, this.setupAttribute(attr)];
|
|
981
1287
|
case 2:
|
|
982
|
-
|
|
983
|
-
|
|
1288
|
+
_d.sent();
|
|
1289
|
+
_d.label = 3;
|
|
984
1290
|
case 3:
|
|
985
|
-
|
|
1291
|
+
_b = _a.next();
|
|
986
1292
|
return [3 /*break*/, 1];
|
|
987
|
-
case 4:
|
|
1293
|
+
case 4: return [3 /*break*/, 7];
|
|
1294
|
+
case 5:
|
|
1295
|
+
e_20_1 = _d.sent();
|
|
1296
|
+
e_20 = { error: e_20_1 };
|
|
1297
|
+
return [3 /*break*/, 7];
|
|
1298
|
+
case 6:
|
|
1299
|
+
try {
|
|
1300
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1301
|
+
}
|
|
1302
|
+
finally { if (e_20) throw e_20.error; }
|
|
1303
|
+
return [7 /*endfinally*/];
|
|
1304
|
+
case 7:
|
|
988
1305
|
this.deferredAttributes.length = 0;
|
|
989
1306
|
return [2 /*return*/];
|
|
990
1307
|
}
|
|
@@ -993,7 +1310,7 @@ var Tag = /** @class */ (function (_super) {
|
|
|
993
1310
|
};
|
|
994
1311
|
Tag.prototype.deconstruct = function () {
|
|
995
1312
|
this.attributes.forEach(function (attr) { return attr.deconstruct(); });
|
|
996
|
-
this.attributes.
|
|
1313
|
+
this.attributes.clear();
|
|
997
1314
|
this._children.forEach(function (child) { return child.deconstruct(); });
|
|
998
1315
|
this._children.length = 0;
|
|
999
1316
|
_super.prototype.deconstruct.call(this);
|