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