vsn 0.1.124 → 0.1.126
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 -8
- package/demo/examples/cascading-function-sheets.html +28 -0
- package/demo/examples/component-slots.html +16 -22
- package/demo/examples/loop.html +21 -0
- package/demo/resources/xhr-cfs.html +1 -0
- package/demo/resources/xhr-test-component.html +4 -0
- package/demo/service.html +3 -3
- package/demo/vsn.js +2 -2
- package/dist/AST/ClassNode.js +6 -3
- 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/ElementQueryNode.d.ts +2 -1
- package/dist/AST/ElementQueryNode.js +5 -5
- package/dist/AST/ElementQueryNode.js.map +1 -1
- package/dist/AST/FunctionNode.d.ts +1 -1
- package/dist/AST/LoopNode.d.ts +12 -0
- package/dist/AST/LoopNode.js +121 -0
- package/dist/AST/LoopNode.js.map +1 -0
- package/dist/AST/OnNode.d.ts +1 -1
- package/dist/AST/OnNode.js.map +1 -1
- package/dist/AST/ScopeMemberNode.js +4 -0
- package/dist/AST/ScopeMemberNode.js.map +1 -1
- package/dist/AST.d.ts +64 -62
- package/dist/AST.js +82 -69
- package/dist/AST.js.map +1 -1
- package/dist/Component.d.ts +2 -0
- package/dist/Component.js +12 -27
- package/dist/Component.js.map +1 -1
- package/dist/DOM/AbstractDOM.d.ts +48 -0
- package/dist/DOM/AbstractDOM.js +937 -0
- package/dist/DOM/AbstractDOM.js.map +1 -0
- package/dist/DOM/ShadowDOM.d.ts +5 -0
- package/dist/DOM/ShadowDOM.js +32 -0
- package/dist/DOM/ShadowDOM.js.map +1 -0
- package/dist/DOM.d.ts +3 -48
- package/dist/DOM.js +6 -913
- package/dist/DOM.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.d.ts +3 -2
- package/dist/Scope.js +37 -10
- package/dist/Scope.js.map +1 -1
- package/dist/Tag.d.ts +2 -0
- package/dist/Tag.js +52 -9
- package/dist/Tag.js.map +1 -1
- package/dist/helpers/VisionHelper.d.ts +1 -0
- package/dist/helpers/VisionHelper.js +45 -0
- package/dist/helpers/VisionHelper.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/vsn.js +3 -9
- 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/ElementQueryNode.ts +2 -1
- package/src/AST/FunctionNode.ts +1 -1
- package/src/AST/LoopNode.ts +35 -0
- package/src/AST/OnNode.ts +2 -2
- package/src/AST/ScopeMemberNode.ts +4 -0
- package/src/AST.ts +19 -7
- package/src/Component.ts +15 -13
- package/src/DOM/AbstractDOM.ts +389 -0
- package/src/DOM/ShadowDOM.ts +15 -0
- package/src/DOM.ts +4 -385
- package/src/Scope/ObjectAccessor.ts +21 -0
- package/src/Scope/ScopeAbstract.ts +11 -0
- package/src/Scope.ts +14 -1
- package/src/Tag.ts +25 -0
- package/src/helpers/VisionHelper.ts +6 -0
- package/src/version.ts +1 -1
- package/src/vsn.ts +3 -7
- package/test/AST/ClassNode.spec.ts +26 -4
- package/test/AST.spec.ts +21 -21
- package/test/Controller.spec.ts +1 -1
- package/test/DOM.spec.ts +3 -3
- package/test/Tag/TagList.spec.ts +1 -1
- package/test/attributes/Bind.spec.ts +12 -12
- package/test/attributes/JSONAttribute.spec.ts +5 -5
- package/test/attributes/ListItem.spec.ts +6 -6
- package/test/attributes/ScopeAttribute.spec.ts +2 -2
- package/test/attributes/ServiceAttribute.spec.ts +1 -1
- package/test/attributes/SetAttribute.spec.ts +3 -3
- package/test/attributes/Styles.spec.ts +2 -2
|
@@ -0,0 +1,937 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
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
|
+
};
|
|
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
|
+
};
|
|
80
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
81
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
82
|
+
to[j] = from[i];
|
|
83
|
+
return to;
|
|
84
|
+
};
|
|
85
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
86
|
+
exports.AbstractDOM = exports.EQuerySelectDirection = void 0;
|
|
87
|
+
var Tag_1 = require("../Tag");
|
|
88
|
+
var WrappedWindow_1 = require("./WrappedWindow");
|
|
89
|
+
var WrappedDocument_1 = require("./WrappedDocument");
|
|
90
|
+
var Configuration_1 = require("../Configuration");
|
|
91
|
+
var TagList_1 = require("../Tag/TagList");
|
|
92
|
+
var AST_1 = require("../AST");
|
|
93
|
+
var ClassNode_1 = require("../AST/ClassNode");
|
|
94
|
+
var Registry_1 = require("../Registry");
|
|
95
|
+
var ElementHelper_1 = require("../helpers/ElementHelper");
|
|
96
|
+
var SlotTag_1 = require("../Tag/SlotTag");
|
|
97
|
+
var SlottedTag_1 = require("../Tag/SlottedTag");
|
|
98
|
+
var EventDispatcher_1 = require("../EventDispatcher");
|
|
99
|
+
var EQuerySelectDirection;
|
|
100
|
+
(function (EQuerySelectDirection) {
|
|
101
|
+
EQuerySelectDirection[EQuerySelectDirection["ALL"] = 0] = "ALL";
|
|
102
|
+
EQuerySelectDirection[EQuerySelectDirection["UP"] = 1] = "UP";
|
|
103
|
+
EQuerySelectDirection[EQuerySelectDirection["DOWN"] = 2] = "DOWN";
|
|
104
|
+
})(EQuerySelectDirection = exports.EQuerySelectDirection || (exports.EQuerySelectDirection = {}));
|
|
105
|
+
var AbstractDOM = /** @class */ (function (_super) {
|
|
106
|
+
__extends(AbstractDOM, _super);
|
|
107
|
+
function AbstractDOM(rootElement, build, debug) {
|
|
108
|
+
if (build === void 0) { build = true; }
|
|
109
|
+
if (debug === void 0) { debug = false; }
|
|
110
|
+
var _this = _super.call(this) || this;
|
|
111
|
+
_this.rootElement = rootElement;
|
|
112
|
+
_this.debug = debug;
|
|
113
|
+
_this.queued = [];
|
|
114
|
+
_this._built = false;
|
|
115
|
+
_this._ready = new Promise(function (resolve) {
|
|
116
|
+
_this.once('built', function () {
|
|
117
|
+
resolve(true);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
_this.observer = new MutationObserver(_this.mutation.bind(_this));
|
|
121
|
+
_this.tags = [];
|
|
122
|
+
_this.window = new WrappedWindow_1.WrappedWindow(window);
|
|
123
|
+
_this.document = new WrappedDocument_1.WrappedDocument(window.document);
|
|
124
|
+
if (build) {
|
|
125
|
+
_this.buildFrom(rootElement, true);
|
|
126
|
+
}
|
|
127
|
+
_this.evaluate();
|
|
128
|
+
Configuration_1.Configuration.instance.on('change', _this.evaluate.bind(_this));
|
|
129
|
+
return _this;
|
|
130
|
+
}
|
|
131
|
+
Object.defineProperty(AbstractDOM.prototype, "built", {
|
|
132
|
+
get: function () {
|
|
133
|
+
return this._built;
|
|
134
|
+
},
|
|
135
|
+
enumerable: false,
|
|
136
|
+
configurable: true
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(AbstractDOM.prototype, "root", {
|
|
139
|
+
get: function () {
|
|
140
|
+
return this._root;
|
|
141
|
+
},
|
|
142
|
+
enumerable: false,
|
|
143
|
+
configurable: true
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(AbstractDOM.prototype, "ready", {
|
|
146
|
+
get: function () {
|
|
147
|
+
return this.promise('builtRoot');
|
|
148
|
+
},
|
|
149
|
+
enumerable: false,
|
|
150
|
+
configurable: true
|
|
151
|
+
});
|
|
152
|
+
AbstractDOM.prototype.get = function (selector, create, tag, direction) {
|
|
153
|
+
if (create === void 0) { create = false; }
|
|
154
|
+
if (tag === void 0) { tag = null; }
|
|
155
|
+
if (direction === void 0) { direction = EQuerySelectDirection.DOWN; }
|
|
156
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
157
|
+
var _a, nodes;
|
|
158
|
+
return __generator(this, function (_b) {
|
|
159
|
+
switch (_b.label) {
|
|
160
|
+
case 0:
|
|
161
|
+
_a = selector;
|
|
162
|
+
switch (_a) {
|
|
163
|
+
case 'window': return [3 /*break*/, 1];
|
|
164
|
+
case 'document': return [3 /*break*/, 2];
|
|
165
|
+
case 'body': return [3 /*break*/, 3];
|
|
166
|
+
}
|
|
167
|
+
return [3 /*break*/, 4];
|
|
168
|
+
case 1: return [2 /*return*/, new TagList_1.TagList(this.window)];
|
|
169
|
+
case 2: return [2 /*return*/, new TagList_1.TagList(this.document)];
|
|
170
|
+
case 3: return [2 /*return*/, new TagList_1.TagList(this.root)];
|
|
171
|
+
case 4:
|
|
172
|
+
nodes = void 0;
|
|
173
|
+
if (direction === EQuerySelectDirection.DOWN) {
|
|
174
|
+
nodes = this.querySelectorAll(selector, tag);
|
|
175
|
+
}
|
|
176
|
+
else if (direction === EQuerySelectDirection.UP) {
|
|
177
|
+
nodes = [this.querySelectorClosest(selector, tag)];
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
nodes = this.querySelectorAll(selector);
|
|
181
|
+
}
|
|
182
|
+
return [4 /*yield*/, this.getTagsForElements(Array.from(nodes), create)];
|
|
183
|
+
case 5: return [2 /*return*/, _b.sent()];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
AbstractDOM.prototype.getFromTag = function (tag, selector, create) {
|
|
189
|
+
if (create === void 0) { create = false; }
|
|
190
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
+
var nodes;
|
|
192
|
+
return __generator(this, function (_a) {
|
|
193
|
+
switch (_a.label) {
|
|
194
|
+
case 0:
|
|
195
|
+
nodes = this.querySelectorElement(tag.element, selector);
|
|
196
|
+
return [4 /*yield*/, this.getTagsForElements(Array.from(nodes), create)];
|
|
197
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
AbstractDOM.prototype.registerElementInRoot = function (tag) {
|
|
203
|
+
var id = tag.element.getAttribute('id');
|
|
204
|
+
if (!!id)
|
|
205
|
+
this.root.scope.set("#" + id, tag.scope);
|
|
206
|
+
};
|
|
207
|
+
AbstractDOM.prototype.querySelectorClosest = function (q, tag) {
|
|
208
|
+
if (tag === void 0) { tag = null; }
|
|
209
|
+
return tag.element.closest(q);
|
|
210
|
+
};
|
|
211
|
+
AbstractDOM.prototype.querySelectPath = function (path, element) {
|
|
212
|
+
var e_1, _a;
|
|
213
|
+
if (element === void 0) { element = null; }
|
|
214
|
+
var current = path.shift();
|
|
215
|
+
if (!current)
|
|
216
|
+
return [];
|
|
217
|
+
var elements = Array.from(element ? this.querySelectorElement(element, current) : this.querySelectorAll(current));
|
|
218
|
+
if (path.length > 0) {
|
|
219
|
+
var result = [];
|
|
220
|
+
try {
|
|
221
|
+
for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
|
|
222
|
+
var _element = elements_1_1.value;
|
|
223
|
+
result.push.apply(result, __spreadArray([], __read(this.querySelectPath(__spreadArray([], __read(path)), _element))));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
227
|
+
finally {
|
|
228
|
+
try {
|
|
229
|
+
if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);
|
|
230
|
+
}
|
|
231
|
+
finally { if (e_1) throw e_1.error; }
|
|
232
|
+
}
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
return elements;
|
|
236
|
+
};
|
|
237
|
+
AbstractDOM.prototype.querySelectorAll = function (q, tag) {
|
|
238
|
+
if (tag === void 0) { tag = null; }
|
|
239
|
+
var element = tag && !q.startsWith('#') ? tag.element : this.rootElement;
|
|
240
|
+
return this.querySelectorElement(element, q);
|
|
241
|
+
};
|
|
242
|
+
AbstractDOM.prototype.querySelectorElement = function (element, q) {
|
|
243
|
+
var e_2, _a;
|
|
244
|
+
var parentIndex = q.indexOf(':parent');
|
|
245
|
+
if (parentIndex > -1) {
|
|
246
|
+
var _q = q.substring(0, parentIndex);
|
|
247
|
+
var rest = q.substring(parentIndex + 7);
|
|
248
|
+
if (_q.length > 0) {
|
|
249
|
+
var nodeList = [];
|
|
250
|
+
try {
|
|
251
|
+
for (var _b = __values(Array.from(this.querySelectorElement(element, _q))), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
252
|
+
var _element = _c.value;
|
|
253
|
+
if (rest.length > 0) {
|
|
254
|
+
nodeList.push.apply(nodeList, __spreadArray([], __read(Array.from(this.querySelectorElement(AbstractDOM.getParentElement(_element), rest)))));
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
nodeList.push(AbstractDOM.getParentElement(_element));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
262
|
+
finally {
|
|
263
|
+
try {
|
|
264
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
265
|
+
}
|
|
266
|
+
finally { if (e_2) throw e_2.error; }
|
|
267
|
+
}
|
|
268
|
+
return nodeList;
|
|
269
|
+
}
|
|
270
|
+
else if (rest.length === 0) {
|
|
271
|
+
return [AbstractDOM.getParentElement(element)];
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
return this.querySelectorElement(AbstractDOM.getParentElement(element), rest);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
var matches = element.querySelectorAll(q);
|
|
278
|
+
if (matches.length === 0 && element.shadowRoot) {
|
|
279
|
+
matches = element.shadowRoot.querySelectorAll(q);
|
|
280
|
+
}
|
|
281
|
+
return matches;
|
|
282
|
+
};
|
|
283
|
+
AbstractDOM.prototype.querySelector = function (q) {
|
|
284
|
+
return this.rootElement.querySelector(q);
|
|
285
|
+
};
|
|
286
|
+
AbstractDOM.prototype.exec = function (code) {
|
|
287
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
288
|
+
var tree;
|
|
289
|
+
return __generator(this, function (_a) {
|
|
290
|
+
switch (_a.label) {
|
|
291
|
+
case 0:
|
|
292
|
+
tree = new AST_1.Tree(code);
|
|
293
|
+
return [4 /*yield*/, tree.prepare(this.root.scope, this)];
|
|
294
|
+
case 1:
|
|
295
|
+
_a.sent();
|
|
296
|
+
return [4 /*yield*/, tree.evaluate(this.root.scope, this)];
|
|
297
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
AbstractDOM.prototype.evaluate = function () {
|
|
303
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
304
|
+
var _a, _b, tag, e_3_1;
|
|
305
|
+
var e_3, _c;
|
|
306
|
+
return __generator(this, function (_d) {
|
|
307
|
+
switch (_d.label) {
|
|
308
|
+
case 0:
|
|
309
|
+
clearTimeout(this.evaluateTimeout);
|
|
310
|
+
_d.label = 1;
|
|
311
|
+
case 1:
|
|
312
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
313
|
+
_a = __values(this.tags), _b = _a.next();
|
|
314
|
+
_d.label = 2;
|
|
315
|
+
case 2:
|
|
316
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
317
|
+
tag = _b.value;
|
|
318
|
+
return [4 /*yield*/, tag.evaluate()];
|
|
319
|
+
case 3:
|
|
320
|
+
_d.sent();
|
|
321
|
+
_d.label = 4;
|
|
322
|
+
case 4:
|
|
323
|
+
_b = _a.next();
|
|
324
|
+
return [3 /*break*/, 2];
|
|
325
|
+
case 5: return [3 /*break*/, 8];
|
|
326
|
+
case 6:
|
|
327
|
+
e_3_1 = _d.sent();
|
|
328
|
+
e_3 = { error: e_3_1 };
|
|
329
|
+
return [3 /*break*/, 8];
|
|
330
|
+
case 7:
|
|
331
|
+
try {
|
|
332
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
333
|
+
}
|
|
334
|
+
finally { if (e_3) throw e_3.error; }
|
|
335
|
+
return [7 /*endfinally*/];
|
|
336
|
+
case 8: return [2 /*return*/];
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
AbstractDOM.prototype.mutation = function (mutations) {
|
|
342
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
343
|
+
var mutations_1, mutations_1_1, mutation, tag, _a, _b, ele, toRemove, e_4_1, e_5_1;
|
|
344
|
+
var e_5, _c, e_4, _d;
|
|
345
|
+
return __generator(this, function (_e) {
|
|
346
|
+
switch (_e.label) {
|
|
347
|
+
case 0:
|
|
348
|
+
_e.trys.push([0, 13, 14, 15]);
|
|
349
|
+
mutations_1 = __values(mutations), mutations_1_1 = mutations_1.next();
|
|
350
|
+
_e.label = 1;
|
|
351
|
+
case 1:
|
|
352
|
+
if (!!mutations_1_1.done) return [3 /*break*/, 12];
|
|
353
|
+
mutation = mutations_1_1.value;
|
|
354
|
+
return [4 /*yield*/, this.getTagForElement(mutation.target)];
|
|
355
|
+
case 2:
|
|
356
|
+
tag = _e.sent();
|
|
357
|
+
if (tag) {
|
|
358
|
+
tag.mutate(mutation);
|
|
359
|
+
}
|
|
360
|
+
if (!(mutation.type === 'attributes' && mutation.attributeName === 'class')) return [3 /*break*/, 4];
|
|
361
|
+
return [4 /*yield*/, ClassNode_1.ClassNode.checkForClassChanges(mutation.target, this, tag)];
|
|
362
|
+
case 3:
|
|
363
|
+
_e.sent();
|
|
364
|
+
_e.label = 4;
|
|
365
|
+
case 4:
|
|
366
|
+
_e.trys.push([4, 9, 10, 11]);
|
|
367
|
+
_a = (e_4 = void 0, __values(Array.from(mutation.removedNodes))), _b = _a.next();
|
|
368
|
+
_e.label = 5;
|
|
369
|
+
case 5:
|
|
370
|
+
if (!!_b.done) return [3 /*break*/, 8];
|
|
371
|
+
ele = _b.value;
|
|
372
|
+
return [4 /*yield*/, this.getTagForElement(ele)];
|
|
373
|
+
case 6:
|
|
374
|
+
toRemove = _e.sent();
|
|
375
|
+
if (toRemove) {
|
|
376
|
+
toRemove.deconstruct();
|
|
377
|
+
}
|
|
378
|
+
_e.label = 7;
|
|
379
|
+
case 7:
|
|
380
|
+
_b = _a.next();
|
|
381
|
+
return [3 /*break*/, 5];
|
|
382
|
+
case 8: return [3 /*break*/, 11];
|
|
383
|
+
case 9:
|
|
384
|
+
e_4_1 = _e.sent();
|
|
385
|
+
e_4 = { error: e_4_1 };
|
|
386
|
+
return [3 /*break*/, 11];
|
|
387
|
+
case 10:
|
|
388
|
+
try {
|
|
389
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
390
|
+
}
|
|
391
|
+
finally { if (e_4) throw e_4.error; }
|
|
392
|
+
return [7 /*endfinally*/];
|
|
393
|
+
case 11:
|
|
394
|
+
mutations_1_1 = mutations_1.next();
|
|
395
|
+
return [3 /*break*/, 1];
|
|
396
|
+
case 12: return [3 /*break*/, 15];
|
|
397
|
+
case 13:
|
|
398
|
+
e_5_1 = _e.sent();
|
|
399
|
+
e_5 = { error: e_5_1 };
|
|
400
|
+
return [3 /*break*/, 15];
|
|
401
|
+
case 14:
|
|
402
|
+
try {
|
|
403
|
+
if (mutations_1_1 && !mutations_1_1.done && (_c = mutations_1.return)) _c.call(mutations_1);
|
|
404
|
+
}
|
|
405
|
+
finally { if (e_5) throw e_5.error; }
|
|
406
|
+
return [7 /*endfinally*/];
|
|
407
|
+
case 15: return [2 /*return*/];
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
AbstractDOM.prototype.discover = function (ele, forComponent) {
|
|
413
|
+
if (forComponent === void 0) { forComponent = false; }
|
|
414
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
415
|
+
var discovered, checkElement, scanChildren;
|
|
416
|
+
var _this = this;
|
|
417
|
+
return __generator(this, function (_a) {
|
|
418
|
+
discovered = [];
|
|
419
|
+
checkElement = function (e) {
|
|
420
|
+
var _a, _b;
|
|
421
|
+
if (!forComponent && ((_a = e === null || e === void 0 ? void 0 : e.tagName) === null || _a === void 0 ? void 0 : _a.includes('-'))) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
if (Registry_1.Registry.instance.tags.has((_b = e === null || e === void 0 ? void 0 : e.tagName) === null || _b === void 0 ? void 0 : _b.toLowerCase())) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
if (ElementHelper_1.ElementHelper.hasVisionAttribute(e)) {
|
|
428
|
+
if ((!forComponent && e.hasAttribute('slot')))
|
|
429
|
+
return false;
|
|
430
|
+
if (_this.queued.indexOf(e) > -1)
|
|
431
|
+
return false;
|
|
432
|
+
_this.queued.push(e);
|
|
433
|
+
discovered.push(e);
|
|
434
|
+
}
|
|
435
|
+
return true;
|
|
436
|
+
};
|
|
437
|
+
scanChildren = function (e) {
|
|
438
|
+
var e_6, _a;
|
|
439
|
+
try {
|
|
440
|
+
for (var _b = __values(Array.from(e.children)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
441
|
+
var element = _c.value;
|
|
442
|
+
if (!checkElement(element))
|
|
443
|
+
continue;
|
|
444
|
+
if (element.tagName.toLowerCase() !== 'template')
|
|
445
|
+
scanChildren(element);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
449
|
+
finally {
|
|
450
|
+
try {
|
|
451
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
452
|
+
}
|
|
453
|
+
finally { if (e_6) throw e_6.error; }
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
checkElement(ele);
|
|
457
|
+
scanChildren(ele);
|
|
458
|
+
return [2 /*return*/, discovered];
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
};
|
|
462
|
+
AbstractDOM.prototype.buildTag = function (element, returnExisting, cls) {
|
|
463
|
+
if (returnExisting === void 0) { returnExisting = false; }
|
|
464
|
+
if (cls === void 0) { cls = Tag_1.Tag; }
|
|
465
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
466
|
+
var tag;
|
|
467
|
+
return __generator(this, function (_a) {
|
|
468
|
+
if (element[Tag_1.Tag.TaggedVariable])
|
|
469
|
+
return [2 /*return*/, returnExisting ? element[Tag_1.Tag.TaggedVariable] : null];
|
|
470
|
+
if (element.tagName.toLowerCase() === 'slot')
|
|
471
|
+
cls = SlotTag_1.SlotTag;
|
|
472
|
+
else if (element.hasAttribute('slot'))
|
|
473
|
+
cls = SlottedTag_1.SlottedTag;
|
|
474
|
+
tag = new cls(element, this);
|
|
475
|
+
this.tags.push(tag);
|
|
476
|
+
return [2 /*return*/, tag];
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
};
|
|
480
|
+
AbstractDOM.prototype.setupTags = function (tags) {
|
|
481
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
482
|
+
var tags_1, tags_1_1, tag, e_7_1, tags_2, tags_2_1, tag, e_8_1, tags_3, tags_3_1, tag, e_9_1, tags_4, tags_4_1, tag, e_10_1, tags_5, tags_5_1, tag, e_11_1, tags_6, tags_6_1, tag, e_12_1, tags_7, tags_7_1, tag;
|
|
483
|
+
var e_7, _a, e_8, _b, e_9, _c, e_10, _d, e_11, _e, e_12, _f, e_13, _g;
|
|
484
|
+
return __generator(this, function (_h) {
|
|
485
|
+
switch (_h.label) {
|
|
486
|
+
case 0:
|
|
487
|
+
_h.trys.push([0, 5, 6, 7]);
|
|
488
|
+
tags_1 = __values(tags), tags_1_1 = tags_1.next();
|
|
489
|
+
_h.label = 1;
|
|
490
|
+
case 1:
|
|
491
|
+
if (!!tags_1_1.done) return [3 /*break*/, 4];
|
|
492
|
+
tag = tags_1_1.value;
|
|
493
|
+
return [4 /*yield*/, tag.buildAttributes()];
|
|
494
|
+
case 2:
|
|
495
|
+
_h.sent();
|
|
496
|
+
_h.label = 3;
|
|
497
|
+
case 3:
|
|
498
|
+
tags_1_1 = tags_1.next();
|
|
499
|
+
return [3 /*break*/, 1];
|
|
500
|
+
case 4: return [3 /*break*/, 7];
|
|
501
|
+
case 5:
|
|
502
|
+
e_7_1 = _h.sent();
|
|
503
|
+
e_7 = { error: e_7_1 };
|
|
504
|
+
return [3 /*break*/, 7];
|
|
505
|
+
case 6:
|
|
506
|
+
try {
|
|
507
|
+
if (tags_1_1 && !tags_1_1.done && (_a = tags_1.return)) _a.call(tags_1);
|
|
508
|
+
}
|
|
509
|
+
finally { if (e_7) throw e_7.error; }
|
|
510
|
+
return [7 /*endfinally*/];
|
|
511
|
+
case 7:
|
|
512
|
+
_h.trys.push([7, 12, 13, 14]);
|
|
513
|
+
tags_2 = __values(tags), tags_2_1 = tags_2.next();
|
|
514
|
+
_h.label = 8;
|
|
515
|
+
case 8:
|
|
516
|
+
if (!!tags_2_1.done) return [3 /*break*/, 11];
|
|
517
|
+
tag = tags_2_1.value;
|
|
518
|
+
return [4 /*yield*/, tag.compileAttributes()];
|
|
519
|
+
case 9:
|
|
520
|
+
_h.sent();
|
|
521
|
+
_h.label = 10;
|
|
522
|
+
case 10:
|
|
523
|
+
tags_2_1 = tags_2.next();
|
|
524
|
+
return [3 /*break*/, 8];
|
|
525
|
+
case 11: return [3 /*break*/, 14];
|
|
526
|
+
case 12:
|
|
527
|
+
e_8_1 = _h.sent();
|
|
528
|
+
e_8 = { error: e_8_1 };
|
|
529
|
+
return [3 /*break*/, 14];
|
|
530
|
+
case 13:
|
|
531
|
+
try {
|
|
532
|
+
if (tags_2_1 && !tags_2_1.done && (_b = tags_2.return)) _b.call(tags_2);
|
|
533
|
+
}
|
|
534
|
+
finally { if (e_8) throw e_8.error; }
|
|
535
|
+
return [7 /*endfinally*/];
|
|
536
|
+
case 14:
|
|
537
|
+
_h.trys.push([14, 19, 20, 21]);
|
|
538
|
+
tags_3 = __values(tags), tags_3_1 = tags_3.next();
|
|
539
|
+
_h.label = 15;
|
|
540
|
+
case 15:
|
|
541
|
+
if (!!tags_3_1.done) return [3 /*break*/, 18];
|
|
542
|
+
tag = tags_3_1.value;
|
|
543
|
+
return [4 /*yield*/, tag.setupAttributes()];
|
|
544
|
+
case 16:
|
|
545
|
+
_h.sent();
|
|
546
|
+
_h.label = 17;
|
|
547
|
+
case 17:
|
|
548
|
+
tags_3_1 = tags_3.next();
|
|
549
|
+
return [3 /*break*/, 15];
|
|
550
|
+
case 18: return [3 /*break*/, 21];
|
|
551
|
+
case 19:
|
|
552
|
+
e_9_1 = _h.sent();
|
|
553
|
+
e_9 = { error: e_9_1 };
|
|
554
|
+
return [3 /*break*/, 21];
|
|
555
|
+
case 20:
|
|
556
|
+
try {
|
|
557
|
+
if (tags_3_1 && !tags_3_1.done && (_c = tags_3.return)) _c.call(tags_3);
|
|
558
|
+
}
|
|
559
|
+
finally { if (e_9) throw e_9.error; }
|
|
560
|
+
return [7 /*endfinally*/];
|
|
561
|
+
case 21:
|
|
562
|
+
_h.trys.push([21, 26, 27, 28]);
|
|
563
|
+
tags_4 = __values(tags), tags_4_1 = tags_4.next();
|
|
564
|
+
_h.label = 22;
|
|
565
|
+
case 22:
|
|
566
|
+
if (!!tags_4_1.done) return [3 /*break*/, 25];
|
|
567
|
+
tag = tags_4_1.value;
|
|
568
|
+
return [4 /*yield*/, tag.extractAttributes()];
|
|
569
|
+
case 23:
|
|
570
|
+
_h.sent();
|
|
571
|
+
_h.label = 24;
|
|
572
|
+
case 24:
|
|
573
|
+
tags_4_1 = tags_4.next();
|
|
574
|
+
return [3 /*break*/, 22];
|
|
575
|
+
case 25: return [3 /*break*/, 28];
|
|
576
|
+
case 26:
|
|
577
|
+
e_10_1 = _h.sent();
|
|
578
|
+
e_10 = { error: e_10_1 };
|
|
579
|
+
return [3 /*break*/, 28];
|
|
580
|
+
case 27:
|
|
581
|
+
try {
|
|
582
|
+
if (tags_4_1 && !tags_4_1.done && (_d = tags_4.return)) _d.call(tags_4);
|
|
583
|
+
}
|
|
584
|
+
finally { if (e_10) throw e_10.error; }
|
|
585
|
+
return [7 /*endfinally*/];
|
|
586
|
+
case 28:
|
|
587
|
+
_h.trys.push([28, 33, 34, 35]);
|
|
588
|
+
tags_5 = __values(tags), tags_5_1 = tags_5.next();
|
|
589
|
+
_h.label = 29;
|
|
590
|
+
case 29:
|
|
591
|
+
if (!!tags_5_1.done) return [3 /*break*/, 32];
|
|
592
|
+
tag = tags_5_1.value;
|
|
593
|
+
return [4 /*yield*/, tag.connectAttributes()];
|
|
594
|
+
case 30:
|
|
595
|
+
_h.sent();
|
|
596
|
+
_h.label = 31;
|
|
597
|
+
case 31:
|
|
598
|
+
tags_5_1 = tags_5.next();
|
|
599
|
+
return [3 /*break*/, 29];
|
|
600
|
+
case 32: return [3 /*break*/, 35];
|
|
601
|
+
case 33:
|
|
602
|
+
e_11_1 = _h.sent();
|
|
603
|
+
e_11 = { error: e_11_1 };
|
|
604
|
+
return [3 /*break*/, 35];
|
|
605
|
+
case 34:
|
|
606
|
+
try {
|
|
607
|
+
if (tags_5_1 && !tags_5_1.done && (_e = tags_5.return)) _e.call(tags_5);
|
|
608
|
+
}
|
|
609
|
+
finally { if (e_11) throw e_11.error; }
|
|
610
|
+
return [7 /*endfinally*/];
|
|
611
|
+
case 35:
|
|
612
|
+
_h.trys.push([35, 40, 41, 42]);
|
|
613
|
+
tags_6 = __values(tags), tags_6_1 = tags_6.next();
|
|
614
|
+
_h.label = 36;
|
|
615
|
+
case 36:
|
|
616
|
+
if (!!tags_6_1.done) return [3 /*break*/, 39];
|
|
617
|
+
tag = tags_6_1.value;
|
|
618
|
+
return [4 /*yield*/, tag.finalize()];
|
|
619
|
+
case 37:
|
|
620
|
+
_h.sent();
|
|
621
|
+
this.queued.splice(this.queued.indexOf(tag.element), 1);
|
|
622
|
+
_h.label = 38;
|
|
623
|
+
case 38:
|
|
624
|
+
tags_6_1 = tags_6.next();
|
|
625
|
+
return [3 /*break*/, 36];
|
|
626
|
+
case 39: return [3 /*break*/, 42];
|
|
627
|
+
case 40:
|
|
628
|
+
e_12_1 = _h.sent();
|
|
629
|
+
e_12 = { error: e_12_1 };
|
|
630
|
+
return [3 /*break*/, 42];
|
|
631
|
+
case 41:
|
|
632
|
+
try {
|
|
633
|
+
if (tags_6_1 && !tags_6_1.done && (_f = tags_6.return)) _f.call(tags_6);
|
|
634
|
+
}
|
|
635
|
+
finally { if (e_12) throw e_12.error; }
|
|
636
|
+
return [7 /*endfinally*/];
|
|
637
|
+
case 42:
|
|
638
|
+
try {
|
|
639
|
+
for (tags_7 = __values(tags), tags_7_1 = tags_7.next(); !tags_7_1.done; tags_7_1 = tags_7.next()) {
|
|
640
|
+
tag = tags_7_1.value;
|
|
641
|
+
this.observer.observe(tag.element, {
|
|
642
|
+
attributes: true,
|
|
643
|
+
characterData: true,
|
|
644
|
+
childList: true,
|
|
645
|
+
subtree: true
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
650
|
+
finally {
|
|
651
|
+
try {
|
|
652
|
+
if (tags_7_1 && !tags_7_1.done && (_g = tags_7.return)) _g.call(tags_7);
|
|
653
|
+
}
|
|
654
|
+
finally { if (e_13) throw e_13.error; }
|
|
655
|
+
}
|
|
656
|
+
return [2 /*return*/];
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
});
|
|
660
|
+
};
|
|
661
|
+
AbstractDOM.prototype.buildFrom = function (ele, isRoot, forComponent) {
|
|
662
|
+
if (isRoot === void 0) { isRoot = false; }
|
|
663
|
+
if (forComponent === void 0) { forComponent = false; }
|
|
664
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
665
|
+
var _a, templateNodes, components, _b, _c, n, tag, e_14_1, newTags, toBuild, toBuild_1, toBuild_1_1, element, tag, e_15_1;
|
|
666
|
+
var e_14, _d, e_15, _e;
|
|
667
|
+
return __generator(this, function (_f) {
|
|
668
|
+
switch (_f.label) {
|
|
669
|
+
case 0:
|
|
670
|
+
if (!isRoot) return [3 /*break*/, 3];
|
|
671
|
+
this.rootElement.setAttribute('vsn-root', '');
|
|
672
|
+
_a = this;
|
|
673
|
+
return [4 /*yield*/, this.buildTag(this.rootElement, true)];
|
|
674
|
+
case 1:
|
|
675
|
+
_a._root = _f.sent();
|
|
676
|
+
this._root.createScope(true);
|
|
677
|
+
return [4 /*yield*/, this.setupTags([this._root])];
|
|
678
|
+
case 2:
|
|
679
|
+
_f.sent();
|
|
680
|
+
_f.label = 3;
|
|
681
|
+
case 3:
|
|
682
|
+
templateNodes = this.querySelectorElement(ele, 'template');
|
|
683
|
+
components = [];
|
|
684
|
+
_f.label = 4;
|
|
685
|
+
case 4:
|
|
686
|
+
_f.trys.push([4, 9, 10, 11]);
|
|
687
|
+
_b = __values(Array.from(templateNodes)), _c = _b.next();
|
|
688
|
+
_f.label = 5;
|
|
689
|
+
case 5:
|
|
690
|
+
if (!!_c.done) return [3 /*break*/, 8];
|
|
691
|
+
n = _c.value;
|
|
692
|
+
if (!ElementHelper_1.ElementHelper.hasVisionAttribute(n))
|
|
693
|
+
return [3 /*break*/, 7];
|
|
694
|
+
return [4 /*yield*/, this.buildTag(n)];
|
|
695
|
+
case 6:
|
|
696
|
+
tag = _f.sent();
|
|
697
|
+
if (tag)
|
|
698
|
+
components.push(tag);
|
|
699
|
+
_f.label = 7;
|
|
700
|
+
case 7:
|
|
701
|
+
_c = _b.next();
|
|
702
|
+
return [3 /*break*/, 5];
|
|
703
|
+
case 8: return [3 /*break*/, 11];
|
|
704
|
+
case 9:
|
|
705
|
+
e_14_1 = _f.sent();
|
|
706
|
+
e_14 = { error: e_14_1 };
|
|
707
|
+
return [3 /*break*/, 11];
|
|
708
|
+
case 10:
|
|
709
|
+
try {
|
|
710
|
+
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
711
|
+
}
|
|
712
|
+
finally { if (e_14) throw e_14.error; }
|
|
713
|
+
return [7 /*endfinally*/];
|
|
714
|
+
case 11:
|
|
715
|
+
if (!components.length) return [3 /*break*/, 13];
|
|
716
|
+
return [4 /*yield*/, this.setupTags(components)];
|
|
717
|
+
case 12:
|
|
718
|
+
_f.sent();
|
|
719
|
+
_f.label = 13;
|
|
720
|
+
case 13:
|
|
721
|
+
newTags = [];
|
|
722
|
+
return [4 /*yield*/, this.discover(ele, forComponent)];
|
|
723
|
+
case 14:
|
|
724
|
+
toBuild = _f.sent();
|
|
725
|
+
_f.label = 15;
|
|
726
|
+
case 15:
|
|
727
|
+
_f.trys.push([15, 20, 21, 22]);
|
|
728
|
+
toBuild_1 = __values(toBuild), toBuild_1_1 = toBuild_1.next();
|
|
729
|
+
_f.label = 16;
|
|
730
|
+
case 16:
|
|
731
|
+
if (!!toBuild_1_1.done) return [3 /*break*/, 19];
|
|
732
|
+
element = toBuild_1_1.value;
|
|
733
|
+
return [4 /*yield*/, this.buildTag(element)];
|
|
734
|
+
case 17:
|
|
735
|
+
tag = _f.sent();
|
|
736
|
+
if (tag)
|
|
737
|
+
newTags.push(tag);
|
|
738
|
+
_f.label = 18;
|
|
739
|
+
case 18:
|
|
740
|
+
toBuild_1_1 = toBuild_1.next();
|
|
741
|
+
return [3 /*break*/, 16];
|
|
742
|
+
case 19: return [3 /*break*/, 22];
|
|
743
|
+
case 20:
|
|
744
|
+
e_15_1 = _f.sent();
|
|
745
|
+
e_15 = { error: e_15_1 };
|
|
746
|
+
return [3 /*break*/, 22];
|
|
747
|
+
case 21:
|
|
748
|
+
try {
|
|
749
|
+
if (toBuild_1_1 && !toBuild_1_1.done && (_e = toBuild_1.return)) _e.call(toBuild_1);
|
|
750
|
+
}
|
|
751
|
+
finally { if (e_15) throw e_15.error; }
|
|
752
|
+
return [7 /*endfinally*/];
|
|
753
|
+
case 22: return [4 /*yield*/, this.setupTags(newTags)];
|
|
754
|
+
case 23:
|
|
755
|
+
_f.sent();
|
|
756
|
+
if (isRoot) {
|
|
757
|
+
this._built = true;
|
|
758
|
+
this.dispatch('builtRoot');
|
|
759
|
+
}
|
|
760
|
+
this.dispatch('built', newTags);
|
|
761
|
+
return [2 /*return*/, newTags];
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
});
|
|
765
|
+
};
|
|
766
|
+
AbstractDOM.prototype.getTagsForElements = function (elements, create) {
|
|
767
|
+
if (create === void 0) { create = false; }
|
|
768
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
769
|
+
var tags, found, elements_2, elements_2_1, element, notFound, i, element, notFound_1, notFound_1_1, element, _a, _b, e_16_1;
|
|
770
|
+
var e_17, _c, e_16, _d;
|
|
771
|
+
return __generator(this, function (_e) {
|
|
772
|
+
switch (_e.label) {
|
|
773
|
+
case 0:
|
|
774
|
+
tags = new TagList_1.TagList();
|
|
775
|
+
found = [];
|
|
776
|
+
try {
|
|
777
|
+
for (elements_2 = __values(elements), elements_2_1 = elements_2.next(); !elements_2_1.done; elements_2_1 = elements_2.next()) {
|
|
778
|
+
element = elements_2_1.value;
|
|
779
|
+
if (element && element[Tag_1.Tag.TaggedVariable]) {
|
|
780
|
+
tags.push(element[Tag_1.Tag.TaggedVariable]);
|
|
781
|
+
found.push(element);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
786
|
+
finally {
|
|
787
|
+
try {
|
|
788
|
+
if (elements_2_1 && !elements_2_1.done && (_c = elements_2.return)) _c.call(elements_2);
|
|
789
|
+
}
|
|
790
|
+
finally { if (e_17) throw e_17.error; }
|
|
791
|
+
}
|
|
792
|
+
if (!create) return [3 /*break*/, 8];
|
|
793
|
+
notFound = __spreadArray([], __read(elements));
|
|
794
|
+
for (i = notFound.length; i >= 0; i--) {
|
|
795
|
+
element = notFound[i];
|
|
796
|
+
if (found.indexOf(element) > -1) {
|
|
797
|
+
notFound.splice(i, 1);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
_e.label = 1;
|
|
801
|
+
case 1:
|
|
802
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
803
|
+
notFound_1 = __values(notFound), notFound_1_1 = notFound_1.next();
|
|
804
|
+
_e.label = 2;
|
|
805
|
+
case 2:
|
|
806
|
+
if (!!notFound_1_1.done) return [3 /*break*/, 5];
|
|
807
|
+
element = notFound_1_1.value;
|
|
808
|
+
_b = (_a = tags).push;
|
|
809
|
+
return [4 /*yield*/, this.getTagForElement(element, create)];
|
|
810
|
+
case 3:
|
|
811
|
+
_b.apply(_a, [_e.sent()]);
|
|
812
|
+
_e.label = 4;
|
|
813
|
+
case 4:
|
|
814
|
+
notFound_1_1 = notFound_1.next();
|
|
815
|
+
return [3 /*break*/, 2];
|
|
816
|
+
case 5: return [3 /*break*/, 8];
|
|
817
|
+
case 6:
|
|
818
|
+
e_16_1 = _e.sent();
|
|
819
|
+
e_16 = { error: e_16_1 };
|
|
820
|
+
return [3 /*break*/, 8];
|
|
821
|
+
case 7:
|
|
822
|
+
try {
|
|
823
|
+
if (notFound_1_1 && !notFound_1_1.done && (_d = notFound_1.return)) _d.call(notFound_1);
|
|
824
|
+
}
|
|
825
|
+
finally { if (e_16) throw e_16.error; }
|
|
826
|
+
return [7 /*endfinally*/];
|
|
827
|
+
case 8: return [2 /*return*/, tags];
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
});
|
|
831
|
+
};
|
|
832
|
+
AbstractDOM.prototype.getTagForElement = function (element, create, forComponent) {
|
|
833
|
+
if (create === void 0) { create = false; }
|
|
834
|
+
if (forComponent === void 0) { forComponent = false; }
|
|
835
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
836
|
+
return __generator(this, function (_a) {
|
|
837
|
+
switch (_a.label) {
|
|
838
|
+
case 0:
|
|
839
|
+
if (element && element[Tag_1.Tag.TaggedVariable])
|
|
840
|
+
return [2 /*return*/, element[Tag_1.Tag.TaggedVariable]];
|
|
841
|
+
if (!(element && create)) return [3 /*break*/, 3];
|
|
842
|
+
if (element instanceof HTMLElement)
|
|
843
|
+
element.setAttribute('vsn-ref', '');
|
|
844
|
+
return [4 /*yield*/, this.buildFrom(element.parentElement || element, false, forComponent)];
|
|
845
|
+
case 1:
|
|
846
|
+
_a.sent();
|
|
847
|
+
return [4 /*yield*/, this.getTagForElement(element, false)];
|
|
848
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
849
|
+
case 3: return [2 /*return*/, null];
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
});
|
|
853
|
+
};
|
|
854
|
+
AbstractDOM.prototype.getTagForScope = function (scope) {
|
|
855
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
856
|
+
var _a, _b, tag;
|
|
857
|
+
var e_18, _c;
|
|
858
|
+
return __generator(this, function (_d) {
|
|
859
|
+
try {
|
|
860
|
+
for (_a = __values(this.tags), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
861
|
+
tag = _b.value;
|
|
862
|
+
if (tag.uniqueScope && tag.scope === scope)
|
|
863
|
+
return [2 /*return*/, tag];
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
867
|
+
finally {
|
|
868
|
+
try {
|
|
869
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
870
|
+
}
|
|
871
|
+
finally { if (e_18) throw e_18.error; }
|
|
872
|
+
}
|
|
873
|
+
return [2 /*return*/, null];
|
|
874
|
+
});
|
|
875
|
+
});
|
|
876
|
+
};
|
|
877
|
+
AbstractDOM.prototype.resetBranch = function (e) {
|
|
878
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
879
|
+
var tag, children, children_1, children_1_1, t, e_19_1;
|
|
880
|
+
var e_19, _a;
|
|
881
|
+
return __generator(this, function (_b) {
|
|
882
|
+
switch (_b.label) {
|
|
883
|
+
case 0:
|
|
884
|
+
if (e instanceof Tag_1.Tag)
|
|
885
|
+
e = e.element;
|
|
886
|
+
tag = e[Tag_1.Tag.TaggedVariable];
|
|
887
|
+
if (tag) {
|
|
888
|
+
tag.findParentTag();
|
|
889
|
+
}
|
|
890
|
+
children = Array.from(e.children);
|
|
891
|
+
_b.label = 1;
|
|
892
|
+
case 1:
|
|
893
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
894
|
+
children_1 = __values(children), children_1_1 = children_1.next();
|
|
895
|
+
_b.label = 2;
|
|
896
|
+
case 2:
|
|
897
|
+
if (!!children_1_1.done) return [3 /*break*/, 5];
|
|
898
|
+
t = children_1_1.value;
|
|
899
|
+
return [4 /*yield*/, this.resetBranch(t)];
|
|
900
|
+
case 3:
|
|
901
|
+
_b.sent();
|
|
902
|
+
_b.label = 4;
|
|
903
|
+
case 4:
|
|
904
|
+
children_1_1 = children_1.next();
|
|
905
|
+
return [3 /*break*/, 2];
|
|
906
|
+
case 5: return [3 /*break*/, 8];
|
|
907
|
+
case 6:
|
|
908
|
+
e_19_1 = _b.sent();
|
|
909
|
+
e_19 = { error: e_19_1 };
|
|
910
|
+
return [3 /*break*/, 8];
|
|
911
|
+
case 7:
|
|
912
|
+
try {
|
|
913
|
+
if (children_1_1 && !children_1_1.done && (_a = children_1.return)) _a.call(children_1);
|
|
914
|
+
}
|
|
915
|
+
finally { if (e_19) throw e_19.error; }
|
|
916
|
+
return [7 /*endfinally*/];
|
|
917
|
+
case 8: return [2 /*return*/];
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
});
|
|
921
|
+
};
|
|
922
|
+
AbstractDOM.getParentElement = function (element) {
|
|
923
|
+
if (element.parentElement) {
|
|
924
|
+
return element.parentElement;
|
|
925
|
+
}
|
|
926
|
+
else if (element.assignedSlot) {
|
|
927
|
+
return element.assignedSlot.parentElement;
|
|
928
|
+
}
|
|
929
|
+
else if (element['shadowParent']) {
|
|
930
|
+
return element['shadowParent'];
|
|
931
|
+
}
|
|
932
|
+
return null;
|
|
933
|
+
};
|
|
934
|
+
return AbstractDOM;
|
|
935
|
+
}(EventDispatcher_1.EventDispatcher));
|
|
936
|
+
exports.AbstractDOM = AbstractDOM;
|
|
937
|
+
//# sourceMappingURL=AbstractDOM.js.map
|