@webtides/element-js 0.7.3 → 1.0.0-alpha.2
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/README.md +2 -2
- package/dist/index.js +688 -969
- package/dist/index.js.map +4 -4
- package/index.js +2 -1
- package/package.json +16 -20
- package/src/BaseElement.js +102 -66
- package/src/StyledElement.js +34 -12
- package/src/TemplateElement.js +27 -7
- package/src/dom-parts/AttributePart.js +160 -0
- package/src/dom-parts/ChildNodePart.js +343 -0
- package/src/dom-parts/NodePart.js +37 -0
- package/src/dom-parts/Part.js +12 -0
- package/src/dom-parts/TemplatePart.js +140 -0
- package/src/dom-parts/TemplateResult.js +332 -0
- package/src/dom-parts/directives.js +109 -0
- package/src/dom-parts/html.js +12 -0
- package/src/dom-parts/render.js +10 -0
- package/src/util/AttributeParser.js +62 -29
- package/src/util/DOMHelper.js +247 -5
- package/src/util/Directive.js +35 -0
- package/src/util/Store.js +25 -4
- package/src/util/defineElement.js +2 -2
- package/src/util/i18n.js +3 -3
- package/src/util/toString.js +2 -2
- package/CHANGELOG.md +0 -142
- package/src/renderer/vanilla/TemplateElement.js +0 -50
- package/src/renderer/vanilla/index.js +0 -18
- package/src/renderer/vanilla/util/directives.js +0 -78
- package/src/renderer/vanilla/util/html.js +0 -65
- package/src/renderer/vanilla/util/render.js +0 -149
package/dist/index.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2
3
|
var __publicField = (obj, key, value) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (key in obj)
|
|
6
|
-
return __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value});
|
|
7
|
-
return obj[key] = value;
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
8
6
|
};
|
|
9
7
|
|
|
10
8
|
// src/util/AttributeParser.js
|
|
11
9
|
function isObjectLike(value) {
|
|
12
10
|
return typeof value == "object" && value !== null;
|
|
13
11
|
}
|
|
14
|
-
function isJSON(
|
|
12
|
+
function isJSON(value) {
|
|
15
13
|
try {
|
|
16
|
-
return JSON.parse(
|
|
14
|
+
return JSON.parse(value) && !!value;
|
|
17
15
|
} catch (e) {
|
|
18
16
|
return false;
|
|
19
17
|
}
|
|
@@ -60,8 +58,23 @@ function dashToCamel(string) {
|
|
|
60
58
|
function camelToDash(string) {
|
|
61
59
|
return string.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
62
60
|
}
|
|
61
|
+
function encodeAttribute(attribute2) {
|
|
62
|
+
return `${attribute2}`.replace(/'/g, "'").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">").replace(/\r\n/g, "\n").replace(/[\r\n]/g, "\n");
|
|
63
|
+
}
|
|
63
64
|
|
|
64
65
|
// src/util/DOMHelper.js
|
|
66
|
+
var ELEMENT_NODE = 1;
|
|
67
|
+
var COMMENT_NODE = 8;
|
|
68
|
+
var getNodePath = (node) => {
|
|
69
|
+
const path = [];
|
|
70
|
+
let parentNode = node.parentNode;
|
|
71
|
+
while (parentNode) {
|
|
72
|
+
path.push([...parentNode.childNodes].indexOf(node));
|
|
73
|
+
node = parentNode;
|
|
74
|
+
parentNode = node.parentNode;
|
|
75
|
+
}
|
|
76
|
+
return path;
|
|
77
|
+
};
|
|
65
78
|
function getShadowParentOrBody(element) {
|
|
66
79
|
if (element instanceof ShadowRoot) {
|
|
67
80
|
return element;
|
|
@@ -73,18 +86,25 @@ function getShadowParentOrBody(element) {
|
|
|
73
86
|
}
|
|
74
87
|
return document.body;
|
|
75
88
|
}
|
|
76
|
-
var supportsAdoptingStyleSheets = () =>
|
|
77
|
-
|
|
89
|
+
var supportsAdoptingStyleSheets = () => {
|
|
90
|
+
return "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype;
|
|
91
|
+
};
|
|
92
|
+
var convertStringToTemplate = (string) => {
|
|
93
|
+
var _a;
|
|
94
|
+
const template = (_a = globalThis.document) == null ? void 0 : _a.createElement("template");
|
|
95
|
+
template.innerHTML = string.trimStart().trimEnd();
|
|
96
|
+
return template.content;
|
|
97
|
+
};
|
|
78
98
|
|
|
79
99
|
// src/util/Store.js
|
|
80
100
|
var Store = class {
|
|
81
101
|
constructor(value) {
|
|
82
|
-
__publicField(this, "_observer", new Set());
|
|
102
|
+
__publicField(this, "_observer", /* @__PURE__ */ new Set());
|
|
83
103
|
__publicField(this, "_singlePropertyMode", false);
|
|
84
104
|
__publicField(this, "_state", {});
|
|
85
105
|
this._singlePropertyMode = arguments.length > 0 && !isObjectLike(value);
|
|
86
|
-
const specificValues = this._singlePropertyMode ? {value} : value;
|
|
87
|
-
this._state = {...!this._singlePropertyMode && this.properties(), ...specificValues};
|
|
106
|
+
const specificValues = this._singlePropertyMode ? { value } : value;
|
|
107
|
+
this._state = { ...!this._singlePropertyMode && this.properties(), ...specificValues };
|
|
88
108
|
Object.entries(this._state).map(([key, value2]) => {
|
|
89
109
|
Object.defineProperty(this, key, {
|
|
90
110
|
get: () => {
|
|
@@ -184,23 +204,19 @@ var BaseElement = class extends HTMLElement {
|
|
|
184
204
|
propertyOptions: {},
|
|
185
205
|
...options
|
|
186
206
|
};
|
|
187
|
-
if (options.childListUpdate !== void 0 && options.childListUpdate !== null) {
|
|
188
|
-
this._options.mutationObserverOptions.childList = options.childListUpdate;
|
|
189
|
-
console.warn(`[${this.localName}] Using the "childListUpdate" option is deprecated and will be removed before 1.0! Please use the "mutationObserverOptions" dictionary instead. See the docs for more info`);
|
|
190
|
-
}
|
|
191
207
|
}
|
|
192
208
|
connectedCallback() {
|
|
193
209
|
this.defineAttributesAsProperties();
|
|
194
210
|
this.defineProperties();
|
|
195
|
-
this.defineComputedProperties();
|
|
196
211
|
this.definePropertyInjection();
|
|
197
212
|
this.defineObserver();
|
|
198
213
|
if (this.hasAttribute("defer-update") || this._options.deferUpdate) {
|
|
199
214
|
this.registerEventsAndRefs();
|
|
200
215
|
this.triggerHook("connected");
|
|
201
216
|
} else {
|
|
202
|
-
this.requestUpdate({notify: false}).then(() => {
|
|
217
|
+
this.requestUpdate({ notify: false }).then(() => {
|
|
203
218
|
this.triggerHook("connected");
|
|
219
|
+
this.triggerHook("afterUpdate");
|
|
204
220
|
});
|
|
205
221
|
}
|
|
206
222
|
}
|
|
@@ -208,7 +224,10 @@ var BaseElement = class extends HTMLElement {
|
|
|
208
224
|
this._mutationObserver = new MutationObserver((mutations) => {
|
|
209
225
|
mutations.forEach((mutation) => {
|
|
210
226
|
if (mutation.type === "attributes" && mutation.target === this && this._state.hasOwnProperty(dashToCamel(mutation.attributeName))) {
|
|
211
|
-
this[dashToCamel(mutation.attributeName)] = parseAttribute(
|
|
227
|
+
this[dashToCamel(mutation.attributeName)] = parseAttribute(
|
|
228
|
+
this.getAttribute(mutation.attributeName),
|
|
229
|
+
this._options.propertyOptions[dashToCamel(mutation.attributeName)]
|
|
230
|
+
);
|
|
212
231
|
}
|
|
213
232
|
if (mutation.type === "attributes" && mutation.target !== this) {
|
|
214
233
|
this.requestUpdate();
|
|
@@ -239,7 +258,7 @@ var BaseElement = class extends HTMLElement {
|
|
|
239
258
|
});
|
|
240
259
|
this.triggerHook("disconnected");
|
|
241
260
|
}
|
|
242
|
-
requestUpdate(options = {notify: true}) {
|
|
261
|
+
requestUpdate(options = { notify: true }) {
|
|
243
262
|
if (options.notify === true) {
|
|
244
263
|
this.triggerHook("beforeUpdate");
|
|
245
264
|
}
|
|
@@ -248,19 +267,19 @@ var BaseElement = class extends HTMLElement {
|
|
|
248
267
|
this._batchUpdate = false;
|
|
249
268
|
}
|
|
250
269
|
return new Promise((resolve, reject) => {
|
|
251
|
-
this._requestedUpdates.push({resolve, reject});
|
|
270
|
+
this._requestedUpdates.push({ resolve, reject });
|
|
252
271
|
this._batchUpdate = requestAnimationFrame(() => {
|
|
253
272
|
try {
|
|
254
273
|
this.update(options);
|
|
255
|
-
this._requestedUpdates.forEach(({resolve: resolve2, reject: reject2}) => resolve2());
|
|
274
|
+
this._requestedUpdates.forEach(({ resolve: resolve2, reject: reject2 }) => resolve2());
|
|
256
275
|
} catch (e) {
|
|
257
|
-
this._requestedUpdates.forEach(({resolve: resolve2, reject: reject2}) => reject2(e));
|
|
276
|
+
this._requestedUpdates.forEach(({ resolve: resolve2, reject: reject2 }) => reject2(e));
|
|
258
277
|
}
|
|
259
278
|
this._requestedUpdates = [];
|
|
260
279
|
});
|
|
261
280
|
});
|
|
262
281
|
}
|
|
263
|
-
update(options = {notify: true}) {
|
|
282
|
+
update(options = { notify: true }) {
|
|
264
283
|
this.registerEventsAndRefs();
|
|
265
284
|
if (options.notify === true) {
|
|
266
285
|
this.triggerHook("afterUpdate");
|
|
@@ -272,19 +291,19 @@ var BaseElement = class extends HTMLElement {
|
|
|
272
291
|
}
|
|
273
292
|
defineAttributesAsProperties() {
|
|
274
293
|
const ignoreAttributes = ["class", "style"];
|
|
275
|
-
Array.from(this.attributes).filter((
|
|
276
|
-
return !ignoreAttributes.includes(
|
|
277
|
-
}).forEach((
|
|
278
|
-
const name = dashToCamel(
|
|
294
|
+
Array.from(this.attributes).filter((attribute2) => {
|
|
295
|
+
return !ignoreAttributes.includes(attribute2.name);
|
|
296
|
+
}).forEach((attribute2) => {
|
|
297
|
+
const name = dashToCamel(attribute2.name);
|
|
279
298
|
const parseOptions = this._options.propertyOptions[name];
|
|
280
|
-
this.defineProperty(name, parseAttribute(
|
|
299
|
+
this.defineProperty(name, parseAttribute(attribute2.value, parseOptions), true);
|
|
281
300
|
});
|
|
282
301
|
}
|
|
283
302
|
properties() {
|
|
284
303
|
return {};
|
|
285
304
|
}
|
|
286
305
|
defineProperties() {
|
|
287
|
-
Object.keys({...this.injectProperties(), ...this.properties()}).forEach((prop) => {
|
|
306
|
+
Object.keys({ ...this.injectProperties(), ...this.properties() }).forEach((prop) => {
|
|
288
307
|
const value = this[prop] || this.properties()[prop];
|
|
289
308
|
this.defineProperty(prop, value);
|
|
290
309
|
});
|
|
@@ -298,7 +317,7 @@ var BaseElement = class extends HTMLElement {
|
|
|
298
317
|
return;
|
|
299
318
|
}
|
|
300
319
|
if (!reflectAttribute && ((_a = this._options.propertyOptions[property]) == null ? void 0 : _a.reflect)) {
|
|
301
|
-
this.reflectProperty({property, newValue: value});
|
|
320
|
+
this.reflectProperty({ property, newValue: value });
|
|
302
321
|
}
|
|
303
322
|
if (((_b = this._options.propertyOptions[property]) == null ? void 0 : _b.reflect) === false) {
|
|
304
323
|
this.removeAttribute(camelToDash(property));
|
|
@@ -318,7 +337,7 @@ var BaseElement = class extends HTMLElement {
|
|
|
318
337
|
newValue.subscribe(this);
|
|
319
338
|
}
|
|
320
339
|
if (reflectAttribute || ((_a2 = this._options.propertyOptions[property]) == null ? void 0 : _a2.reflect)) {
|
|
321
|
-
this.reflectProperty({property, newValue, newValueString});
|
|
340
|
+
this.reflectProperty({ property, newValue, newValueString });
|
|
322
341
|
}
|
|
323
342
|
if (this._options.autoUpdate) {
|
|
324
343
|
this.requestUpdate({
|
|
@@ -353,7 +372,7 @@ var BaseElement = class extends HTMLElement {
|
|
|
353
372
|
}
|
|
354
373
|
reflectProperty(options) {
|
|
355
374
|
var _a;
|
|
356
|
-
const {property, newValue} = options;
|
|
375
|
+
const { property, newValue } = options;
|
|
357
376
|
const newValueString = options.newValueString || JSON.stringify(newValue);
|
|
358
377
|
if (newValue === void 0 || newValue === null || isNaN(newValue)) {
|
|
359
378
|
this.setAttribute(camelToDash(property), "");
|
|
@@ -380,7 +399,7 @@ var BaseElement = class extends HTMLElement {
|
|
|
380
399
|
}
|
|
381
400
|
}
|
|
382
401
|
requestContext(propertyName, valueOrCallback) {
|
|
383
|
-
this.dispatch("request-context", {[propertyName]: valueOrCallback}, true);
|
|
402
|
+
this.dispatch("request-context", { [propertyName]: valueOrCallback }, true);
|
|
384
403
|
}
|
|
385
404
|
onRequestContext(event) {
|
|
386
405
|
var _a;
|
|
@@ -398,9 +417,6 @@ var BaseElement = class extends HTMLElement {
|
|
|
398
417
|
}
|
|
399
418
|
});
|
|
400
419
|
}
|
|
401
|
-
hooks() {
|
|
402
|
-
return {};
|
|
403
|
-
}
|
|
404
420
|
connected() {
|
|
405
421
|
}
|
|
406
422
|
beforeUpdate() {
|
|
@@ -410,11 +426,6 @@ var BaseElement = class extends HTMLElement {
|
|
|
410
426
|
disconnected() {
|
|
411
427
|
}
|
|
412
428
|
triggerHook(name) {
|
|
413
|
-
if (this.hooks && name in this.hooks()) {
|
|
414
|
-
console.warn(`[${this.localName}] Using the hooks() map for lifecycle hooks is deprecated! Please overwrite the existing lifecycle hook functions. See the docs for more info`);
|
|
415
|
-
this.hooks()[name]();
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
429
|
if (name in this) {
|
|
419
430
|
this[name]();
|
|
420
431
|
}
|
|
@@ -422,19 +433,6 @@ var BaseElement = class extends HTMLElement {
|
|
|
422
433
|
watch() {
|
|
423
434
|
return {};
|
|
424
435
|
}
|
|
425
|
-
computed() {
|
|
426
|
-
return {};
|
|
427
|
-
}
|
|
428
|
-
defineComputedProperties() {
|
|
429
|
-
Object.keys(this.computed()).forEach((prop) => {
|
|
430
|
-
if (!this.hasOwnProperty(prop)) {
|
|
431
|
-
console.warn(`[${this.localName}] Using the computed() map for computed properties is deprecated! Please use regular JS getters and return the computed value. See the docs for more info`);
|
|
432
|
-
Object.defineProperty(this, prop, {
|
|
433
|
-
get: () => this.computed()[prop]()
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
436
|
events() {
|
|
439
437
|
return {};
|
|
440
438
|
}
|
|
@@ -443,7 +441,7 @@ var BaseElement = class extends HTMLElement {
|
|
|
443
441
|
const eventDefinitions = this.events();
|
|
444
442
|
Object.keys(eventDefinitions).forEach((elementSelector) => {
|
|
445
443
|
const events = eventDefinitions[elementSelector];
|
|
446
|
-
const selectorWhiteList = {window, document, this: this.getRoot()};
|
|
444
|
+
const selectorWhiteList = { window, document, this: this.getRoot() };
|
|
447
445
|
const whiteListElement = selectorWhiteList[elementSelector];
|
|
448
446
|
const eventTargets = whiteListElement ? [whiteListElement] : this.getRoot().querySelectorAll(elementSelector);
|
|
449
447
|
eventTargets.forEach((eventTarget) => {
|
|
@@ -453,18 +451,18 @@ var BaseElement = class extends HTMLElement {
|
|
|
453
451
|
if (typeof notation === "function") {
|
|
454
452
|
const callback = notation.bind(this);
|
|
455
453
|
eventTarget.addEventListener(eventName, callback);
|
|
456
|
-
this._registeredEvents.push({eventTarget, eventName, callback});
|
|
454
|
+
this._registeredEvents.push({ eventTarget, eventName, callback });
|
|
457
455
|
} else if (typeof notation === "object" && typeof notation.listener === "function") {
|
|
458
456
|
const callback = notation.listener.bind(this);
|
|
459
457
|
eventTarget.addEventListener(eventName, callback, (_a = notation.options) != null ? _a : {});
|
|
460
|
-
this._registeredEvents.push({eventTarget, eventName, callback});
|
|
458
|
+
this._registeredEvents.push({ eventTarget, eventName, callback });
|
|
461
459
|
}
|
|
462
460
|
});
|
|
463
461
|
});
|
|
464
462
|
});
|
|
465
463
|
}
|
|
466
464
|
removeEvents() {
|
|
467
|
-
this._registeredEvents.forEach(({eventTarget, eventName, callback}) => {
|
|
465
|
+
this._registeredEvents.forEach(({ eventTarget, eventName, callback }) => {
|
|
468
466
|
if (eventTarget === window || eventTarget === document || this.getRoot().contains(eventTarget)) {
|
|
469
467
|
eventTarget.removeEventListener(eventName, callback);
|
|
470
468
|
}
|
|
@@ -488,7 +486,9 @@ var BaseElement = class extends HTMLElement {
|
|
|
488
486
|
} else if (!hasListRef) {
|
|
489
487
|
refsMap[refKey] = refNode;
|
|
490
488
|
} else {
|
|
491
|
-
console.warn(
|
|
489
|
+
console.warn(
|
|
490
|
+
`Did not register singular ref ${refKey}, ${refNode} as a ref list is already registered under the same name.`
|
|
491
|
+
);
|
|
492
492
|
}
|
|
493
493
|
});
|
|
494
494
|
this.$refs = refsMap;
|
|
@@ -526,7 +526,8 @@ function i18n(key, fallback) {
|
|
|
526
526
|
// src/StyledElement.js
|
|
527
527
|
var _StyledElement = class extends BaseElement {
|
|
528
528
|
static updateGlobalStyles() {
|
|
529
|
-
|
|
529
|
+
var _a;
|
|
530
|
+
_StyledElement.globalStyles = (_a = globalThis.document) == null ? void 0 : _a.getElementById("globalStyles");
|
|
530
531
|
if (_StyledElement.globalStyles && _StyledElement["globalStyleSheet"]) {
|
|
531
532
|
_StyledElement["globalStyleSheet"].replaceSync(_StyledElement.globalStyles.textContent);
|
|
532
533
|
}
|
|
@@ -545,11 +546,6 @@ var _StyledElement = class extends BaseElement {
|
|
|
545
546
|
super.connectedCallback();
|
|
546
547
|
if (supportsAdoptingStyleSheets() && this._options.shadowRender) {
|
|
547
548
|
this.adoptStyleSheets();
|
|
548
|
-
} else if (this._options.shadowRender && window.ShadyCSS !== void 0) {
|
|
549
|
-
window.ShadyCSS.ScopingShim.prepareAdoptedCssText(this._styles, this.localName);
|
|
550
|
-
}
|
|
551
|
-
if (window.ShadyCSS !== void 0) {
|
|
552
|
-
window.ShadyCSS.styleElement(this);
|
|
553
549
|
}
|
|
554
550
|
}
|
|
555
551
|
styles() {
|
|
@@ -559,7 +555,7 @@ var _StyledElement = class extends BaseElement {
|
|
|
559
555
|
var _a, _b;
|
|
560
556
|
if (!supportsAdoptingStyleSheets() || this._options.shadowRender === false) {
|
|
561
557
|
const appendableStyles = [...this._styles];
|
|
562
|
-
if (this._options.shadowRender && this._options.adoptGlobalStyles
|
|
558
|
+
if (this._options.shadowRender && this._options.adoptGlobalStyles) {
|
|
563
559
|
appendableStyles.unshift((_b = (_a = _StyledElement.globalStyles) == null ? void 0 : _a.textContent) != null ? _b : "");
|
|
564
560
|
}
|
|
565
561
|
this.appendStyleSheets(appendableStyles);
|
|
@@ -588,9 +584,10 @@ var _StyledElement = class extends BaseElement {
|
|
|
588
584
|
appendStyleSheets(styles) {
|
|
589
585
|
const parentDocument = getShadowParentOrBody(this.getRoot());
|
|
590
586
|
styles.forEach((style, index) => {
|
|
587
|
+
var _a;
|
|
591
588
|
const identifier = this.tagName + index;
|
|
592
589
|
if (!parentDocument.querySelector(`#${identifier}`)) {
|
|
593
|
-
const styleElement = document.createElement("style");
|
|
590
|
+
const styleElement = (_a = globalThis.document) == null ? void 0 : _a.createElement("style");
|
|
594
591
|
styleElement.id = identifier;
|
|
595
592
|
styleElement.style.display = "none";
|
|
596
593
|
styleElement.textContent = style;
|
|
@@ -603,979 +600,690 @@ var StyledElement = _StyledElement;
|
|
|
603
600
|
__publicField(StyledElement, "globalStyles", null);
|
|
604
601
|
StyledElement.updateGlobalStyles();
|
|
605
602
|
|
|
606
|
-
//
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
* The complete set of authors may be found at
|
|
613
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
614
|
-
* The complete set of contributors may be found at
|
|
615
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
616
|
-
* Code distributed by Google as part of the polymer project is also
|
|
617
|
-
* subject to an additional IP rights grant found at
|
|
618
|
-
* http://polymer.github.io/PATENTS.txt
|
|
619
|
-
*/
|
|
620
|
-
var directives = new WeakMap();
|
|
621
|
-
var isDirective = (o) => {
|
|
622
|
-
return typeof o === "function" && directives.has(o);
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
// node_modules/lit-html/lib/dom.js
|
|
626
|
-
/**
|
|
627
|
-
* @license
|
|
628
|
-
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
629
|
-
* This code may only be used under the BSD style license found at
|
|
630
|
-
* http://polymer.github.io/LICENSE.txt
|
|
631
|
-
* The complete set of authors may be found at
|
|
632
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
633
|
-
* The complete set of contributors may be found at
|
|
634
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
635
|
-
* Code distributed by Google as part of the polymer project is also
|
|
636
|
-
* subject to an additional IP rights grant found at
|
|
637
|
-
* http://polymer.github.io/PATENTS.txt
|
|
638
|
-
*/
|
|
639
|
-
var isCEPolyfill = typeof window !== "undefined" && window.customElements != null && window.customElements.polyfillWrapFlushCallback !== void 0;
|
|
640
|
-
var removeNodes = (container, start, end = null) => {
|
|
641
|
-
while (start !== end) {
|
|
642
|
-
const n = start.nextSibling;
|
|
643
|
-
container.removeChild(start);
|
|
644
|
-
start = n;
|
|
603
|
+
// src/dom-parts/Part.js
|
|
604
|
+
var Part = class {
|
|
605
|
+
constructor() {
|
|
606
|
+
__publicField(this, "processor");
|
|
607
|
+
}
|
|
608
|
+
update(value) {
|
|
645
609
|
}
|
|
646
610
|
};
|
|
647
611
|
|
|
648
|
-
//
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
658
|
-
* Code distributed by Google as part of the polymer project is also
|
|
659
|
-
* subject to an additional IP rights grant found at
|
|
660
|
-
* http://polymer.github.io/PATENTS.txt
|
|
661
|
-
*/
|
|
662
|
-
var noChange = {};
|
|
663
|
-
var nothing = {};
|
|
664
|
-
|
|
665
|
-
// node_modules/lit-html/lib/template.js
|
|
666
|
-
/**
|
|
667
|
-
* @license
|
|
668
|
-
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
669
|
-
* This code may only be used under the BSD style license found at
|
|
670
|
-
* http://polymer.github.io/LICENSE.txt
|
|
671
|
-
* The complete set of authors may be found at
|
|
672
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
673
|
-
* The complete set of contributors may be found at
|
|
674
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
675
|
-
* Code distributed by Google as part of the polymer project is also
|
|
676
|
-
* subject to an additional IP rights grant found at
|
|
677
|
-
* http://polymer.github.io/PATENTS.txt
|
|
678
|
-
*/
|
|
679
|
-
var marker = `{{lit-${String(Math.random()).slice(2)}}}`;
|
|
680
|
-
var nodeMarker = `<!--${marker}-->`;
|
|
681
|
-
var markerRegex = new RegExp(`${marker}|${nodeMarker}`);
|
|
682
|
-
var boundAttributeSuffix = "$lit$";
|
|
683
|
-
var Template = class {
|
|
684
|
-
constructor(result, element) {
|
|
685
|
-
this.parts = [];
|
|
686
|
-
this.element = element;
|
|
687
|
-
const nodesToRemove = [];
|
|
688
|
-
const stack = [];
|
|
689
|
-
const walker = document.createTreeWalker(element.content, 133, null, false);
|
|
690
|
-
let lastPartIndex = 0;
|
|
691
|
-
let index = -1;
|
|
692
|
-
let partIndex = 0;
|
|
693
|
-
const {strings, values: {length}} = result;
|
|
694
|
-
while (partIndex < length) {
|
|
695
|
-
const node = walker.nextNode();
|
|
696
|
-
if (node === null) {
|
|
697
|
-
walker.currentNode = stack.pop();
|
|
698
|
-
continue;
|
|
699
|
-
}
|
|
700
|
-
index++;
|
|
701
|
-
if (node.nodeType === 1) {
|
|
702
|
-
if (node.hasAttributes()) {
|
|
703
|
-
const attributes = node.attributes;
|
|
704
|
-
const {length: length2} = attributes;
|
|
705
|
-
let count = 0;
|
|
706
|
-
for (let i = 0; i < length2; i++) {
|
|
707
|
-
if (endsWith(attributes[i].name, boundAttributeSuffix)) {
|
|
708
|
-
count++;
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
while (count-- > 0) {
|
|
712
|
-
const stringForPart = strings[partIndex];
|
|
713
|
-
const name = lastAttributeNameRegex.exec(stringForPart)[2];
|
|
714
|
-
const attributeLookupName = name.toLowerCase() + boundAttributeSuffix;
|
|
715
|
-
const attributeValue = node.getAttribute(attributeLookupName);
|
|
716
|
-
node.removeAttribute(attributeLookupName);
|
|
717
|
-
const statics = attributeValue.split(markerRegex);
|
|
718
|
-
this.parts.push({type: "attribute", index, name, strings: statics});
|
|
719
|
-
partIndex += statics.length - 1;
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
if (node.tagName === "TEMPLATE") {
|
|
723
|
-
stack.push(node);
|
|
724
|
-
walker.currentNode = node.content;
|
|
725
|
-
}
|
|
726
|
-
} else if (node.nodeType === 3) {
|
|
727
|
-
const data = node.data;
|
|
728
|
-
if (data.indexOf(marker) >= 0) {
|
|
729
|
-
const parent = node.parentNode;
|
|
730
|
-
const strings2 = data.split(markerRegex);
|
|
731
|
-
const lastIndex = strings2.length - 1;
|
|
732
|
-
for (let i = 0; i < lastIndex; i++) {
|
|
733
|
-
let insert;
|
|
734
|
-
let s = strings2[i];
|
|
735
|
-
if (s === "") {
|
|
736
|
-
insert = createMarker();
|
|
737
|
-
} else {
|
|
738
|
-
const match = lastAttributeNameRegex.exec(s);
|
|
739
|
-
if (match !== null && endsWith(match[2], boundAttributeSuffix)) {
|
|
740
|
-
s = s.slice(0, match.index) + match[1] + match[2].slice(0, -boundAttributeSuffix.length) + match[3];
|
|
741
|
-
}
|
|
742
|
-
insert = document.createTextNode(s);
|
|
743
|
-
}
|
|
744
|
-
parent.insertBefore(insert, node);
|
|
745
|
-
this.parts.push({type: "node", index: ++index});
|
|
746
|
-
}
|
|
747
|
-
if (strings2[lastIndex] === "") {
|
|
748
|
-
parent.insertBefore(createMarker(), node);
|
|
749
|
-
nodesToRemove.push(node);
|
|
750
|
-
} else {
|
|
751
|
-
node.data = strings2[lastIndex];
|
|
752
|
-
}
|
|
753
|
-
partIndex += lastIndex;
|
|
754
|
-
}
|
|
755
|
-
} else if (node.nodeType === 8) {
|
|
756
|
-
if (node.data === marker) {
|
|
757
|
-
const parent = node.parentNode;
|
|
758
|
-
if (node.previousSibling === null || index === lastPartIndex) {
|
|
759
|
-
index++;
|
|
760
|
-
parent.insertBefore(createMarker(), node);
|
|
761
|
-
}
|
|
762
|
-
lastPartIndex = index;
|
|
763
|
-
this.parts.push({type: "node", index});
|
|
764
|
-
if (node.nextSibling === null) {
|
|
765
|
-
node.data = "";
|
|
766
|
-
} else {
|
|
767
|
-
nodesToRemove.push(node);
|
|
768
|
-
index--;
|
|
769
|
-
}
|
|
770
|
-
partIndex++;
|
|
771
|
-
} else {
|
|
772
|
-
let i = -1;
|
|
773
|
-
while ((i = node.data.indexOf(marker, i + 1)) !== -1) {
|
|
774
|
-
this.parts.push({type: "node", index: -1});
|
|
775
|
-
partIndex++;
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
for (const n of nodesToRemove) {
|
|
781
|
-
n.parentNode.removeChild(n);
|
|
782
|
-
}
|
|
783
|
-
}
|
|
612
|
+
// src/dom-parts/AttributePart.js
|
|
613
|
+
var processBooleanAttribute = (node, name, oldValue) => {
|
|
614
|
+
node.removeAttribute(`?${name}`);
|
|
615
|
+
return (newValue) => {
|
|
616
|
+
const value = !!(newValue == null ? void 0 : newValue.valueOf()) && newValue !== "false";
|
|
617
|
+
if (oldValue !== value) {
|
|
618
|
+
node.toggleAttribute(name, oldValue = !!value);
|
|
619
|
+
}
|
|
620
|
+
};
|
|
784
621
|
};
|
|
785
|
-
var
|
|
786
|
-
|
|
787
|
-
return
|
|
622
|
+
var processPropertyAttribute = (node, name) => {
|
|
623
|
+
node.removeAttribute(`.${name}`);
|
|
624
|
+
return (value) => {
|
|
625
|
+
node[name] = value;
|
|
626
|
+
};
|
|
788
627
|
};
|
|
789
|
-
var
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
814
|
-
update(values) {
|
|
815
|
-
let i = 0;
|
|
816
|
-
for (const part of this.__parts) {
|
|
817
|
-
if (part !== void 0) {
|
|
818
|
-
part.setValue(values[i]);
|
|
819
|
-
}
|
|
820
|
-
i++;
|
|
821
|
-
}
|
|
822
|
-
for (const part of this.__parts) {
|
|
823
|
-
if (part !== void 0) {
|
|
824
|
-
part.commit();
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
_clone() {
|
|
829
|
-
const fragment = isCEPolyfill ? this.template.element.content.cloneNode(true) : document.importNode(this.template.element.content, true);
|
|
830
|
-
const stack = [];
|
|
831
|
-
const parts2 = this.template.parts;
|
|
832
|
-
const walker = document.createTreeWalker(fragment, 133, null, false);
|
|
833
|
-
let partIndex = 0;
|
|
834
|
-
let nodeIndex = 0;
|
|
835
|
-
let part;
|
|
836
|
-
let node = walker.nextNode();
|
|
837
|
-
while (partIndex < parts2.length) {
|
|
838
|
-
part = parts2[partIndex];
|
|
839
|
-
if (!isTemplatePartActive(part)) {
|
|
840
|
-
this.__parts.push(void 0);
|
|
841
|
-
partIndex++;
|
|
842
|
-
continue;
|
|
843
|
-
}
|
|
844
|
-
while (nodeIndex < part.index) {
|
|
845
|
-
nodeIndex++;
|
|
846
|
-
if (node.nodeName === "TEMPLATE") {
|
|
847
|
-
stack.push(node);
|
|
848
|
-
walker.currentNode = node.content;
|
|
849
|
-
}
|
|
850
|
-
if ((node = walker.nextNode()) === null) {
|
|
851
|
-
walker.currentNode = stack.pop();
|
|
852
|
-
node = walker.nextNode();
|
|
628
|
+
var processEventAttribute = (node, name) => {
|
|
629
|
+
node.removeAttribute(name);
|
|
630
|
+
let oldValue = void 0;
|
|
631
|
+
let type = name.startsWith("@") ? name.slice(1) : name.toLowerCase().slice(2);
|
|
632
|
+
return (newValue) => {
|
|
633
|
+
if (oldValue !== newValue) {
|
|
634
|
+
if (oldValue)
|
|
635
|
+
node.removeEventListener(type, oldValue);
|
|
636
|
+
if (oldValue = newValue)
|
|
637
|
+
node.addEventListener(type, oldValue);
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
};
|
|
641
|
+
var processAttribute = (node, name) => {
|
|
642
|
+
var _a;
|
|
643
|
+
let oldValue, orphan = true;
|
|
644
|
+
const attributeNode = (_a = globalThis.document) == null ? void 0 : _a.createAttributeNS(null, name);
|
|
645
|
+
return (newValue) => {
|
|
646
|
+
const value = newValue == null ? void 0 : newValue.valueOf();
|
|
647
|
+
if (oldValue !== value) {
|
|
648
|
+
if ((oldValue = value) == null) {
|
|
649
|
+
if (!orphan) {
|
|
650
|
+
node.removeAttributeNode(attributeNode);
|
|
651
|
+
orphan = true;
|
|
853
652
|
}
|
|
854
|
-
}
|
|
855
|
-
if (part.type === "node") {
|
|
856
|
-
const part2 = this.processor.handleTextExpression(this.options);
|
|
857
|
-
part2.insertAfterNode(node.previousSibling);
|
|
858
|
-
this.__parts.push(part2);
|
|
859
653
|
} else {
|
|
860
|
-
|
|
654
|
+
attributeNode.value = value;
|
|
655
|
+
if (orphan) {
|
|
656
|
+
node.setAttributeNodeNS(attributeNode);
|
|
657
|
+
orphan = false;
|
|
658
|
+
}
|
|
861
659
|
}
|
|
862
|
-
partIndex++;
|
|
863
660
|
}
|
|
864
|
-
|
|
865
|
-
document.adoptNode(fragment);
|
|
866
|
-
customElements.upgrade(fragment);
|
|
867
|
-
}
|
|
868
|
-
return fragment;
|
|
869
|
-
}
|
|
661
|
+
};
|
|
870
662
|
};
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
* @license
|
|
875
|
-
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
876
|
-
* This code may only be used under the BSD style license found at
|
|
877
|
-
* http://polymer.github.io/LICENSE.txt
|
|
878
|
-
* The complete set of authors may be found at
|
|
879
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
880
|
-
* The complete set of contributors may be found at
|
|
881
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
882
|
-
* Code distributed by Google as part of the polymer project is also
|
|
883
|
-
* subject to an additional IP rights grant found at
|
|
884
|
-
* http://polymer.github.io/PATENTS.txt
|
|
885
|
-
*/
|
|
886
|
-
var commentMarker = ` ${marker} `;
|
|
887
|
-
var TemplateResult = class {
|
|
888
|
-
constructor(strings, values, type, processor) {
|
|
889
|
-
this.strings = strings;
|
|
890
|
-
this.values = values;
|
|
891
|
-
this.type = type;
|
|
892
|
-
this.processor = processor;
|
|
893
|
-
}
|
|
894
|
-
getHTML() {
|
|
895
|
-
const l = this.strings.length - 1;
|
|
896
|
-
let html2 = "";
|
|
897
|
-
let isCommentBinding = false;
|
|
898
|
-
for (let i = 0; i < l; i++) {
|
|
899
|
-
const s = this.strings[i];
|
|
900
|
-
const commentOpen = s.lastIndexOf("<!--");
|
|
901
|
-
isCommentBinding = (commentOpen > -1 || isCommentBinding) && s.indexOf("-->", commentOpen + 1) === -1;
|
|
902
|
-
const attributeMatch = lastAttributeNameRegex.exec(s);
|
|
903
|
-
if (attributeMatch === null) {
|
|
904
|
-
html2 += s + (isCommentBinding ? commentMarker : nodeMarker);
|
|
905
|
-
} else {
|
|
906
|
-
html2 += s.substr(0, attributeMatch.index) + attributeMatch[1] + attributeMatch[2] + boundAttributeSuffix + attributeMatch[3] + marker;
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
html2 += this.strings[l];
|
|
910
|
-
return html2;
|
|
663
|
+
var processAttributePart = (node, name) => {
|
|
664
|
+
if (name.startsWith("?")) {
|
|
665
|
+
return processBooleanAttribute(node, name.slice(1), false);
|
|
911
666
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
template.innerHTML = this.getHTML();
|
|
915
|
-
return template;
|
|
667
|
+
if (name.startsWith(".")) {
|
|
668
|
+
return processPropertyAttribute(node, name.slice(1));
|
|
916
669
|
}
|
|
670
|
+
if (name.startsWith("@") || name.startsWith("on")) {
|
|
671
|
+
return processEventAttribute(node, name);
|
|
672
|
+
}
|
|
673
|
+
return processAttribute(node, name);
|
|
917
674
|
};
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
927
|
-
* The complete set of contributors may be found at
|
|
928
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
929
|
-
* Code distributed by Google as part of the polymer project is also
|
|
930
|
-
* subject to an additional IP rights grant found at
|
|
931
|
-
* http://polymer.github.io/PATENTS.txt
|
|
932
|
-
*/
|
|
933
|
-
var isPrimitive = (value) => {
|
|
934
|
-
return value === null || !(typeof value === "object" || typeof value === "function");
|
|
935
|
-
};
|
|
936
|
-
var isIterable = (value) => {
|
|
937
|
-
return Array.isArray(value) || !!(value && value[Symbol.iterator]);
|
|
938
|
-
};
|
|
939
|
-
var AttributeCommitter = class {
|
|
940
|
-
constructor(element, name, strings) {
|
|
941
|
-
this.dirty = true;
|
|
942
|
-
this.element = element;
|
|
675
|
+
var AttributePart = class extends Part {
|
|
676
|
+
constructor(node, name, initialValue) {
|
|
677
|
+
super();
|
|
678
|
+
__publicField(this, "name");
|
|
679
|
+
__publicField(this, "interpolations", 1);
|
|
680
|
+
__publicField(this, "values", []);
|
|
681
|
+
__publicField(this, "currentValueIndex", 0);
|
|
682
|
+
__publicField(this, "initialValue");
|
|
943
683
|
this.name = name;
|
|
944
|
-
this.
|
|
945
|
-
this.
|
|
946
|
-
for (let i = 0; i < strings.length - 1; i++) {
|
|
947
|
-
this.parts[i] = this._createPart();
|
|
948
|
-
}
|
|
684
|
+
this.initialValue = initialValue;
|
|
685
|
+
this.processor = processAttributePart(node.nextElementSibling, this.name);
|
|
949
686
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
}
|
|
953
|
-
_getValue() {
|
|
954
|
-
const strings = this.strings;
|
|
955
|
-
const l = strings.length - 1;
|
|
956
|
-
let text = "";
|
|
957
|
-
for (let i = 0; i < l; i++) {
|
|
958
|
-
text += strings[i];
|
|
959
|
-
const part = this.parts[i];
|
|
960
|
-
if (part !== void 0) {
|
|
961
|
-
const v = part.value;
|
|
962
|
-
if (isPrimitive(v) || !isIterable(v)) {
|
|
963
|
-
text += typeof v === "string" ? v : String(v);
|
|
964
|
-
} else {
|
|
965
|
-
for (const t of v) {
|
|
966
|
-
text += typeof t === "string" ? t : String(t);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
text += strings[l];
|
|
972
|
-
return text;
|
|
687
|
+
addNode(node) {
|
|
688
|
+
this.interpolations++;
|
|
973
689
|
}
|
|
974
|
-
|
|
975
|
-
if (this.
|
|
976
|
-
this.
|
|
977
|
-
|
|
690
|
+
update(value) {
|
|
691
|
+
if (this.initialValue === "") {
|
|
692
|
+
this.processor(value);
|
|
693
|
+
return;
|
|
978
694
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
}
|
|
986
|
-
setValue(value) {
|
|
987
|
-
if (value !== noChange && (!isPrimitive(value) || value !== this.value)) {
|
|
988
|
-
this.value = value;
|
|
989
|
-
if (!isDirective(value)) {
|
|
990
|
-
this.committer.dirty = true;
|
|
991
|
-
}
|
|
695
|
+
this.values[this.currentValueIndex++] = value;
|
|
696
|
+
if (this.interpolations === this.currentValueIndex) {
|
|
697
|
+
this.currentValueIndex = 0;
|
|
698
|
+
let replaceIndex = 0;
|
|
699
|
+
const parsedValue = this.initialValue.replace(/\x03/g, () => this.values[replaceIndex++]);
|
|
700
|
+
this.processor(parsedValue);
|
|
992
701
|
}
|
|
993
702
|
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
// src/dom-parts/ChildNodePart.js
|
|
706
|
+
var removeChildNodes = (node) => {
|
|
707
|
+
var _a;
|
|
708
|
+
const range = (_a = globalThis.document) == null ? void 0 : _a.createRange();
|
|
709
|
+
const firstChild = Array.isArray(node) ? node[0] : node instanceof TemplatePart ? node.childNodes[0] : node.firstChild;
|
|
710
|
+
const lastChild = Array.isArray(node) ? node[node.length - 1] : node instanceof TemplatePart ? node.childNodes[node.childNodes.length - 1] : node.lastChild;
|
|
711
|
+
range.setStartAfter(firstChild);
|
|
712
|
+
range.setEndAfter(lastChild);
|
|
713
|
+
range.deleteContents();
|
|
714
|
+
return firstChild;
|
|
715
|
+
};
|
|
716
|
+
var removeNodesBetweenComments = (commentNode) => {
|
|
717
|
+
while (commentNode.previousSibling) {
|
|
718
|
+
if (commentNode.previousSibling.nodeType === COMMENT_NODE && commentNode.previousSibling.data === commentNode.data.replace("/", "")) {
|
|
719
|
+
break;
|
|
1002
720
|
}
|
|
1003
|
-
|
|
721
|
+
commentNode.parentNode.removeChild(commentNode.previousSibling);
|
|
1004
722
|
}
|
|
1005
723
|
};
|
|
1006
|
-
var
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
appendIntoPart(part) {
|
|
1021
|
-
part.__insert(this.startNode = createMarker());
|
|
1022
|
-
part.__insert(this.endNode = createMarker());
|
|
1023
|
-
}
|
|
1024
|
-
insertAfterPart(ref) {
|
|
1025
|
-
ref.__insert(this.startNode = createMarker());
|
|
1026
|
-
this.endNode = ref.endNode;
|
|
1027
|
-
ref.endNode = this.startNode;
|
|
1028
|
-
}
|
|
1029
|
-
setValue(value) {
|
|
1030
|
-
this.__pendingValue = value;
|
|
1031
|
-
}
|
|
1032
|
-
commit() {
|
|
1033
|
-
if (this.startNode.parentNode === null) {
|
|
1034
|
-
return;
|
|
724
|
+
var diffChildNodes = function(parentNode, domChildNodes, templateChildNodes, anchorNode) {
|
|
725
|
+
let length = Math.max(templateChildNodes.length, domChildNodes.length);
|
|
726
|
+
for (let index = 0; index < length; index++) {
|
|
727
|
+
let domChildNode = domChildNodes[index];
|
|
728
|
+
let templateChildNode = templateChildNodes[index];
|
|
729
|
+
if (!domChildNode) {
|
|
730
|
+
if (templateChildNode instanceof TemplatePart) {
|
|
731
|
+
anchorNode.before(...templateChildNode.childNodes);
|
|
732
|
+
} else if (typeof templateChildNode === "object" && "ELEMENT_NODE" in templateChildNode) {
|
|
733
|
+
parentNode.insertBefore(templateChildNode, anchorNode);
|
|
734
|
+
} else {
|
|
735
|
+
parentNode.insertBefore(document.createTextNode(templateChildNode), anchorNode);
|
|
736
|
+
}
|
|
737
|
+
continue;
|
|
1035
738
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
directive2(this);
|
|
739
|
+
if (!templateChildNode) {
|
|
740
|
+
parentNode.removeChild(removeChildNodes(domChildNode));
|
|
741
|
+
continue;
|
|
1040
742
|
}
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
return;
|
|
743
|
+
if (domChildNode === templateChildNode) {
|
|
744
|
+
continue;
|
|
1044
745
|
}
|
|
1045
|
-
if (
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
}
|
|
1049
|
-
} else if (value instanceof TemplateResult) {
|
|
1050
|
-
this.__commitTemplateResult(value);
|
|
1051
|
-
} else if (value instanceof Node) {
|
|
1052
|
-
this.__commitNode(value);
|
|
1053
|
-
} else if (isIterable(value)) {
|
|
1054
|
-
this.__commitIterable(value);
|
|
1055
|
-
} else if (value === nothing) {
|
|
1056
|
-
this.value = nothing;
|
|
1057
|
-
this.clear();
|
|
1058
|
-
} else {
|
|
1059
|
-
this.__commitText(value);
|
|
746
|
+
if (templateChildNode.nodeType !== domChildNode.nodeType) {
|
|
747
|
+
parentNode.replaceChild(templateChildNode, domChildNode);
|
|
748
|
+
continue;
|
|
1060
749
|
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
}
|
|
1065
|
-
__commitNode(value) {
|
|
1066
|
-
if (this.value === value) {
|
|
1067
|
-
return;
|
|
750
|
+
if (templateChildNode.nodeType === ELEMENT_NODE && templateChildNode.tagName !== domChildNode.tagName) {
|
|
751
|
+
parentNode.replaceChild(templateChildNode, domChildNode);
|
|
752
|
+
continue;
|
|
1068
753
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
}
|
|
1073
|
-
__commitText(value) {
|
|
1074
|
-
const node = this.startNode.nextSibling;
|
|
1075
|
-
value = value == null ? "" : value;
|
|
1076
|
-
const valueAsString = typeof value === "string" ? value : String(value);
|
|
1077
|
-
if (node === this.endNode.previousSibling && node.nodeType === 3) {
|
|
1078
|
-
node.data = valueAsString;
|
|
1079
|
-
} else {
|
|
1080
|
-
this.__commitNode(document.createTextNode(valueAsString));
|
|
1081
|
-
}
|
|
1082
|
-
this.value = value;
|
|
1083
|
-
}
|
|
1084
|
-
__commitTemplateResult(value) {
|
|
1085
|
-
const template = this.options.templateFactory(value);
|
|
1086
|
-
if (this.value instanceof TemplateInstance && this.value.template === template) {
|
|
1087
|
-
this.value.update(value.values);
|
|
1088
|
-
} else {
|
|
1089
|
-
const instance = new TemplateInstance(template, value.processor, this.options);
|
|
1090
|
-
const fragment = instance._clone();
|
|
1091
|
-
instance.update(value.values);
|
|
1092
|
-
this.__commitNode(fragment);
|
|
1093
|
-
this.value = instance;
|
|
754
|
+
if (templateChildNode.nodeType === ELEMENT_NODE && templateChildNode.tagName === "SVG") {
|
|
755
|
+
parentNode.replaceChild(templateChildNode, domChildNode);
|
|
756
|
+
continue;
|
|
1094
757
|
}
|
|
1095
758
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
759
|
+
return templateChildNodes;
|
|
760
|
+
};
|
|
761
|
+
var processNodePart = (comment, initialValue) => {
|
|
762
|
+
let nodes = [];
|
|
763
|
+
let oldValue = initialValue instanceof TemplatePart ? [...initialValue.childNodes] : initialValue;
|
|
764
|
+
let cachedTextNode = void 0;
|
|
765
|
+
const processNodeValue = (newValue) => {
|
|
766
|
+
var _a, _b;
|
|
767
|
+
switch (typeof newValue) {
|
|
768
|
+
case "string":
|
|
769
|
+
case "number":
|
|
770
|
+
case "boolean":
|
|
771
|
+
if (oldValue !== newValue) {
|
|
772
|
+
oldValue = newValue;
|
|
773
|
+
if (!cachedTextNode)
|
|
774
|
+
cachedTextNode = (_a = globalThis.document) == null ? void 0 : _a.createTextNode("");
|
|
775
|
+
cachedTextNode.data = newValue;
|
|
776
|
+
if (((_b = comment.previousSibling) == null ? void 0 : _b.data) === comment.data.replace("/", "")) {
|
|
777
|
+
comment.parentNode.insertBefore(cachedTextNode, comment);
|
|
778
|
+
} else {
|
|
779
|
+
comment.previousSibling.data = newValue;
|
|
780
|
+
}
|
|
781
|
+
nodes = [cachedTextNode];
|
|
1113
782
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
783
|
+
break;
|
|
784
|
+
case "object":
|
|
785
|
+
case "undefined":
|
|
786
|
+
if (newValue === null || newValue === void 0) {
|
|
787
|
+
if (oldValue !== newValue) {
|
|
788
|
+
oldValue = newValue;
|
|
789
|
+
removeNodesBetweenComments(comment);
|
|
790
|
+
nodes = [];
|
|
791
|
+
}
|
|
792
|
+
break;
|
|
793
|
+
}
|
|
794
|
+
if (Array.isArray(newValue)) {
|
|
795
|
+
if (newValue.length === 0) {
|
|
796
|
+
removeNodesBetweenComments(comment);
|
|
797
|
+
nodes = [];
|
|
798
|
+
} else {
|
|
799
|
+
nodes = diffChildNodes(comment.parentNode, oldValue || [], newValue, comment);
|
|
800
|
+
}
|
|
801
|
+
oldValue = newValue;
|
|
802
|
+
break;
|
|
803
|
+
}
|
|
804
|
+
if (oldValue !== newValue) {
|
|
805
|
+
if ("ELEMENT_NODE" in newValue) {
|
|
806
|
+
oldValue = newValue;
|
|
807
|
+
nodes = diffChildNodes(comment.parentNode, nodes, [newValue], comment);
|
|
808
|
+
} else if (newValue instanceof TemplatePart) {
|
|
809
|
+
oldValue = newValue;
|
|
810
|
+
nodes = diffChildNodes(comment.parentNode, nodes, [...newValue.childNodes], comment);
|
|
811
|
+
} else {
|
|
812
|
+
console.warn("Could not process value", newValue);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
break;
|
|
816
|
+
case "function":
|
|
817
|
+
processNodeValue(newValue(comment));
|
|
818
|
+
break;
|
|
1122
819
|
}
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
removeNodes(this.startNode.parentNode, startNode.nextSibling, this.endNode);
|
|
1126
|
-
}
|
|
820
|
+
};
|
|
821
|
+
return processNodeValue;
|
|
1127
822
|
};
|
|
1128
|
-
var
|
|
1129
|
-
constructor(
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
throw new Error("Boolean attributes can only contain a single expression");
|
|
823
|
+
var ChildNodePart = class extends Part {
|
|
824
|
+
constructor(startNode, value) {
|
|
825
|
+
var _a;
|
|
826
|
+
if (startNode && (startNode == null ? void 0 : startNode.nodeType) !== COMMENT_NODE) {
|
|
827
|
+
throw new Error("ChildNodePart: startNode is not a comment node");
|
|
1134
828
|
}
|
|
1135
|
-
|
|
1136
|
-
this
|
|
1137
|
-
this
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
this
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
const
|
|
1145
|
-
|
|
1146
|
-
|
|
829
|
+
super();
|
|
830
|
+
__publicField(this, "startNode");
|
|
831
|
+
__publicField(this, "endNode");
|
|
832
|
+
__publicField(this, "parts", []);
|
|
833
|
+
__publicField(this, "templatePart");
|
|
834
|
+
__publicField(this, "childNodes", []);
|
|
835
|
+
let serverSideRendered = false;
|
|
836
|
+
if (startNode) {
|
|
837
|
+
const placeholder = startNode.data;
|
|
838
|
+
const childNodes = [startNode];
|
|
839
|
+
let childNode = startNode.nextSibling;
|
|
840
|
+
while (childNode && childNode.data !== `/${placeholder}`) {
|
|
841
|
+
childNodes.push(childNode);
|
|
842
|
+
childNode = childNode.nextSibling;
|
|
843
|
+
}
|
|
844
|
+
const endNode = childNode;
|
|
845
|
+
childNodes.push(endNode);
|
|
846
|
+
if (childNodes.length > 2) {
|
|
847
|
+
serverSideRendered = true;
|
|
848
|
+
}
|
|
849
|
+
this.childNodes = childNodes;
|
|
850
|
+
this.startNode = startNode;
|
|
851
|
+
this.endNode = endNode;
|
|
1147
852
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
853
|
+
const initialValue = this.parseValue(value);
|
|
854
|
+
if (this.endNode) {
|
|
855
|
+
this.processor = processNodePart(this.endNode, serverSideRendered ? initialValue : void 0);
|
|
1150
856
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
this.element.setAttribute(this.name, "");
|
|
1155
|
-
} else {
|
|
1156
|
-
this.element.removeAttribute(this.name);
|
|
857
|
+
if (!serverSideRendered) {
|
|
858
|
+
if (value instanceof TemplateResult || Array.isArray(value)) {
|
|
859
|
+
this.updateParts(value);
|
|
1157
860
|
}
|
|
1158
|
-
this.
|
|
861
|
+
this.childNodes = [...this.childNodes];
|
|
862
|
+
(_a = this.processor) == null ? void 0 : _a.call(this, initialValue);
|
|
1159
863
|
}
|
|
1160
|
-
this.__pendingValue = noChange;
|
|
1161
|
-
}
|
|
1162
|
-
};
|
|
1163
|
-
var PropertyCommitter = class extends AttributeCommitter {
|
|
1164
|
-
constructor(element, name, strings) {
|
|
1165
|
-
super(element, name, strings);
|
|
1166
|
-
this.single = strings.length === 2 && strings[0] === "" && strings[1] === "";
|
|
1167
864
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
return this.parts[0].value;
|
|
865
|
+
update(value) {
|
|
866
|
+
var _a;
|
|
867
|
+
const parsedValue = this.parseValue(value);
|
|
868
|
+
if (value instanceof TemplateResult || Array.isArray(value)) {
|
|
869
|
+
this.updateParts(value);
|
|
1174
870
|
}
|
|
1175
|
-
|
|
871
|
+
(_a = this.processor) == null ? void 0 : _a.call(this, parsedValue);
|
|
1176
872
|
}
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
this.
|
|
873
|
+
updateParts(value) {
|
|
874
|
+
var _a;
|
|
875
|
+
if (value instanceof TemplateResult) {
|
|
876
|
+
this.templatePart.update(value);
|
|
1181
877
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
};
|
|
1186
|
-
var eventOptionsSupported = false;
|
|
1187
|
-
(() => {
|
|
1188
|
-
try {
|
|
1189
|
-
const options = {
|
|
1190
|
-
get capture() {
|
|
1191
|
-
eventOptionsSupported = true;
|
|
1192
|
-
return false;
|
|
878
|
+
if (Array.isArray(value)) {
|
|
879
|
+
for (let index = 0; index < value.length; index++) {
|
|
880
|
+
(_a = this.parts[index]) == null ? void 0 : _a.update(value[index]);
|
|
1193
881
|
}
|
|
1194
|
-
};
|
|
1195
|
-
window.addEventListener("test", options, options);
|
|
1196
|
-
window.removeEventListener("test", options, options);
|
|
1197
|
-
} catch (_e) {
|
|
1198
|
-
}
|
|
1199
|
-
})();
|
|
1200
|
-
var EventPart = class {
|
|
1201
|
-
constructor(element, eventName, eventContext) {
|
|
1202
|
-
this.value = void 0;
|
|
1203
|
-
this.__pendingValue = void 0;
|
|
1204
|
-
this.element = element;
|
|
1205
|
-
this.eventName = eventName;
|
|
1206
|
-
this.eventContext = eventContext;
|
|
1207
|
-
this.__boundHandleEvent = (e) => this.handleEvent(e);
|
|
1208
|
-
}
|
|
1209
|
-
setValue(value) {
|
|
1210
|
-
this.__pendingValue = value;
|
|
1211
|
-
}
|
|
1212
|
-
commit() {
|
|
1213
|
-
while (isDirective(this.__pendingValue)) {
|
|
1214
|
-
const directive2 = this.__pendingValue;
|
|
1215
|
-
this.__pendingValue = noChange;
|
|
1216
|
-
directive2(this);
|
|
1217
882
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
883
|
+
}
|
|
884
|
+
parseValue(value) {
|
|
885
|
+
var _a;
|
|
886
|
+
if (value instanceof TemplateResult) {
|
|
887
|
+
if (!this.templatePart) {
|
|
888
|
+
const templatePartCommentNodes = (_a = this.childNodes) == null ? void 0 : _a.filter(
|
|
889
|
+
(node) => node && node.nodeType === COMMENT_NODE && node.data === "template-part"
|
|
890
|
+
);
|
|
891
|
+
const startNode = templatePartCommentNodes[0];
|
|
892
|
+
this.templatePart = new TemplatePart(startNode, value);
|
|
893
|
+
}
|
|
894
|
+
return this.templatePart;
|
|
1220
895
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
const shouldRemoveListener = newListener == null || oldListener != null && (newListener.capture !== oldListener.capture || newListener.once !== oldListener.once || newListener.passive !== oldListener.passive);
|
|
1224
|
-
const shouldAddListener = newListener != null && (oldListener == null || shouldRemoveListener);
|
|
1225
|
-
if (shouldRemoveListener) {
|
|
1226
|
-
this.element.removeEventListener(this.eventName, this.__boundHandleEvent, this.__options);
|
|
896
|
+
if (Array.isArray(value)) {
|
|
897
|
+
return this.parseArray(value);
|
|
1227
898
|
}
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
899
|
+
return value;
|
|
900
|
+
}
|
|
901
|
+
parseArray(values) {
|
|
902
|
+
var _a, _b;
|
|
903
|
+
const parsedValues = [];
|
|
904
|
+
for (let index = 0; index < values.length; index++) {
|
|
905
|
+
let value = values[index];
|
|
906
|
+
if (value instanceof TemplateResult) {
|
|
907
|
+
let templatePart = this.parts[index];
|
|
908
|
+
if (!templatePart) {
|
|
909
|
+
const templatePartCommentNodes = (_a = this.childNodes) == null ? void 0 : _a.filter(
|
|
910
|
+
(node) => node && node.nodeType === COMMENT_NODE && node.data === "template-part"
|
|
911
|
+
);
|
|
912
|
+
const startNode = templatePartCommentNodes[index];
|
|
913
|
+
templatePart = new TemplatePart(startNode, value);
|
|
914
|
+
this.parts[index] = templatePart;
|
|
915
|
+
}
|
|
916
|
+
parsedValues[index] = templatePart;
|
|
917
|
+
} else if (Array.isArray(value)) {
|
|
918
|
+
let childNodePart = this.parts[index];
|
|
919
|
+
if (!childNodePart) {
|
|
920
|
+
const templatePartCommentNodes = (_b = this.childNodes) == null ? void 0 : _b.filter(
|
|
921
|
+
(node) => node && node.nodeType === COMMENT_NODE && node.data === "template-part"
|
|
922
|
+
);
|
|
923
|
+
const startNode = templatePartCommentNodes[index];
|
|
924
|
+
childNodePart = new ChildNodePart(startNode, value);
|
|
925
|
+
this.parts[index] = childNodePart;
|
|
926
|
+
}
|
|
927
|
+
parsedValues[index] = childNodePart;
|
|
928
|
+
} else {
|
|
929
|
+
parsedValues[index] = typeof value === "function" ? value() : value;
|
|
930
|
+
}
|
|
1231
931
|
}
|
|
1232
|
-
|
|
1233
|
-
this.__pendingValue = noChange;
|
|
932
|
+
return parsedValues;
|
|
1234
933
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
// src/dom-parts/NodePart.js
|
|
937
|
+
var NodePart = class extends Part {
|
|
938
|
+
constructor(node, initialValue) {
|
|
939
|
+
if (!isObjectLike(initialValue) && !initialValue.directiveClass) {
|
|
940
|
+
throw new Error(
|
|
941
|
+
"NodePart: value is not a wrapped directive function. You must wrap you custom directive class with the defineDirective function."
|
|
942
|
+
);
|
|
1240
943
|
}
|
|
944
|
+
super();
|
|
945
|
+
__publicField(this, "node");
|
|
946
|
+
__publicField(this, "directive");
|
|
947
|
+
this.node = node.nextElementSibling;
|
|
948
|
+
const { directiveClass, values } = initialValue;
|
|
949
|
+
this.directive = new directiveClass(node.nextElementSibling);
|
|
950
|
+
}
|
|
951
|
+
update(value) {
|
|
952
|
+
const { directiveClass, values } = value;
|
|
953
|
+
this.directive.update(...values);
|
|
1241
954
|
}
|
|
1242
955
|
};
|
|
1243
|
-
var getOptions = (o) => o && (eventOptionsSupported ? {capture: o.capture, passive: o.passive, once: o.once} : o.capture);
|
|
1244
956
|
|
|
1245
|
-
//
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
1253
|
-
* The complete set of contributors may be found at
|
|
1254
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
1255
|
-
* Code distributed by Google as part of the polymer project is also
|
|
1256
|
-
* subject to an additional IP rights grant found at
|
|
1257
|
-
* http://polymer.github.io/PATENTS.txt
|
|
1258
|
-
*/
|
|
1259
|
-
var DefaultTemplateProcessor = class {
|
|
1260
|
-
handleAttributeExpressions(element, name, strings, options) {
|
|
1261
|
-
const prefix = name[0];
|
|
1262
|
-
if (prefix === ".") {
|
|
1263
|
-
const committer2 = new PropertyCommitter(element, name.slice(1), strings);
|
|
1264
|
-
return committer2.parts;
|
|
957
|
+
// src/dom-parts/TemplatePart.js
|
|
958
|
+
var partsCache = /* @__PURE__ */ new WeakMap();
|
|
959
|
+
var fragmentsCache = /* @__PURE__ */ new WeakMap();
|
|
960
|
+
var TemplatePart = class extends Part {
|
|
961
|
+
constructor(startNode, value) {
|
|
962
|
+
if (startNode && (startNode == null ? void 0 : startNode.nodeType) !== COMMENT_NODE) {
|
|
963
|
+
throw new Error("TemplatePart: startNode is not a comment node");
|
|
1265
964
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
965
|
+
super();
|
|
966
|
+
__publicField(this, "parts", []);
|
|
967
|
+
__publicField(this, "strings");
|
|
968
|
+
__publicField(this, "childNodes", []);
|
|
969
|
+
let serverSideRendered = false;
|
|
970
|
+
if (startNode) {
|
|
971
|
+
const placeholder = startNode.data;
|
|
972
|
+
const childNodes = [startNode];
|
|
973
|
+
let childNode = startNode.nextSibling;
|
|
974
|
+
while (childNode && childNode.data !== `/${placeholder}`) {
|
|
975
|
+
childNodes.push(childNode);
|
|
976
|
+
childNode = childNode.nextSibling;
|
|
977
|
+
}
|
|
978
|
+
const endNode = childNode;
|
|
979
|
+
childNodes.push(endNode);
|
|
980
|
+
if (childNodes.length > 2) {
|
|
981
|
+
serverSideRendered = true;
|
|
982
|
+
this.childNodes = childNodes;
|
|
983
|
+
}
|
|
1268
984
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
985
|
+
this.parseValue(value);
|
|
986
|
+
if (!serverSideRendered) {
|
|
987
|
+
this.updateParts(value.values);
|
|
988
|
+
this.childNodes = [...this.childNodes];
|
|
1271
989
|
}
|
|
1272
|
-
const committer = new AttributeCommitter(element, name, strings);
|
|
1273
|
-
return committer.parts;
|
|
1274
990
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
991
|
+
update(value) {
|
|
992
|
+
this.parseValue(value);
|
|
993
|
+
this.updateParts(value.values);
|
|
1277
994
|
}
|
|
1278
|
-
|
|
1279
|
-
var
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
* @license
|
|
1284
|
-
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
1285
|
-
* This code may only be used under the BSD style license found at
|
|
1286
|
-
* http://polymer.github.io/LICENSE.txt
|
|
1287
|
-
* The complete set of authors may be found at
|
|
1288
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
1289
|
-
* The complete set of contributors may be found at
|
|
1290
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
1291
|
-
* Code distributed by Google as part of the polymer project is also
|
|
1292
|
-
* subject to an additional IP rights grant found at
|
|
1293
|
-
* http://polymer.github.io/PATENTS.txt
|
|
1294
|
-
*/
|
|
1295
|
-
function templateFactory(result) {
|
|
1296
|
-
let templateCache = templateCaches.get(result.type);
|
|
1297
|
-
if (templateCache === void 0) {
|
|
1298
|
-
templateCache = {
|
|
1299
|
-
stringsArray: new WeakMap(),
|
|
1300
|
-
keyString: new Map()
|
|
1301
|
-
};
|
|
1302
|
-
templateCaches.set(result.type, templateCache);
|
|
995
|
+
updateParts(values) {
|
|
996
|
+
var _a;
|
|
997
|
+
for (let index = 0; index < values.length; index++) {
|
|
998
|
+
(_a = this.parts[index]) == null ? void 0 : _a.update(values[index]);
|
|
999
|
+
}
|
|
1303
1000
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1001
|
+
parseValue(templateResult) {
|
|
1002
|
+
var _a;
|
|
1003
|
+
if (this.strings !== templateResult.strings) {
|
|
1004
|
+
if (this.childNodes.length === 0) {
|
|
1005
|
+
let fragment = fragmentsCache.get(templateResult.strings);
|
|
1006
|
+
if (!fragment) {
|
|
1007
|
+
fragment = this.parseFragment(templateResult);
|
|
1008
|
+
fragmentsCache.set(templateResult.strings, fragment);
|
|
1009
|
+
}
|
|
1010
|
+
const importedFragment = (_a = globalThis.document) == null ? void 0 : _a.importNode(fragment, true);
|
|
1011
|
+
this.childNodes = importedFragment.childNodes;
|
|
1012
|
+
}
|
|
1013
|
+
let parts = partsCache.get(templateResult.strings);
|
|
1014
|
+
if (!parts) {
|
|
1015
|
+
parts = templateResult.parseParts(this.childNodes);
|
|
1016
|
+
partsCache.set(templateResult.strings, parts);
|
|
1017
|
+
}
|
|
1018
|
+
let previousAttributePart = void 0;
|
|
1019
|
+
this.parts = parts.map((part, index) => {
|
|
1020
|
+
const node = part.path.reduceRight(({ childNodes }, i) => childNodes[i], this);
|
|
1021
|
+
if (part.type === "node") {
|
|
1022
|
+
return new ChildNodePart(node, templateResult.values[index]);
|
|
1023
|
+
}
|
|
1024
|
+
if (part.type === "attribute") {
|
|
1025
|
+
if (previousAttributePart && previousAttributePart.name === part.name) {
|
|
1026
|
+
previousAttributePart.addNode(node);
|
|
1027
|
+
return previousAttributePart;
|
|
1028
|
+
}
|
|
1029
|
+
return previousAttributePart = new AttributePart(node, part.name, part.initialValue);
|
|
1030
|
+
}
|
|
1031
|
+
if (part.type === "directive") {
|
|
1032
|
+
return new NodePart(node, templateResult.values[index]);
|
|
1033
|
+
}
|
|
1034
|
+
throw `cannot map part: ${part}`;
|
|
1035
|
+
});
|
|
1036
|
+
this.strings = templateResult.strings;
|
|
1037
|
+
}
|
|
1307
1038
|
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
template = new Template(result, result.getTemplateElement());
|
|
1312
|
-
templateCache.keyString.set(key, template);
|
|
1039
|
+
parseFragment(templateResult) {
|
|
1040
|
+
const templateString = templateResult.templateString;
|
|
1041
|
+
return convertStringToTemplate(templateString);
|
|
1313
1042
|
}
|
|
1314
|
-
templateCache.stringsArray.set(result.strings, template);
|
|
1315
|
-
return template;
|
|
1316
|
-
}
|
|
1317
|
-
var templateCaches = new Map();
|
|
1318
|
-
|
|
1319
|
-
// node_modules/lit-html/lib/render.js
|
|
1320
|
-
/**
|
|
1321
|
-
* @license
|
|
1322
|
-
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
1323
|
-
* This code may only be used under the BSD style license found at
|
|
1324
|
-
* http://polymer.github.io/LICENSE.txt
|
|
1325
|
-
* The complete set of authors may be found at
|
|
1326
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
1327
|
-
* The complete set of contributors may be found at
|
|
1328
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
1329
|
-
* Code distributed by Google as part of the polymer project is also
|
|
1330
|
-
* subject to an additional IP rights grant found at
|
|
1331
|
-
* http://polymer.github.io/PATENTS.txt
|
|
1332
|
-
*/
|
|
1333
|
-
var parts = new WeakMap();
|
|
1334
|
-
var render = (result, container, options) => {
|
|
1335
|
-
let part = parts.get(container);
|
|
1336
|
-
if (part === void 0) {
|
|
1337
|
-
removeNodes(container, container.firstChild);
|
|
1338
|
-
parts.set(container, part = new NodePart(Object.assign({templateFactory}, options)));
|
|
1339
|
-
part.appendInto(container);
|
|
1340
|
-
}
|
|
1341
|
-
part.setValue(result);
|
|
1342
|
-
part.commit();
|
|
1343
1043
|
};
|
|
1344
1044
|
|
|
1345
|
-
//
|
|
1346
|
-
|
|
1347
|
-
*
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
if (
|
|
1360
|
-
|
|
1361
|
-
}
|
|
1362
|
-
var html = (strings, ...values) => new TemplateResult(strings, values, "html", defaultTemplateProcessor);
|
|
1363
|
-
|
|
1364
|
-
// node_modules/lit-html/lib/modify-template.js
|
|
1365
|
-
/**
|
|
1366
|
-
* @license
|
|
1367
|
-
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
1368
|
-
* This code may only be used under the BSD style license found at
|
|
1369
|
-
* http://polymer.github.io/LICENSE.txt
|
|
1370
|
-
* The complete set of authors may be found at
|
|
1371
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
1372
|
-
* The complete set of contributors may be found at
|
|
1373
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
1374
|
-
* Code distributed by Google as part of the polymer project is also
|
|
1375
|
-
* subject to an additional IP rights grant found at
|
|
1376
|
-
* http://polymer.github.io/PATENTS.txt
|
|
1377
|
-
*/
|
|
1378
|
-
var walkerNodeFilter = 133;
|
|
1379
|
-
function removeNodesFromTemplate(template, nodesToRemove) {
|
|
1380
|
-
const {element: {content}, parts: parts2} = template;
|
|
1381
|
-
const walker = document.createTreeWalker(content, walkerNodeFilter, null, false);
|
|
1382
|
-
let partIndex = nextActiveIndexInTemplateParts(parts2);
|
|
1383
|
-
let part = parts2[partIndex];
|
|
1384
|
-
let nodeIndex = -1;
|
|
1385
|
-
let removeCount = 0;
|
|
1386
|
-
const nodesToRemoveInTemplate = [];
|
|
1387
|
-
let currentRemovingNode = null;
|
|
1388
|
-
while (walker.nextNode()) {
|
|
1389
|
-
nodeIndex++;
|
|
1390
|
-
const node = walker.currentNode;
|
|
1391
|
-
if (node.previousSibling === currentRemovingNode) {
|
|
1392
|
-
currentRemovingNode = null;
|
|
1393
|
-
}
|
|
1394
|
-
if (nodesToRemove.has(node)) {
|
|
1395
|
-
nodesToRemoveInTemplate.push(node);
|
|
1396
|
-
if (currentRemovingNode === null) {
|
|
1397
|
-
currentRemovingNode = node;
|
|
1045
|
+
// src/dom-parts/TemplateResult.js
|
|
1046
|
+
var voidElements = /^(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i;
|
|
1047
|
+
var elements = /<([a-z]+[a-z0-9:._-]*)([^>]*?)(\/?)>/g;
|
|
1048
|
+
var attributes = /([^\s]*)=((?:")[^"]*(?:")|(?:')[^']*(?:')|[^\s\/>]*)|([^\s\/>]*)/g;
|
|
1049
|
+
var partPositions = /[\x01\x02]/g;
|
|
1050
|
+
var interpolation = new RegExp(`(<!--dom-part-(\\d+)--><!--/dom-part-(\\d+)-->|(\\S\\w+)="(")?|)`, "g");
|
|
1051
|
+
var createTemplateString = (templateStrings, attributePlaceholders = "") => {
|
|
1052
|
+
let partIndex = 0;
|
|
1053
|
+
let template = templateStrings.join("").trim();
|
|
1054
|
+
template = template.replace(elements, (_, name, attributesString, trailingSlash) => {
|
|
1055
|
+
let elementTagWithAttributes = name + attributesString.replaceAll("", attributePlaceholders).trimEnd();
|
|
1056
|
+
if (trailingSlash.length)
|
|
1057
|
+
elementTagWithAttributes += voidElements.test(name) ? " /" : "></" + name;
|
|
1058
|
+
const attributeParts = attributesString.replace(attributes, (attribute2, name2, valueWithQuotes, directive) => {
|
|
1059
|
+
if (directive) {
|
|
1060
|
+
return `<!--$-->`;
|
|
1398
1061
|
}
|
|
1062
|
+
const value = (valueWithQuotes == null ? void 0 : valueWithQuotes.startsWith('"')) || (valueWithQuotes == null ? void 0 : valueWithQuotes.startsWith("'")) ? valueWithQuotes.slice(1, -1) : valueWithQuotes;
|
|
1063
|
+
const partsCount = (attribute2.match(/\x01/g) || []).length;
|
|
1064
|
+
const parts = [];
|
|
1065
|
+
for (let index = 0; index < partsCount; index++) {
|
|
1066
|
+
parts.push(`<!--:${name2}=${value.replaceAll("", "")}-->`);
|
|
1067
|
+
}
|
|
1068
|
+
return parts.join("");
|
|
1069
|
+
});
|
|
1070
|
+
return `
|
|
1071
|
+
${attributesString.includes("") ? attributeParts : ""}
|
|
1072
|
+
<${elementTagWithAttributes}>
|
|
1073
|
+
`;
|
|
1074
|
+
});
|
|
1075
|
+
template = template.replace(partPositions, (partPosition) => {
|
|
1076
|
+
if (partPosition === "") {
|
|
1077
|
+
return `<!--dom-part-${partIndex}--><!--/dom-part-${partIndex++}-->`;
|
|
1399
1078
|
}
|
|
1400
|
-
if (
|
|
1401
|
-
|
|
1402
|
-
}
|
|
1403
|
-
while (part !== void 0 && part.index === nodeIndex) {
|
|
1404
|
-
part.index = currentRemovingNode !== null ? -1 : part.index - removeCount;
|
|
1405
|
-
partIndex = nextActiveIndexInTemplateParts(parts2, partIndex);
|
|
1406
|
-
part = parts2[partIndex];
|
|
1079
|
+
if (partPosition === "") {
|
|
1080
|
+
return `dom-part-${partIndex++}`;
|
|
1407
1081
|
}
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
while (walker.nextNode()) {
|
|
1415
|
-
count++;
|
|
1416
|
-
}
|
|
1417
|
-
return count;
|
|
1082
|
+
});
|
|
1083
|
+
return `
|
|
1084
|
+
<!--template-part-->
|
|
1085
|
+
${template}
|
|
1086
|
+
<!--/template-part-->
|
|
1087
|
+
`;
|
|
1418
1088
|
};
|
|
1419
|
-
var
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1089
|
+
var attribute = (name, value, isSingleValue = true) => {
|
|
1090
|
+
return ` ${name}="${encodeAttribute(isObjectLike(value) ? JSON.stringify(value) : value)}${isSingleValue ? '"' : ""}`;
|
|
1091
|
+
};
|
|
1092
|
+
var getValue = (value) => {
|
|
1093
|
+
switch (typeof value) {
|
|
1094
|
+
case "string":
|
|
1095
|
+
return encodeAttribute(value);
|
|
1096
|
+
case "boolean":
|
|
1097
|
+
case "number":
|
|
1098
|
+
return String(value);
|
|
1099
|
+
case "object":
|
|
1100
|
+
switch (true) {
|
|
1101
|
+
case Array.isArray(value):
|
|
1102
|
+
return value.map(getValue).join("");
|
|
1103
|
+
case value instanceof TemplateResult:
|
|
1104
|
+
return value.toString();
|
|
1105
|
+
}
|
|
1106
|
+
break;
|
|
1107
|
+
case "function":
|
|
1108
|
+
return getValue(value());
|
|
1425
1109
|
}
|
|
1426
|
-
return
|
|
1110
|
+
return value == null ? "" : encodeAttribute(String(value));
|
|
1427
1111
|
};
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1112
|
+
var parsedUpdates = /* @__PURE__ */ new WeakMap();
|
|
1113
|
+
var templateParts = /* @__PURE__ */ new WeakMap();
|
|
1114
|
+
var TemplateResult = class {
|
|
1115
|
+
constructor(strings, ...values) {
|
|
1116
|
+
this.strings = strings;
|
|
1117
|
+
this.values = values;
|
|
1118
|
+
}
|
|
1119
|
+
renderInto(domNode) {
|
|
1120
|
+
let serverSideRendered = false;
|
|
1121
|
+
let templatePart = templateParts.get(domNode);
|
|
1122
|
+
if (!templatePart) {
|
|
1123
|
+
const startNode = Array.from(domNode.childNodes).filter((node) => node.nodeType === COMMENT_NODE).find((node) => node.data === "template-part");
|
|
1124
|
+
serverSideRendered = startNode !== void 0;
|
|
1125
|
+
templatePart = new TemplatePart(startNode, this);
|
|
1126
|
+
templateParts.set(domNode, templatePart);
|
|
1127
|
+
if (!serverSideRendered) {
|
|
1128
|
+
domNode.replaceChildren(...templatePart.childNodes);
|
|
1129
|
+
}
|
|
1130
|
+
} else {
|
|
1131
|
+
templatePart.update(this);
|
|
1444
1132
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1133
|
+
}
|
|
1134
|
+
parse(strings) {
|
|
1135
|
+
const html2 = createTemplateString(strings, "");
|
|
1136
|
+
const parts = [];
|
|
1137
|
+
let i = 0;
|
|
1138
|
+
let match = null;
|
|
1139
|
+
while (match = interpolation.exec(html2)) {
|
|
1140
|
+
const pre = html2.slice(i, match.index);
|
|
1141
|
+
i = match.index + match[0].length;
|
|
1142
|
+
if (match[2]) {
|
|
1143
|
+
const index = match[2];
|
|
1144
|
+
parts.push((value) => `${pre}<!--dom-part-${index}-->${getValue(value)}<!--/dom-part-${index}-->`);
|
|
1145
|
+
} else if (match[4]) {
|
|
1146
|
+
const isSingleValue = match[5] !== void 0;
|
|
1147
|
+
let name = match[4];
|
|
1148
|
+
switch (true) {
|
|
1149
|
+
case name[0] === "?":
|
|
1150
|
+
const booleanName = name.slice(1).toLowerCase();
|
|
1151
|
+
parts.push((value) => {
|
|
1152
|
+
if (!value)
|
|
1153
|
+
return "";
|
|
1154
|
+
return `${pre} ${booleanName}=""`;
|
|
1155
|
+
});
|
|
1156
|
+
break;
|
|
1157
|
+
case name[0] === ".":
|
|
1158
|
+
const lower = name.slice(1).toLowerCase();
|
|
1159
|
+
parts.push((value) => {
|
|
1160
|
+
let result = pre;
|
|
1161
|
+
if (value === null || value === void 0 || value === "") {
|
|
1162
|
+
result += attribute(lower, "");
|
|
1163
|
+
} else {
|
|
1164
|
+
result += attribute(lower, value, isSingleValue);
|
|
1165
|
+
}
|
|
1166
|
+
return result;
|
|
1167
|
+
});
|
|
1168
|
+
break;
|
|
1169
|
+
case name[0] === "@":
|
|
1170
|
+
name = "on" + name.slice(1);
|
|
1171
|
+
case (name[0] === "o" && name[1] === "n"):
|
|
1172
|
+
parts.push((value) => {
|
|
1173
|
+
return pre;
|
|
1174
|
+
});
|
|
1175
|
+
break;
|
|
1176
|
+
default:
|
|
1177
|
+
parts.push((value) => {
|
|
1178
|
+
let result = pre;
|
|
1179
|
+
if (value != null) {
|
|
1180
|
+
result += attribute(name, value, isSingleValue);
|
|
1181
|
+
}
|
|
1182
|
+
return result;
|
|
1183
|
+
});
|
|
1184
|
+
break;
|
|
1450
1185
|
}
|
|
1451
|
-
|
|
1186
|
+
} else {
|
|
1187
|
+
parts.push((value) => {
|
|
1188
|
+
let result = pre;
|
|
1189
|
+
if (isObjectLike(value) && value.directiveClass) {
|
|
1190
|
+
const directive = new value.directiveClass();
|
|
1191
|
+
result += directive.stringify(...value.values);
|
|
1192
|
+
} else if (value != null) {
|
|
1193
|
+
result += encodeAttribute(isObjectLike(value) ? JSON.stringify(value) : value);
|
|
1194
|
+
}
|
|
1195
|
+
return result;
|
|
1196
|
+
});
|
|
1452
1197
|
}
|
|
1453
|
-
partIndex = nextActiveIndexInTemplateParts(parts2, partIndex);
|
|
1454
1198
|
}
|
|
1199
|
+
if (parts.length !== strings.length - 1) {
|
|
1200
|
+
throw {
|
|
1201
|
+
name: "ParseTemplateError",
|
|
1202
|
+
message: "Could not parse parts from template correctly. Parts length has not the expected length.",
|
|
1203
|
+
strings,
|
|
1204
|
+
templateString: html2,
|
|
1205
|
+
parts
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
if (parts.length) {
|
|
1209
|
+
const last = parts[parts.length - 1];
|
|
1210
|
+
const chunk = html2.slice(i);
|
|
1211
|
+
parts[parts.length - 1] = (value) => last(value) + chunk;
|
|
1212
|
+
} else {
|
|
1213
|
+
parts.push(() => html2);
|
|
1214
|
+
}
|
|
1215
|
+
return parts;
|
|
1455
1216
|
}
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
if (
|
|
1475
|
-
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1217
|
+
parseParts(childNodes) {
|
|
1218
|
+
var _a, _b;
|
|
1219
|
+
const range = (_a = globalThis.document) == null ? void 0 : _a.createRange();
|
|
1220
|
+
range.setStartBefore(childNodes[0]);
|
|
1221
|
+
range.setEndAfter(childNodes[childNodes.length - 1]);
|
|
1222
|
+
const template = range.cloneContents();
|
|
1223
|
+
const treeWalker = (_b = globalThis.document) == null ? void 0 : _b.createTreeWalker(template, 128);
|
|
1224
|
+
let node = treeWalker.currentNode;
|
|
1225
|
+
const getParts = () => {
|
|
1226
|
+
const parts2 = [];
|
|
1227
|
+
let currentPart = void 0;
|
|
1228
|
+
while (node = treeWalker.nextNode()) {
|
|
1229
|
+
if (/^template-part$/.test(node.data) && currentPart) {
|
|
1230
|
+
currentPart.parts = getParts();
|
|
1231
|
+
}
|
|
1232
|
+
if (/^\/template-part$/.test(node.data)) {
|
|
1233
|
+
return parts2;
|
|
1234
|
+
}
|
|
1235
|
+
if (/^dom-part-\d+$/.test(node.data)) {
|
|
1236
|
+
parts2.push(currentPart = { type: "node", path: getNodePath(node), parts: [] });
|
|
1237
|
+
}
|
|
1238
|
+
if (/^dom-part-\d+:/.test(node.data)) {
|
|
1239
|
+
const [_, attribute2] = node.data.split(":");
|
|
1240
|
+
const [name, initialValue] = attribute2.split("=");
|
|
1241
|
+
currentPart = void 0;
|
|
1242
|
+
parts2.push({ type: "attribute", path: getNodePath(node), name, initialValue });
|
|
1243
|
+
}
|
|
1244
|
+
if (/^dom-part-\d+\$/.test(node.data)) {
|
|
1245
|
+
currentPart = void 0;
|
|
1246
|
+
parts2.push({ type: "directive", path: getNodePath(node) });
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
return parts2;
|
|
1487
1250
|
};
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1251
|
+
const parts = getParts();
|
|
1252
|
+
if (parts.length !== this.strings.length - 1) {
|
|
1253
|
+
throw {
|
|
1254
|
+
name: "ParseTemplateError",
|
|
1255
|
+
message: "Could not parse parts from template correctly. Parts length has not the expected length. -> " + JSON.stringify({
|
|
1256
|
+
strings: this.strings,
|
|
1257
|
+
templateString: this.templateString,
|
|
1258
|
+
childNodes,
|
|
1259
|
+
template,
|
|
1260
|
+
parts
|
|
1261
|
+
})
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
return parts;
|
|
1265
|
+
}
|
|
1266
|
+
get templateString() {
|
|
1267
|
+
return createTemplateString(this.strings);
|
|
1503
1268
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
TEMPLATE_TYPES.forEach((type) => {
|
|
1510
|
-
const templates = templateCaches.get(getTemplateCacheKey(type, scopeName));
|
|
1511
|
-
if (templates !== void 0) {
|
|
1512
|
-
templates.keyString.forEach((template) => {
|
|
1513
|
-
const {element: {content}} = template;
|
|
1514
|
-
const styles = new Set();
|
|
1515
|
-
Array.from(content.querySelectorAll("style")).forEach((s) => {
|
|
1516
|
-
styles.add(s);
|
|
1517
|
-
});
|
|
1518
|
-
removeNodesFromTemplate(template, styles);
|
|
1519
|
-
});
|
|
1269
|
+
toString() {
|
|
1270
|
+
let updates = parsedUpdates.get(this.strings);
|
|
1271
|
+
if (!updates) {
|
|
1272
|
+
updates = this.parse(this.strings);
|
|
1273
|
+
parsedUpdates.set(this.strings, updates);
|
|
1520
1274
|
}
|
|
1521
|
-
|
|
1522
|
-
};
|
|
1523
|
-
var shadyRenderSet = new Set();
|
|
1524
|
-
var prepareTemplateStyles = (scopeName, renderedDOM, template) => {
|
|
1525
|
-
shadyRenderSet.add(scopeName);
|
|
1526
|
-
const templateElement = !!template ? template.element : document.createElement("template");
|
|
1527
|
-
const styles = renderedDOM.querySelectorAll("style");
|
|
1528
|
-
const {length} = styles;
|
|
1529
|
-
if (length === 0) {
|
|
1530
|
-
window.ShadyCSS.prepareTemplateStyles(templateElement, scopeName);
|
|
1531
|
-
return;
|
|
1532
|
-
}
|
|
1533
|
-
const condensedStyle = document.createElement("style");
|
|
1534
|
-
for (let i = 0; i < length; i++) {
|
|
1535
|
-
const style2 = styles[i];
|
|
1536
|
-
style2.parentNode.removeChild(style2);
|
|
1537
|
-
condensedStyle.textContent += style2.textContent;
|
|
1538
|
-
}
|
|
1539
|
-
removeStylesFromLitTemplates(scopeName);
|
|
1540
|
-
const content = templateElement.content;
|
|
1541
|
-
if (!!template) {
|
|
1542
|
-
insertNodeIntoTemplate(template, condensedStyle, content.firstChild);
|
|
1543
|
-
} else {
|
|
1544
|
-
content.insertBefore(condensedStyle, content.firstChild);
|
|
1545
|
-
}
|
|
1546
|
-
window.ShadyCSS.prepareTemplateStyles(templateElement, scopeName);
|
|
1547
|
-
const style = content.querySelector("style");
|
|
1548
|
-
if (window.ShadyCSS.nativeShadow && style !== null) {
|
|
1549
|
-
renderedDOM.insertBefore(style.cloneNode(true), renderedDOM.firstChild);
|
|
1550
|
-
} else if (!!template) {
|
|
1551
|
-
content.insertBefore(condensedStyle, content.firstChild);
|
|
1552
|
-
const removes = new Set();
|
|
1553
|
-
removes.add(condensedStyle);
|
|
1554
|
-
removeNodesFromTemplate(template, removes);
|
|
1275
|
+
return this.values.length ? this.values.map((value, index) => updates[index](value)).join("") : updates[0]();
|
|
1555
1276
|
}
|
|
1556
1277
|
};
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
render(result, renderContainer, Object.assign({templateFactory: shadyTemplateFactory(scopeName)}, options));
|
|
1567
|
-
if (firstScopeRender) {
|
|
1568
|
-
const part = parts.get(renderContainer);
|
|
1569
|
-
parts.delete(renderContainer);
|
|
1570
|
-
const template = part.value instanceof TemplateInstance ? part.value.template : void 0;
|
|
1571
|
-
prepareTemplateStyles(scopeName, renderContainer, template);
|
|
1572
|
-
removeNodes(container, container.firstChild);
|
|
1573
|
-
container.appendChild(renderContainer);
|
|
1574
|
-
parts.set(container, part);
|
|
1575
|
-
}
|
|
1576
|
-
if (!hasRendered && needsScoping) {
|
|
1577
|
-
window.ShadyCSS.styleElement(container.host);
|
|
1578
|
-
}
|
|
1278
|
+
|
|
1279
|
+
// src/dom-parts/html.js
|
|
1280
|
+
var html = function(strings, ...values) {
|
|
1281
|
+
return new TemplateResult(strings, ...values);
|
|
1282
|
+
};
|
|
1283
|
+
|
|
1284
|
+
// src/dom-parts/render.js
|
|
1285
|
+
var render = (template, domNode) => {
|
|
1286
|
+
template.renderInto(domNode);
|
|
1579
1287
|
};
|
|
1580
1288
|
|
|
1581
1289
|
// src/TemplateElement.js
|
|
@@ -1593,7 +1301,7 @@ var TemplateElement = class extends StyledElement {
|
|
|
1593
1301
|
});
|
|
1594
1302
|
this._template = this._options.template;
|
|
1595
1303
|
if (this._options.shadowRender)
|
|
1596
|
-
this.attachShadow({mode: "open"});
|
|
1304
|
+
this.attachShadow({ mode: "open" });
|
|
1597
1305
|
}
|
|
1598
1306
|
template() {
|
|
1599
1307
|
return html``;
|
|
@@ -1607,18 +1315,29 @@ var TemplateElement = class extends StyledElement {
|
|
|
1607
1315
|
if (typeof template === "string") {
|
|
1608
1316
|
this.getRoot().innerHTML = `${template}`;
|
|
1609
1317
|
} else {
|
|
1610
|
-
|
|
1611
|
-
scopeName: this.localName,
|
|
1612
|
-
eventContext: this
|
|
1613
|
-
});
|
|
1318
|
+
render(template, this.getRoot());
|
|
1614
1319
|
}
|
|
1615
1320
|
}
|
|
1616
1321
|
getRoot() {
|
|
1617
1322
|
return this.shadowRoot !== null ? this.shadowRoot : this;
|
|
1618
1323
|
}
|
|
1619
1324
|
};
|
|
1325
|
+
|
|
1326
|
+
// src/util/Directive.js
|
|
1327
|
+
var Directive = class {
|
|
1328
|
+
constructor(node) {
|
|
1329
|
+
__publicField(this, "node");
|
|
1330
|
+
this.node = node;
|
|
1331
|
+
}
|
|
1332
|
+
update() {
|
|
1333
|
+
}
|
|
1334
|
+
stringify(...values) {
|
|
1335
|
+
return "";
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1620
1338
|
export {
|
|
1621
1339
|
BaseElement,
|
|
1340
|
+
Directive,
|
|
1622
1341
|
Store,
|
|
1623
1342
|
StyledElement,
|
|
1624
1343
|
TemplateElement,
|