lwc 2.22.0 → 2.23.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/dist/engine-dom/esm/es2017/engine-dom.js +1222 -947
- package/dist/engine-dom/iife/es2017/engine-dom.js +1222 -946
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +1129 -882
- package/dist/engine-dom/iife/es5/engine-dom.js +524 -499
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +475 -457
- package/dist/engine-dom/umd/es2017/engine-dom.js +1222 -946
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +1129 -882
- package/dist/engine-dom/umd/es5/engine-dom.js +524 -499
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +475 -457
- package/dist/engine-server/commonjs/es2017/engine-server.js +809 -626
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +809 -626
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +30 -27
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +30 -27
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +29 -26
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +32 -31
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +31 -30
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +30 -27
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +29 -26
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +32 -31
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +31 -30
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +7 -7
|
@@ -291,7 +291,11 @@ var LWC = (function (exports) {
|
|
|
291
291
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
292
292
|
return attributeName;
|
|
293
293
|
}
|
|
294
|
-
/** version: 2.
|
|
294
|
+
/** version: 2.23.2 */
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Copyright (C) 2018 salesforce.com, inc.
|
|
298
|
+
*/
|
|
295
299
|
|
|
296
300
|
/*
|
|
297
301
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -300,7 +304,7 @@ var LWC = (function (exports) {
|
|
|
300
304
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
301
305
|
*/
|
|
302
306
|
function detect(propName) {
|
|
303
|
-
return
|
|
307
|
+
return getOwnPropertyDescriptor$1(Element.prototype, propName) === undefined;
|
|
304
308
|
}
|
|
305
309
|
|
|
306
310
|
/*
|
|
@@ -369,6 +373,7 @@ var LWC = (function (exports) {
|
|
|
369
373
|
patch$1(propName);
|
|
370
374
|
}
|
|
371
375
|
}
|
|
376
|
+
/** version: 2.23.2 */
|
|
372
377
|
|
|
373
378
|
/**
|
|
374
379
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -388,6 +393,7 @@ var LWC = (function (exports) {
|
|
|
388
393
|
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
389
394
|
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
390
395
|
ENABLE_MIXED_SHADOW_MODE: null,
|
|
396
|
+
ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
|
|
391
397
|
ENABLE_NODE_LIST_PATCH: null,
|
|
392
398
|
ENABLE_NODE_PATCH: null,
|
|
393
399
|
ENABLE_REACTIVE_SETTER: null,
|
|
@@ -396,7 +402,7 @@ var LWC = (function (exports) {
|
|
|
396
402
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
397
403
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
398
404
|
}
|
|
399
|
-
const
|
|
405
|
+
const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
|
|
400
406
|
/**
|
|
401
407
|
* Set the value at runtime of a given feature flag. This method only be invoked once per feature
|
|
402
408
|
* flag. It is meant to be used during the app initialization.
|
|
@@ -420,13 +426,13 @@ var LWC = (function (exports) {
|
|
|
420
426
|
}
|
|
421
427
|
{
|
|
422
428
|
// Disallow the same flag to be set more than once in production
|
|
423
|
-
const runtimeValue =
|
|
429
|
+
const runtimeValue = lwcRuntimeFlags[name];
|
|
424
430
|
if (!isUndefined$1(runtimeValue)) {
|
|
425
431
|
// eslint-disable-next-line no-console
|
|
426
432
|
console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
|
|
427
433
|
return;
|
|
428
434
|
}
|
|
429
|
-
defineProperty(
|
|
435
|
+
defineProperty(lwcRuntimeFlags, name, { value });
|
|
430
436
|
}
|
|
431
437
|
}
|
|
432
438
|
/**
|
|
@@ -701,8 +707,8 @@ var LWC = (function (exports) {
|
|
|
701
707
|
*/
|
|
702
708
|
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
703
709
|
// to inject at runtime.
|
|
704
|
-
const HTMLElementConstructor
|
|
705
|
-
const HTMLElementPrototype = HTMLElementConstructor
|
|
710
|
+
const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () { };
|
|
711
|
+
const HTMLElementPrototype = HTMLElementConstructor.prototype;
|
|
706
712
|
|
|
707
713
|
/*
|
|
708
714
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -859,6 +865,14 @@ var LWC = (function (exports) {
|
|
|
859
865
|
}
|
|
860
866
|
});
|
|
861
867
|
|
|
868
|
+
function updateComponentValue(vm, key, newValue) {
|
|
869
|
+
const { cmpFields } = vm;
|
|
870
|
+
if (newValue !== cmpFields[key]) {
|
|
871
|
+
cmpFields[key] = newValue;
|
|
872
|
+
componentValueMutated(vm, key);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|
|
862
876
|
/**
|
|
863
877
|
* Copyright (C) 2017 salesforce.com, inc.
|
|
864
878
|
*/
|
|
@@ -1342,10 +1356,7 @@ var LWC = (function (exports) {
|
|
|
1342
1356
|
},
|
|
1343
1357
|
set(newValue) {
|
|
1344
1358
|
const vm = getAssociatedVM(this);
|
|
1345
|
-
|
|
1346
|
-
vm.cmpProps[propName] = newValue;
|
|
1347
|
-
componentValueMutated(vm, propName);
|
|
1348
|
-
}
|
|
1359
|
+
updateComponentValue(vm, propName, newValue);
|
|
1349
1360
|
return set.call(vm.elm, newValue);
|
|
1350
1361
|
},
|
|
1351
1362
|
};
|
|
@@ -1574,10 +1585,7 @@ var LWC = (function (exports) {
|
|
|
1574
1585
|
},
|
|
1575
1586
|
set(newValue) {
|
|
1576
1587
|
const vm = getAssociatedVM(this);
|
|
1577
|
-
|
|
1578
|
-
vm.cmpFields[key] = newValue;
|
|
1579
|
-
componentValueMutated(vm, key);
|
|
1580
|
-
}
|
|
1588
|
+
updateComponentValue(vm, key, newValue);
|
|
1581
1589
|
},
|
|
1582
1590
|
enumerable: true,
|
|
1583
1591
|
configurable: true,
|
|
@@ -1681,7 +1689,7 @@ var LWC = (function (exports) {
|
|
|
1681
1689
|
const vm = getAssociatedVM(this);
|
|
1682
1690
|
|
|
1683
1691
|
if (set) {
|
|
1684
|
-
if (
|
|
1692
|
+
if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
|
|
1685
1693
|
let ro = vm.oar[key];
|
|
1686
1694
|
|
|
1687
1695
|
if (isUndefined$1(ro)) {
|
|
@@ -1729,10 +1737,7 @@ var LWC = (function (exports) {
|
|
|
1729
1737
|
set(newValue) {
|
|
1730
1738
|
const vm = getAssociatedVM(this);
|
|
1731
1739
|
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
1732
|
-
|
|
1733
|
-
vm.cmpFields[key] = reactiveOrAnyValue;
|
|
1734
|
-
componentValueMutated(vm, key);
|
|
1735
|
-
}
|
|
1740
|
+
updateComponentValue(vm, key, reactiveOrAnyValue);
|
|
1736
1741
|
},
|
|
1737
1742
|
enumerable: true,
|
|
1738
1743
|
configurable: true,
|
|
@@ -1768,10 +1773,7 @@ var LWC = (function (exports) {
|
|
|
1768
1773
|
* letting the author to do the wrong thing, but it will keep our
|
|
1769
1774
|
* system to be backward compatible.
|
|
1770
1775
|
*/
|
|
1771
|
-
|
|
1772
|
-
vm.cmpFields[key] = value;
|
|
1773
|
-
componentValueMutated(vm, key);
|
|
1774
|
-
}
|
|
1776
|
+
updateComponentValue(vm, key, value);
|
|
1775
1777
|
},
|
|
1776
1778
|
enumerable: true,
|
|
1777
1779
|
configurable: true,
|
|
@@ -2096,7 +2098,7 @@ var LWC = (function (exports) {
|
|
|
2096
2098
|
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
2097
2099
|
return HTMLBridgeElement;
|
|
2098
2100
|
}
|
|
2099
|
-
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor
|
|
2101
|
+
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
|
|
2100
2102
|
freeze(BaseBridgeElement);
|
|
2101
2103
|
seal(BaseBridgeElement.prototype);
|
|
2102
2104
|
function setActiveVM(vm) {
|
|
@@ -2107,7 +2109,7 @@ var LWC = (function (exports) {
|
|
|
2107
2109
|
}
|
|
2108
2110
|
function swapTemplate(oldTpl, newTpl) {
|
|
2109
2111
|
|
|
2110
|
-
if (!
|
|
2112
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2111
2113
|
throw new Error('HMR is not enabled');
|
|
2112
2114
|
}
|
|
2113
2115
|
|
|
@@ -2115,7 +2117,7 @@ var LWC = (function (exports) {
|
|
|
2115
2117
|
}
|
|
2116
2118
|
function swapComponent(oldComponent, newComponent) {
|
|
2117
2119
|
|
|
2118
|
-
if (!
|
|
2120
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2119
2121
|
throw new Error('HMR is not enabled');
|
|
2120
2122
|
}
|
|
2121
2123
|
|
|
@@ -2123,7 +2125,7 @@ var LWC = (function (exports) {
|
|
|
2123
2125
|
}
|
|
2124
2126
|
function swapStyle(oldStyle, newStyle) {
|
|
2125
2127
|
|
|
2126
|
-
if (!
|
|
2128
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2127
2129
|
throw new Error('HMR is not enabled');
|
|
2128
2130
|
}
|
|
2129
2131
|
|
|
@@ -2440,13 +2442,13 @@ var LWC = (function (exports) {
|
|
|
2440
2442
|
return owner;
|
|
2441
2443
|
}
|
|
2442
2444
|
function createStylesheet(vm, stylesheets) {
|
|
2443
|
-
const { renderMode, shadowMode, renderer: {
|
|
2445
|
+
const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
|
|
2444
2446
|
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
2445
2447
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
2446
2448
|
insertStylesheet(stylesheets[i]);
|
|
2447
2449
|
}
|
|
2448
2450
|
}
|
|
2449
|
-
else if (
|
|
2451
|
+
else if (vm.hydrated) {
|
|
2450
2452
|
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
2451
2453
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
2452
2454
|
// the first time the VM renders.
|
|
@@ -2471,30 +2473,61 @@ var LWC = (function (exports) {
|
|
|
2471
2473
|
* SPDX-License-Identifier: MIT
|
|
2472
2474
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2473
2475
|
*/
|
|
2476
|
+
|
|
2477
|
+
function checkHasVM(elm) {
|
|
2478
|
+
const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
2479
|
+
|
|
2480
|
+
return hasVM;
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2474
2483
|
function getUpgradableConstructor(tagName, renderer) {
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2484
|
+
const {
|
|
2485
|
+
getCustomElement,
|
|
2486
|
+
HTMLElementExported: RendererHTMLElement,
|
|
2487
|
+
defineCustomElement
|
|
2488
|
+
} = renderer; // Should never get a tag with upper case letter at this point, the compiler should
|
|
2489
|
+
// produce only tags with lowercase letters
|
|
2490
|
+
// But, for backwards compatibility, we will lower case the tagName
|
|
2491
|
+
|
|
2492
|
+
tagName = tagName.toLowerCase();
|
|
2493
|
+
let CE = getCustomElement(tagName);
|
|
2494
|
+
|
|
2495
|
+
if (!isUndefined$1(CE)) {
|
|
2496
|
+
return CE;
|
|
2497
|
+
}
|
|
2498
|
+
/**
|
|
2499
|
+
* LWC Upgradable Element reference to an element that was created
|
|
2500
|
+
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
2501
|
+
*/
|
|
2502
|
+
|
|
2503
|
+
|
|
2504
|
+
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
2505
|
+
constructor(upgradeCallback) {
|
|
2506
|
+
super();
|
|
2507
|
+
|
|
2508
|
+
if (isFunction$1(upgradeCallback)) {
|
|
2509
|
+
upgradeCallback(this); // nothing to do with the result for now
|
|
2510
|
+
}
|
|
2483
2511
|
}
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
CE =
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
upgradeCallback(this); // nothing to do with the result for now
|
|
2493
|
-
}
|
|
2494
|
-
}
|
|
2512
|
+
|
|
2513
|
+
};
|
|
2514
|
+
|
|
2515
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
2516
|
+
CE.prototype.connectedCallback = function () {
|
|
2517
|
+
if (checkHasVM(this)) {
|
|
2518
|
+
connectRootElement(this);
|
|
2519
|
+
}
|
|
2495
2520
|
};
|
|
2496
|
-
|
|
2497
|
-
|
|
2521
|
+
|
|
2522
|
+
CE.prototype.disconnectedCallback = function () {
|
|
2523
|
+
if (checkHasVM(this)) {
|
|
2524
|
+
disconnectRootElement(this);
|
|
2525
|
+
}
|
|
2526
|
+
};
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2529
|
+
defineCustomElement(tagName, CE);
|
|
2530
|
+
return CE;
|
|
2498
2531
|
}
|
|
2499
2532
|
|
|
2500
2533
|
/*
|
|
@@ -2736,524 +2769,732 @@ var LWC = (function (exports) {
|
|
|
2736
2769
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2737
2770
|
*/
|
|
2738
2771
|
function patchChildren(c1, c2, parent, renderer) {
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
}
|
|
2772
|
+
if (hasDynamicChildren(c2)) {
|
|
2773
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
2774
|
+
} else {
|
|
2775
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
2776
|
+
}
|
|
2745
2777
|
}
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2778
|
+
|
|
2779
|
+
function patch(n1, n2, parent, renderer) {
|
|
2780
|
+
var _a, _b;
|
|
2781
|
+
|
|
2782
|
+
if (n1 === n2) {
|
|
2783
|
+
return;
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
switch (n2.type) {
|
|
2787
|
+
case 0
|
|
2788
|
+
/* VNodeType.Text */
|
|
2789
|
+
:
|
|
2790
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
2791
|
+
patchText(n1, n2, renderer);
|
|
2792
|
+
break;
|
|
2793
|
+
|
|
2794
|
+
case 1
|
|
2795
|
+
/* VNodeType.Comment */
|
|
2796
|
+
:
|
|
2797
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
2798
|
+
patchComment(n1, n2, renderer);
|
|
2799
|
+
break;
|
|
2800
|
+
|
|
2801
|
+
case 4
|
|
2802
|
+
/* VNodeType.Static */
|
|
2803
|
+
:
|
|
2804
|
+
n2.elm = n1.elm;
|
|
2805
|
+
break;
|
|
2806
|
+
|
|
2807
|
+
case 2
|
|
2808
|
+
/* VNodeType.Element */
|
|
2809
|
+
:
|
|
2810
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
2811
|
+
break;
|
|
2812
|
+
|
|
2813
|
+
case 3
|
|
2814
|
+
/* VNodeType.CustomElement */
|
|
2815
|
+
:
|
|
2816
|
+
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
2817
|
+
break;
|
|
2818
|
+
}
|
|
2770
2819
|
}
|
|
2820
|
+
|
|
2771
2821
|
function mount(node, parent, renderer, anchor) {
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2822
|
+
var _a, _b;
|
|
2823
|
+
|
|
2824
|
+
switch (node.type) {
|
|
2825
|
+
case 0
|
|
2826
|
+
/* VNodeType.Text */
|
|
2827
|
+
:
|
|
2828
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
2829
|
+
mountText(node, parent, anchor, renderer);
|
|
2830
|
+
break;
|
|
2831
|
+
|
|
2832
|
+
case 1
|
|
2833
|
+
/* VNodeType.Comment */
|
|
2834
|
+
:
|
|
2835
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
2836
|
+
mountComment(node, parent, anchor, renderer);
|
|
2837
|
+
break;
|
|
2838
|
+
|
|
2839
|
+
case 4
|
|
2840
|
+
/* VNodeType.Static */
|
|
2841
|
+
:
|
|
2842
|
+
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
2843
|
+
mountStatic(node, parent, anchor, renderer);
|
|
2844
|
+
break;
|
|
2845
|
+
|
|
2846
|
+
case 2
|
|
2847
|
+
/* VNodeType.Element */
|
|
2848
|
+
:
|
|
2849
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
2850
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
2851
|
+
break;
|
|
2852
|
+
|
|
2853
|
+
case 3
|
|
2854
|
+
/* VNodeType.CustomElement */
|
|
2855
|
+
:
|
|
2856
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
2857
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
2858
|
+
break;
|
|
2859
|
+
}
|
|
2795
2860
|
}
|
|
2861
|
+
|
|
2796
2862
|
function patchText(n1, n2, renderer) {
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2863
|
+
n2.elm = n1.elm;
|
|
2864
|
+
|
|
2865
|
+
if (n2.text !== n1.text) {
|
|
2866
|
+
updateTextContent(n2, renderer);
|
|
2867
|
+
}
|
|
2801
2868
|
}
|
|
2869
|
+
|
|
2802
2870
|
function mountText(vnode, parent, anchor, renderer) {
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2871
|
+
const {
|
|
2872
|
+
owner
|
|
2873
|
+
} = vnode;
|
|
2874
|
+
const {
|
|
2875
|
+
createText
|
|
2876
|
+
} = renderer;
|
|
2877
|
+
const textNode = vnode.elm = createText(vnode.text);
|
|
2878
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
2879
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
2808
2880
|
}
|
|
2881
|
+
|
|
2809
2882
|
function patchComment(n1, n2, renderer) {
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2883
|
+
n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
2884
|
+
// it is the case today.
|
|
2885
|
+
|
|
2886
|
+
if (n2.text !== n1.text) {
|
|
2887
|
+
updateTextContent(n2, renderer);
|
|
2888
|
+
}
|
|
2816
2889
|
}
|
|
2890
|
+
|
|
2817
2891
|
function mountComment(vnode, parent, anchor, renderer) {
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2892
|
+
const {
|
|
2893
|
+
owner
|
|
2894
|
+
} = vnode;
|
|
2895
|
+
const {
|
|
2896
|
+
createComment
|
|
2897
|
+
} = renderer;
|
|
2898
|
+
const commentNode = vnode.elm = createComment(vnode.text);
|
|
2899
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
2900
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
2823
2901
|
}
|
|
2902
|
+
|
|
2824
2903
|
function mountElement(vnode, parent, anchor, renderer) {
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2904
|
+
const {
|
|
2905
|
+
sel,
|
|
2906
|
+
owner,
|
|
2907
|
+
data: {
|
|
2908
|
+
svg
|
|
2909
|
+
}
|
|
2910
|
+
} = vnode;
|
|
2911
|
+
const {
|
|
2912
|
+
createElement
|
|
2913
|
+
} = renderer;
|
|
2914
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
2915
|
+
const elm = vnode.elm = createElement(sel, namespace);
|
|
2916
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
2917
|
+
applyStyleScoping(elm, owner, renderer);
|
|
2918
|
+
applyDomManual(elm, vnode);
|
|
2919
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
2920
|
+
insertNode(elm, parent, anchor, renderer);
|
|
2921
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
2835
2922
|
}
|
|
2923
|
+
|
|
2836
2924
|
function patchElement(n1, n2, renderer) {
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2925
|
+
const elm = n2.elm = n1.elm;
|
|
2926
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
2927
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
2840
2928
|
}
|
|
2929
|
+
|
|
2841
2930
|
function mountStatic(vnode, parent, anchor, renderer) {
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2931
|
+
const {
|
|
2932
|
+
owner
|
|
2933
|
+
} = vnode;
|
|
2934
|
+
const {
|
|
2935
|
+
cloneNode,
|
|
2936
|
+
isSyntheticShadowDefined
|
|
2937
|
+
} = renderer;
|
|
2938
|
+
const elm = vnode.elm = cloneNode(vnode.fragment, true);
|
|
2939
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
2940
|
+
|
|
2941
|
+
const {
|
|
2942
|
+
renderMode,
|
|
2943
|
+
shadowMode
|
|
2944
|
+
} = owner;
|
|
2945
|
+
|
|
2946
|
+
if (isSyntheticShadowDefined) {
|
|
2947
|
+
if (shadowMode === 1
|
|
2948
|
+
/* ShadowMode.Synthetic */
|
|
2949
|
+
|| renderMode === 0
|
|
2950
|
+
/* RenderMode.Light */
|
|
2951
|
+
) {
|
|
2952
|
+
elm[KEY__SHADOW_STATIC] = true;
|
|
2852
2953
|
}
|
|
2853
|
-
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
insertNode(elm, parent, anchor, renderer);
|
|
2854
2957
|
}
|
|
2958
|
+
|
|
2855
2959
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2960
|
+
const {
|
|
2961
|
+
sel,
|
|
2962
|
+
owner
|
|
2963
|
+
} = vnode;
|
|
2964
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
2965
|
+
/**
|
|
2966
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
2967
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
2968
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
2969
|
+
* an upgradable custom element.
|
|
2970
|
+
*/
|
|
2971
|
+
|
|
2972
|
+
let vm;
|
|
2973
|
+
const elm = new UpgradableConstructor(elm => {
|
|
2974
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
2975
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
2976
|
+
});
|
|
2977
|
+
vnode.elm = elm;
|
|
2978
|
+
vnode.vm = vm;
|
|
2979
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
2980
|
+
applyStyleScoping(elm, owner, renderer);
|
|
2981
|
+
|
|
2982
|
+
if (vm) {
|
|
2983
|
+
allocateChildren(vnode, vm);
|
|
2984
|
+
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
2985
|
+
throw new TypeError(`Incorrect Component Constructor`);
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
2989
|
+
insertNode(elm, parent, anchor, renderer);
|
|
2990
|
+
|
|
2991
|
+
if (vm) {
|
|
2992
|
+
{
|
|
2993
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
2994
|
+
|
|
2882
2995
|
runConnectedCallback(vm);
|
|
2996
|
+
}
|
|
2883
2997
|
}
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3001
|
+
|
|
3002
|
+
if (vm) {
|
|
3003
|
+
appendVM(vm);
|
|
3004
|
+
}
|
|
2888
3005
|
}
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
3006
|
+
|
|
3007
|
+
function patchCustomElement(n1, n2, parent, renderer) {
|
|
3008
|
+
if (n1.ctor !== n2.ctor) {
|
|
3009
|
+
// If the constructor, unmount the current component and mount a new one using the new
|
|
3010
|
+
// constructor.
|
|
3011
|
+
const anchor = renderer.nextSibling(n1.elm);
|
|
3012
|
+
unmount(n1, parent, renderer, true);
|
|
3013
|
+
mountCustomElement(n2, parent, anchor, renderer);
|
|
3014
|
+
} else {
|
|
3015
|
+
// Otherwise patch the existing component with new props/attrs/etc.
|
|
3016
|
+
const elm = n2.elm = n1.elm;
|
|
3017
|
+
const vm = n2.vm = n1.vm;
|
|
2892
3018
|
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3019
|
+
|
|
2893
3020
|
if (!isUndefined$1(vm)) {
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
}
|
|
2898
|
-
// in fallback mode, the children will be always empty, so, nothing
|
|
3021
|
+
// in fallback mode, the allocation will always set children to
|
|
3022
|
+
// empty and delegate the real allocation to the slot elements
|
|
3023
|
+
allocateChildren(n2, vm);
|
|
3024
|
+
} // in fallback mode, the children will be always empty, so, nothing
|
|
2899
3025
|
// will happen, but in native, it does allocate the light dom
|
|
3026
|
+
|
|
3027
|
+
|
|
2900
3028
|
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3029
|
+
|
|
2901
3030
|
if (!isUndefined$1(vm)) {
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
3031
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3032
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
3033
|
+
rerenderVM(vm);
|
|
2905
3034
|
}
|
|
3035
|
+
}
|
|
2906
3036
|
}
|
|
3037
|
+
|
|
2907
3038
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
3039
|
+
for (; start < end; ++start) {
|
|
3040
|
+
const vnode = vnodes[start];
|
|
3041
|
+
|
|
3042
|
+
if (isVNode(vnode)) {
|
|
3043
|
+
mount(vnode, parent, renderer, anchor);
|
|
2913
3044
|
}
|
|
3045
|
+
}
|
|
2914
3046
|
}
|
|
3047
|
+
|
|
2915
3048
|
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
3049
|
+
const {
|
|
3050
|
+
type,
|
|
3051
|
+
elm,
|
|
3052
|
+
sel
|
|
3053
|
+
} = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3054
|
+
// subtree root, is the only element worth unmounting from the subtree.
|
|
3055
|
+
|
|
3056
|
+
if (doRemove) {
|
|
3057
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
3058
|
+
// but the removal used here is from the owner instead.
|
|
3059
|
+
removeNode(elm, parent, renderer);
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
switch (type) {
|
|
3063
|
+
case 2
|
|
3064
|
+
/* VNodeType.Element */
|
|
3065
|
+
:
|
|
3066
|
+
{
|
|
3067
|
+
// Slot content is removed to trigger slotchange event when removing slot.
|
|
3068
|
+
// Only required for synthetic shadow.
|
|
3069
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
|
|
3070
|
+
/* ShadowMode.Synthetic */
|
|
3071
|
+
;
|
|
3072
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
3073
|
+
break;
|
|
3074
|
+
}
|
|
3075
|
+
|
|
3076
|
+
case 3
|
|
3077
|
+
/* VNodeType.CustomElement */
|
|
3078
|
+
:
|
|
3079
|
+
{
|
|
3080
|
+
const {
|
|
3081
|
+
vm
|
|
3082
|
+
} = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
|
|
3083
|
+
// children.
|
|
3084
|
+
|
|
3085
|
+
if (!isUndefined$1(vm)) {
|
|
3086
|
+
removeVM(vm);
|
|
2939
3087
|
}
|
|
2940
|
-
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
2941
3090
|
}
|
|
3091
|
+
|
|
2942
3092
|
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
3093
|
+
for (; start < end; ++start) {
|
|
3094
|
+
const ch = vnodes[start];
|
|
3095
|
+
|
|
3096
|
+
if (isVNode(ch)) {
|
|
3097
|
+
unmount(ch, parent, renderer, doRemove);
|
|
2948
3098
|
}
|
|
3099
|
+
}
|
|
2949
3100
|
}
|
|
3101
|
+
|
|
2950
3102
|
function isVNode(vnode) {
|
|
2951
|
-
|
|
3103
|
+
return vnode != null;
|
|
2952
3104
|
}
|
|
3105
|
+
|
|
2953
3106
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
3107
|
+
const {
|
|
3108
|
+
renderRoot,
|
|
3109
|
+
renderMode,
|
|
3110
|
+
shadowMode
|
|
3111
|
+
} = owner;
|
|
3112
|
+
const {
|
|
3113
|
+
isSyntheticShadowDefined
|
|
3114
|
+
} = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
|
|
3115
|
+
|
|
3116
|
+
if (isSyntheticShadowDefined) {
|
|
3117
|
+
if (shadowMode === 1
|
|
3118
|
+
/* ShadowMode.Synthetic */
|
|
3119
|
+
|| renderMode === 0
|
|
3120
|
+
/* RenderMode.Light */
|
|
3121
|
+
) {
|
|
3122
|
+
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
2961
3123
|
}
|
|
3124
|
+
}
|
|
2962
3125
|
}
|
|
3126
|
+
|
|
2963
3127
|
function updateTextContent(vnode, renderer) {
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
3128
|
+
const {
|
|
3129
|
+
elm,
|
|
3130
|
+
text
|
|
3131
|
+
} = vnode;
|
|
3132
|
+
const {
|
|
3133
|
+
setText
|
|
3134
|
+
} = renderer;
|
|
3135
|
+
|
|
3136
|
+
setText(elm, text);
|
|
2967
3137
|
}
|
|
3138
|
+
|
|
2968
3139
|
function insertNode(node, parent, anchor, renderer) {
|
|
2969
|
-
|
|
3140
|
+
|
|
3141
|
+
renderer.insert(node, parent, anchor);
|
|
2970
3142
|
}
|
|
3143
|
+
|
|
2971
3144
|
function removeNode(node, parent, renderer) {
|
|
2972
|
-
|
|
3145
|
+
|
|
3146
|
+
renderer.remove(node, parent);
|
|
2973
3147
|
}
|
|
3148
|
+
|
|
2974
3149
|
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
3150
|
+
if (isNull(oldVnode)) {
|
|
3151
|
+
applyEventListeners(vnode, renderer);
|
|
3152
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
3153
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
3154
|
+
} // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
3155
|
+
// value is set before type=radio.
|
|
3156
|
+
|
|
3157
|
+
|
|
3158
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
3159
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
3160
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
3161
|
+
patchProps(oldVnode, vnode, renderer);
|
|
2986
3162
|
}
|
|
3163
|
+
|
|
2987
3164
|
function applyStyleScoping(elm, owner, renderer) {
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3165
|
+
// Set the class name for `*.scoped.css` style scoping.
|
|
3166
|
+
const scopeToken = getScopeTokenClass(owner);
|
|
3167
|
+
|
|
3168
|
+
if (!isNull(scopeToken)) {
|
|
3169
|
+
const {
|
|
3170
|
+
getClassList
|
|
3171
|
+
} = renderer; // TODO [#2762]: this dot notation with add is probably problematic
|
|
3172
|
+
// probably we should have a renderer api for just the add operation
|
|
3173
|
+
|
|
3174
|
+
getClassList(elm).add(scopeToken);
|
|
3175
|
+
} // Set property element for synthetic shadow DOM style scoping.
|
|
3176
|
+
|
|
3177
|
+
|
|
3178
|
+
const {
|
|
3179
|
+
stylesheetToken: syntheticToken
|
|
3180
|
+
} = owner.context;
|
|
3181
|
+
|
|
3182
|
+
if (owner.shadowMode === 1
|
|
3183
|
+
/* ShadowMode.Synthetic */
|
|
3184
|
+
&& !isUndefined$1(syntheticToken)) {
|
|
3185
|
+
elm.$shadowToken$ = syntheticToken;
|
|
3186
|
+
}
|
|
3001
3187
|
}
|
|
3188
|
+
|
|
3002
3189
|
function applyDomManual(elm, vnode) {
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3190
|
+
var _a;
|
|
3191
|
+
|
|
3192
|
+
const {
|
|
3193
|
+
owner,
|
|
3194
|
+
data: {
|
|
3195
|
+
context
|
|
3007
3196
|
}
|
|
3197
|
+
} = vnode;
|
|
3198
|
+
|
|
3199
|
+
if (owner.shadowMode === 1
|
|
3200
|
+
/* ShadowMode.Synthetic */
|
|
3201
|
+
&& ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
|
|
3202
|
+
/* LwcDomMode.Manual */
|
|
3203
|
+
) {
|
|
3204
|
+
elm.$domManual$ = true;
|
|
3205
|
+
}
|
|
3008
3206
|
}
|
|
3207
|
+
|
|
3009
3208
|
function allocateChildren(vnode, vm) {
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3209
|
+
// A component with slots will re-render because:
|
|
3210
|
+
// 1- There is a change of the internal state.
|
|
3211
|
+
// 2- There is a change on the external api (ex: slots)
|
|
3212
|
+
//
|
|
3213
|
+
// In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
|
|
3214
|
+
// slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
|
|
3215
|
+
// in a reused VCustomElement, there won't be any slotted children.
|
|
3216
|
+
// For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
|
|
3217
|
+
//
|
|
3218
|
+
// In case #2, we will always get a fresh VCustomElement.
|
|
3219
|
+
const children = vnode.aChildren || vnode.children;
|
|
3220
|
+
vm.aChildren = children;
|
|
3221
|
+
const {
|
|
3222
|
+
renderMode,
|
|
3223
|
+
shadowMode
|
|
3224
|
+
} = vm;
|
|
3225
|
+
|
|
3226
|
+
if (shadowMode === 1
|
|
3227
|
+
/* ShadowMode.Synthetic */
|
|
3228
|
+
|| renderMode === 0
|
|
3229
|
+
/* RenderMode.Light */
|
|
3230
|
+
) {
|
|
3231
|
+
// slow path
|
|
3232
|
+
allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
|
|
3233
|
+
|
|
3234
|
+
vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
3235
|
+
|
|
3236
|
+
vnode.children = EmptyArray;
|
|
3237
|
+
}
|
|
3031
3238
|
}
|
|
3239
|
+
|
|
3032
3240
|
function createViewModelHook(elm, vnode, renderer) {
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
return vm;
|
|
3039
|
-
}
|
|
3040
|
-
const { sel, mode, ctor, owner } = vnode;
|
|
3041
|
-
vm = createVM(elm, ctor, renderer, {
|
|
3042
|
-
mode,
|
|
3043
|
-
owner,
|
|
3044
|
-
tagName: sel,
|
|
3045
|
-
});
|
|
3241
|
+
let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
|
|
3242
|
+
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
3243
|
+
// called right after invoking `document.createElement`.
|
|
3244
|
+
|
|
3245
|
+
if (!isUndefined$1(vm)) {
|
|
3046
3246
|
return vm;
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3247
|
+
}
|
|
3248
|
+
|
|
3249
|
+
const {
|
|
3250
|
+
sel,
|
|
3251
|
+
mode,
|
|
3252
|
+
ctor,
|
|
3253
|
+
owner
|
|
3254
|
+
} = vnode;
|
|
3255
|
+
vm = createVM(elm, ctor, renderer, {
|
|
3256
|
+
mode,
|
|
3257
|
+
owner,
|
|
3258
|
+
tagName: sel
|
|
3259
|
+
});
|
|
3260
|
+
|
|
3261
|
+
return vm;
|
|
3262
|
+
}
|
|
3263
|
+
|
|
3264
|
+
function allocateInSlot(vm, children) {
|
|
3265
|
+
var _a;
|
|
3266
|
+
|
|
3267
|
+
const {
|
|
3268
|
+
cmpSlots: oldSlots
|
|
3269
|
+
} = vm;
|
|
3270
|
+
const cmpSlots = vm.cmpSlots = create(null);
|
|
3271
|
+
|
|
3272
|
+
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
3273
|
+
const vnode = children[i];
|
|
3274
|
+
|
|
3275
|
+
if (isNull(vnode)) {
|
|
3276
|
+
continue;
|
|
3277
|
+
}
|
|
3278
|
+
|
|
3279
|
+
let slotName = '';
|
|
3280
|
+
|
|
3281
|
+
if (isVBaseElement(vnode)) {
|
|
3282
|
+
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
|
|
3286
|
+
ArrayPush$1.call(vnodes, vnode);
|
|
3287
|
+
}
|
|
3288
|
+
|
|
3289
|
+
if (isFalse(vm.isDirty)) {
|
|
3290
|
+
// We need to determine if the old allocation is really different from the new one
|
|
3291
|
+
// and mark the vm as dirty
|
|
3292
|
+
const oldKeys = keys(oldSlots);
|
|
3293
|
+
|
|
3294
|
+
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
3295
|
+
markComponentAsDirty(vm);
|
|
3296
|
+
return;
|
|
3297
|
+
}
|
|
3298
|
+
|
|
3299
|
+
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
3300
|
+
const key = oldKeys[i];
|
|
3301
|
+
|
|
3302
|
+
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
3303
|
+
markComponentAsDirty(vm);
|
|
3304
|
+
return;
|
|
3305
|
+
}
|
|
3306
|
+
|
|
3307
|
+
const oldVNodes = oldSlots[key];
|
|
3308
|
+
const vnodes = cmpSlots[key];
|
|
3309
|
+
|
|
3310
|
+
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
3311
|
+
if (oldVNodes[j] !== vnodes[j]) {
|
|
3312
|
+
markComponentAsDirty(vm);
|
|
3313
|
+
return;
|
|
3086
3314
|
}
|
|
3315
|
+
}
|
|
3087
3316
|
}
|
|
3088
|
-
|
|
3089
|
-
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
3090
|
-
|
|
3091
|
-
|
|
3317
|
+
}
|
|
3318
|
+
} // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
3319
|
+
|
|
3320
|
+
|
|
3321
|
+
const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
|
|
3092
3322
|
// in a template, and will require a more complex diffing algo.
|
|
3323
|
+
|
|
3093
3324
|
function markAsDynamicChildren(children) {
|
|
3094
|
-
|
|
3325
|
+
FromIteration.set(children, 1);
|
|
3095
3326
|
}
|
|
3327
|
+
|
|
3096
3328
|
function hasDynamicChildren(children) {
|
|
3097
|
-
|
|
3329
|
+
return FromIteration.has(children);
|
|
3098
3330
|
}
|
|
3331
|
+
|
|
3099
3332
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3333
|
+
const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
3334
|
+
|
|
3335
|
+
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
3336
|
+
const ch = children[j];
|
|
3337
|
+
|
|
3338
|
+
if (isVNode(ch)) {
|
|
3339
|
+
const {
|
|
3340
|
+
key
|
|
3341
|
+
} = ch;
|
|
3342
|
+
|
|
3343
|
+
if (key !== undefined) {
|
|
3344
|
+
map[key] = j;
|
|
3345
|
+
}
|
|
3110
3346
|
}
|
|
3111
|
-
|
|
3347
|
+
}
|
|
3348
|
+
|
|
3349
|
+
return map;
|
|
3112
3350
|
}
|
|
3351
|
+
|
|
3113
3352
|
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
}
|
|
3193
|
-
// We've already cloned at least once, so it's no longer read-only
|
|
3194
|
-
oldCh[idxInOld] = undefined;
|
|
3195
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
3196
|
-
}
|
|
3197
|
-
}
|
|
3198
|
-
newStartVnode = newCh[++newStartIdx];
|
|
3199
|
-
}
|
|
3353
|
+
let oldStartIdx = 0;
|
|
3354
|
+
let newStartIdx = 0;
|
|
3355
|
+
let oldEndIdx = oldCh.length - 1;
|
|
3356
|
+
let oldStartVnode = oldCh[0];
|
|
3357
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
3358
|
+
const newChEnd = newCh.length - 1;
|
|
3359
|
+
let newEndIdx = newChEnd;
|
|
3360
|
+
let newStartVnode = newCh[0];
|
|
3361
|
+
let newEndVnode = newCh[newEndIdx];
|
|
3362
|
+
let oldKeyToIdx;
|
|
3363
|
+
let idxInOld;
|
|
3364
|
+
let elmToMove;
|
|
3365
|
+
let before;
|
|
3366
|
+
let clonedOldCh = false;
|
|
3367
|
+
|
|
3368
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
3369
|
+
if (!isVNode(oldStartVnode)) {
|
|
3370
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
3371
|
+
} else if (!isVNode(oldEndVnode)) {
|
|
3372
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
3373
|
+
} else if (!isVNode(newStartVnode)) {
|
|
3374
|
+
newStartVnode = newCh[++newStartIdx];
|
|
3375
|
+
} else if (!isVNode(newEndVnode)) {
|
|
3376
|
+
newEndVnode = newCh[--newEndIdx];
|
|
3377
|
+
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
3378
|
+
patch(oldStartVnode, newStartVnode, parent, renderer);
|
|
3379
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
3380
|
+
newStartVnode = newCh[++newStartIdx];
|
|
3381
|
+
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
3382
|
+
patch(oldEndVnode, newEndVnode, parent, renderer);
|
|
3383
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
3384
|
+
newEndVnode = newCh[--newEndIdx];
|
|
3385
|
+
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
3386
|
+
// Vnode moved right
|
|
3387
|
+
patch(oldStartVnode, newEndVnode, parent, renderer);
|
|
3388
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
3389
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
3390
|
+
newEndVnode = newCh[--newEndIdx];
|
|
3391
|
+
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
3392
|
+
// Vnode moved left
|
|
3393
|
+
patch(oldEndVnode, newStartVnode, parent, renderer);
|
|
3394
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
3395
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
3396
|
+
newStartVnode = newCh[++newStartIdx];
|
|
3397
|
+
} else {
|
|
3398
|
+
if (oldKeyToIdx === undefined) {
|
|
3399
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3402
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
3403
|
+
|
|
3404
|
+
if (isUndefined$1(idxInOld)) {
|
|
3405
|
+
// New element
|
|
3406
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3407
|
+
newStartVnode = newCh[++newStartIdx];
|
|
3408
|
+
} else {
|
|
3409
|
+
elmToMove = oldCh[idxInOld];
|
|
3410
|
+
|
|
3411
|
+
if (isVNode(elmToMove)) {
|
|
3412
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
3413
|
+
// New element
|
|
3414
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3415
|
+
} else {
|
|
3416
|
+
patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
|
|
3417
|
+
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
3418
|
+
// so we only care about the `oldCh` object inside this function.
|
|
3419
|
+
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
3420
|
+
// and only clone once.
|
|
3421
|
+
|
|
3422
|
+
if (!clonedOldCh) {
|
|
3423
|
+
clonedOldCh = true;
|
|
3424
|
+
oldCh = [...oldCh];
|
|
3425
|
+
} // We've already cloned at least once, so it's no longer read-only
|
|
3426
|
+
|
|
3427
|
+
|
|
3428
|
+
oldCh[idxInOld] = undefined;
|
|
3429
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
3430
|
+
}
|
|
3200
3431
|
}
|
|
3432
|
+
|
|
3433
|
+
newStartVnode = newCh[++newStartIdx];
|
|
3434
|
+
}
|
|
3201
3435
|
}
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3436
|
+
}
|
|
3437
|
+
|
|
3438
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
3439
|
+
if (oldStartIdx > oldEndIdx) {
|
|
3440
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
3441
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
3442
|
+
let i = newEndIdx;
|
|
3443
|
+
let n;
|
|
3444
|
+
|
|
3445
|
+
do {
|
|
3446
|
+
n = newCh[++i];
|
|
3447
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
3448
|
+
|
|
3449
|
+
before = isVNode(n) ? n.elm : null;
|
|
3450
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
3451
|
+
} else {
|
|
3452
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
3217
3453
|
}
|
|
3454
|
+
}
|
|
3218
3455
|
}
|
|
3456
|
+
|
|
3219
3457
|
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
anchor = n2.elm;
|
|
3254
|
-
}
|
|
3458
|
+
const c1Length = c1.length;
|
|
3459
|
+
const c2Length = c2.length;
|
|
3460
|
+
|
|
3461
|
+
if (c1Length === 0) {
|
|
3462
|
+
// the old list is empty, we can directly insert anything new
|
|
3463
|
+
mountVNodes(c2, parent, renderer, null);
|
|
3464
|
+
return;
|
|
3465
|
+
}
|
|
3466
|
+
|
|
3467
|
+
if (c2Length === 0) {
|
|
3468
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
3469
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
3470
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
3471
|
+
return;
|
|
3472
|
+
} // if the old list is not empty, the new list MUST have the same
|
|
3473
|
+
// amount of nodes, that's why we call this static children
|
|
3474
|
+
|
|
3475
|
+
|
|
3476
|
+
let anchor = null;
|
|
3477
|
+
|
|
3478
|
+
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
3479
|
+
const n1 = c1[i];
|
|
3480
|
+
const n2 = c2[i];
|
|
3481
|
+
|
|
3482
|
+
if (n2 !== n1) {
|
|
3483
|
+
if (isVNode(n1)) {
|
|
3484
|
+
if (isVNode(n2)) {
|
|
3485
|
+
// both vnodes are equivalent, and we just need to patch them
|
|
3486
|
+
patch(n1, n2, parent, renderer);
|
|
3487
|
+
anchor = n2.elm;
|
|
3488
|
+
} else {
|
|
3489
|
+
// removing the old vnode since the new one is null
|
|
3490
|
+
unmount(n1, parent, renderer, true);
|
|
3255
3491
|
}
|
|
3492
|
+
} else if (isVNode(n2)) {
|
|
3493
|
+
mount(n2, parent, renderer, anchor);
|
|
3494
|
+
anchor = n2.elm;
|
|
3495
|
+
}
|
|
3256
3496
|
}
|
|
3497
|
+
}
|
|
3257
3498
|
}
|
|
3258
3499
|
|
|
3259
3500
|
/*
|
|
@@ -3469,13 +3710,6 @@ var LWC = (function (exports) {
|
|
|
3469
3710
|
}
|
|
3470
3711
|
return url;
|
|
3471
3712
|
}
|
|
3472
|
-
/**
|
|
3473
|
-
* Map to store an index value assigned to any dynamic component reference ingested
|
|
3474
|
-
* by dc() api. This allows us to generate a unique unique per template per dynamic
|
|
3475
|
-
* component reference to avoid diffing algo mismatches.
|
|
3476
|
-
*/
|
|
3477
|
-
const DynamicImportedComponentMap = new Map();
|
|
3478
|
-
let dynamicImportedComponentCounter = 0;
|
|
3479
3713
|
/**
|
|
3480
3714
|
* create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
3481
3715
|
*/
|
|
@@ -3487,18 +3721,7 @@ var LWC = (function (exports) {
|
|
|
3487
3721
|
if (!isComponentConstructor(Ctor)) {
|
|
3488
3722
|
throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
|
|
3489
3723
|
}
|
|
3490
|
-
|
|
3491
|
-
if (isUndefined$1(idx)) {
|
|
3492
|
-
idx = dynamicImportedComponentCounter++;
|
|
3493
|
-
DynamicImportedComponentMap.set(Ctor, idx);
|
|
3494
|
-
}
|
|
3495
|
-
// the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
|
|
3496
|
-
// to identify different constructors as vnodes with different keys to avoid reusing the
|
|
3497
|
-
// element used for previous constructors.
|
|
3498
|
-
// Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
|
|
3499
|
-
// hoisting optimization.
|
|
3500
|
-
const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
|
|
3501
|
-
return c(sel, Ctor, newData, children);
|
|
3724
|
+
return c(sel, Ctor, data, children);
|
|
3502
3725
|
}
|
|
3503
3726
|
/**
|
|
3504
3727
|
* slow children collection marking mechanism. this API allows the compiler to signal
|
|
@@ -4105,7 +4328,7 @@ var LWC = (function (exports) {
|
|
|
4105
4328
|
} else if (isNativeShadowDefined) {
|
|
4106
4329
|
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
4107
4330
|
// the if-condition.
|
|
4108
|
-
if (
|
|
4331
|
+
if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
4109
4332
|
if (def.shadowSupportMode === "any"
|
|
4110
4333
|
/* ShadowSupportMode.Any */
|
|
4111
4334
|
) {
|
|
@@ -4218,16 +4441,9 @@ var LWC = (function (exports) {
|
|
|
4218
4441
|
const {
|
|
4219
4442
|
def: {
|
|
4220
4443
|
renderedCallback
|
|
4221
|
-
},
|
|
4222
|
-
renderer: {
|
|
4223
|
-
ssr
|
|
4224
4444
|
}
|
|
4225
4445
|
} = vm;
|
|
4226
4446
|
|
|
4227
|
-
if (isTrue(ssr)) {
|
|
4228
|
-
return;
|
|
4229
|
-
}
|
|
4230
|
-
|
|
4231
4447
|
const {
|
|
4232
4448
|
rendered
|
|
4233
4449
|
} = Services;
|
|
@@ -4468,13 +4684,7 @@ var LWC = (function (exports) {
|
|
|
4468
4684
|
vm.velements = EmptyArray;
|
|
4469
4685
|
}
|
|
4470
4686
|
function scheduleRehydration(vm) {
|
|
4471
|
-
|
|
4472
|
-
renderer: {
|
|
4473
|
-
ssr
|
|
4474
|
-
}
|
|
4475
|
-
} = vm;
|
|
4476
|
-
|
|
4477
|
-
if (isTrue(ssr) || isTrue(vm.isScheduled)) {
|
|
4687
|
+
if (isTrue(vm.isScheduled)) {
|
|
4478
4688
|
return;
|
|
4479
4689
|
}
|
|
4480
4690
|
|
|
@@ -4564,15 +4774,8 @@ var LWC = (function (exports) {
|
|
|
4564
4774
|
}
|
|
4565
4775
|
|
|
4566
4776
|
function createFieldDataCallback(vm, name) {
|
|
4567
|
-
const {
|
|
4568
|
-
cmpFields
|
|
4569
|
-
} = vm;
|
|
4570
4777
|
return value => {
|
|
4571
|
-
|
|
4572
|
-
// storing the value in the underlying storage
|
|
4573
|
-
cmpFields[name] = value;
|
|
4574
|
-
componentValueMutated(vm, name);
|
|
4575
|
-
}
|
|
4778
|
+
updateComponentValue(vm, name, value);
|
|
4576
4779
|
};
|
|
4577
4780
|
}
|
|
4578
4781
|
|
|
@@ -4786,7 +4989,7 @@ var LWC = (function (exports) {
|
|
|
4786
4989
|
ArrayPush$1.call(wiredConnecting, () => {
|
|
4787
4990
|
connector.connect();
|
|
4788
4991
|
|
|
4789
|
-
if (!
|
|
4992
|
+
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
4790
4993
|
if (hasDynamicParams) {
|
|
4791
4994
|
Promise.resolve().then(computeConfigAndUpdate);
|
|
4792
4995
|
return;
|
|
@@ -4926,6 +5129,7 @@ var LWC = (function (exports) {
|
|
|
4926
5129
|
}
|
|
4927
5130
|
return renderer.nextSibling(hydratedNode);
|
|
4928
5131
|
}
|
|
5132
|
+
const NODE_VALUE_PROP = 'nodeValue';
|
|
4929
5133
|
function hydrateText(node, vnode, renderer) {
|
|
4930
5134
|
var _a;
|
|
4931
5135
|
if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
@@ -4942,7 +5146,7 @@ var LWC = (function (exports) {
|
|
|
4942
5146
|
return handleMismatch(node, vnode, renderer);
|
|
4943
5147
|
}
|
|
4944
5148
|
const { setProperty } = renderer;
|
|
4945
|
-
setProperty(node,
|
|
5149
|
+
setProperty(node, NODE_VALUE_PROP, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
4946
5150
|
vnode.elm = node;
|
|
4947
5151
|
return node;
|
|
4948
5152
|
}
|
|
@@ -5163,13 +5367,13 @@ var LWC = (function (exports) {
|
|
|
5163
5367
|
if (!hasCorrectNodeType(vnode, ssr, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
5164
5368
|
return false;
|
|
5165
5369
|
}
|
|
5166
|
-
return getProperty(client,
|
|
5370
|
+
return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
|
|
5167
5371
|
}
|
|
5168
5372
|
if (getProperty(client, 'nodeType') === 8 /* EnvNodeTypes.COMMENT */) {
|
|
5169
5373
|
if (!hasCorrectNodeType(vnode, ssr, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
|
|
5170
5374
|
return false;
|
|
5171
5375
|
}
|
|
5172
|
-
return getProperty(client,
|
|
5376
|
+
return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
|
|
5173
5377
|
}
|
|
5174
5378
|
if (!hasCorrectNodeType(vnode, ssr, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
|
|
5175
5379
|
return false;
|
|
@@ -5227,7 +5431,7 @@ var LWC = (function (exports) {
|
|
|
5227
5431
|
}
|
|
5228
5432
|
return ctor;
|
|
5229
5433
|
}
|
|
5230
|
-
/* version: 2.
|
|
5434
|
+
/* version: 2.23.2 */
|
|
5231
5435
|
|
|
5232
5436
|
/*
|
|
5233
5437
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5368,61 +5572,303 @@ var LWC = (function (exports) {
|
|
|
5368
5572
|
* SPDX-License-Identifier: MIT
|
|
5369
5573
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5370
5574
|
*/
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
//
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
html = `<${wrapperTag}>${html}</${wrapperTag}>`;
|
|
5575
|
+
/**
|
|
5576
|
+
* A factory function that produces a renderer.
|
|
5577
|
+
* Renderer encapsulates operations that are required to render an LWC component into the underlying
|
|
5578
|
+
* runtime environment. In the case of @lwc/enigne-dom, it is meant to be used in a DOM environment.
|
|
5579
|
+
* Example usage:
|
|
5580
|
+
* import { renderer, rendererFactory } from 'lwc';
|
|
5581
|
+
* const customRenderer = rendererFactory(renderer);
|
|
5582
|
+
*
|
|
5583
|
+
* @param baseRenderer Either null or the base renderer imported from 'lwc'.
|
|
5584
|
+
*/
|
|
5585
|
+
function rendererFactory(baseRenderer) {
|
|
5586
|
+
// Util functions
|
|
5587
|
+
function assertInvariant(value, msg) {
|
|
5588
|
+
if (!value) {
|
|
5589
|
+
throw new Error(`Invariant Violation: ${msg}`);
|
|
5590
|
+
}
|
|
5591
|
+
}
|
|
5592
|
+
function isNull(obj) {
|
|
5593
|
+
return obj === null;
|
|
5594
|
+
}
|
|
5595
|
+
function isUndefined(obj) {
|
|
5596
|
+
return obj === undefined;
|
|
5597
|
+
}
|
|
5598
|
+
let getCustomElement;
|
|
5599
|
+
let defineCustomElement;
|
|
5600
|
+
let HTMLElementConstructor;
|
|
5601
|
+
function isCustomElementRegistryAvailable() {
|
|
5602
|
+
if (typeof customElements === 'undefined') {
|
|
5603
|
+
return false;
|
|
5604
|
+
}
|
|
5605
|
+
try {
|
|
5606
|
+
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
5607
|
+
// _wrapNativeSuper()
|
|
5608
|
+
// This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
|
|
5609
|
+
// get wrapped by babel.
|
|
5610
|
+
const HTMLElementAlias = HTMLElement;
|
|
5611
|
+
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
5612
|
+
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
5613
|
+
// which are not equipped to be initialized that way.
|
|
5614
|
+
class clazz extends HTMLElementAlias {
|
|
5412
5615
|
}
|
|
5616
|
+
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
5617
|
+
new clazz();
|
|
5618
|
+
return true;
|
|
5413
5619
|
}
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5620
|
+
catch (_a) {
|
|
5621
|
+
return false;
|
|
5622
|
+
}
|
|
5623
|
+
}
|
|
5624
|
+
if (isCustomElementRegistryAvailable()) {
|
|
5625
|
+
getCustomElement = customElements.get.bind(customElements);
|
|
5626
|
+
defineCustomElement = customElements.define.bind(customElements);
|
|
5627
|
+
HTMLElementConstructor = HTMLElement;
|
|
5628
|
+
}
|
|
5629
|
+
else {
|
|
5630
|
+
const registry = Object.create(null);
|
|
5631
|
+
const reverseRegistry = new WeakMap();
|
|
5632
|
+
defineCustomElement = function define(name, ctor) {
|
|
5633
|
+
if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
|
|
5634
|
+
throw new TypeError(`Invalid Registration`);
|
|
5635
|
+
}
|
|
5636
|
+
registry[name] = ctor;
|
|
5637
|
+
reverseRegistry.set(ctor, name);
|
|
5638
|
+
};
|
|
5639
|
+
getCustomElement = function get(name) {
|
|
5640
|
+
return registry[name];
|
|
5641
|
+
};
|
|
5642
|
+
HTMLElementConstructor = function HTMLElement() {
|
|
5643
|
+
if (!(this instanceof HTMLElement)) {
|
|
5644
|
+
throw new TypeError(`Invalid Invocation`);
|
|
5645
|
+
}
|
|
5646
|
+
const { constructor } = this;
|
|
5647
|
+
const name = reverseRegistry.get(constructor);
|
|
5648
|
+
if (!name) {
|
|
5649
|
+
throw new TypeError(`Invalid Construction`);
|
|
5650
|
+
}
|
|
5651
|
+
const elm = document.createElement(name);
|
|
5652
|
+
Object.setPrototypeOf(elm, constructor.prototype);
|
|
5653
|
+
return elm;
|
|
5654
|
+
};
|
|
5655
|
+
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
5656
|
+
}
|
|
5657
|
+
function cloneNode(node, deep) {
|
|
5658
|
+
return node.cloneNode(deep);
|
|
5659
|
+
}
|
|
5660
|
+
function createElement(tagName, namespace) {
|
|
5661
|
+
return isUndefined(namespace)
|
|
5662
|
+
? document.createElement(tagName)
|
|
5663
|
+
: document.createElementNS(namespace, tagName);
|
|
5664
|
+
}
|
|
5665
|
+
function createText(content) {
|
|
5666
|
+
return document.createTextNode(content);
|
|
5667
|
+
}
|
|
5668
|
+
function createComment(content) {
|
|
5669
|
+
return document.createComment(content);
|
|
5670
|
+
}
|
|
5671
|
+
let createFragment;
|
|
5672
|
+
// IE11 lacks support for this feature
|
|
5673
|
+
const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
|
|
5674
|
+
if (SUPPORTS_TEMPLATE) {
|
|
5675
|
+
// Parse the fragment HTML string into DOM
|
|
5676
|
+
createFragment = function (html) {
|
|
5677
|
+
const template = document.createElement('template');
|
|
5678
|
+
template.innerHTML = html;
|
|
5679
|
+
return template.content.firstChild;
|
|
5680
|
+
};
|
|
5681
|
+
}
|
|
5682
|
+
else {
|
|
5683
|
+
// In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
|
|
5684
|
+
// <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
|
|
5685
|
+
// Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
|
|
5686
|
+
// With other elements added from:
|
|
5687
|
+
// https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
|
|
5688
|
+
// Using the test:
|
|
5689
|
+
// document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
|
|
5690
|
+
// And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
|
|
5691
|
+
const topLevelWrappingMap = {
|
|
5692
|
+
caption: ['table'],
|
|
5693
|
+
col: ['colgroup', 'table'],
|
|
5694
|
+
colgroup: ['table'],
|
|
5695
|
+
option: ['select'],
|
|
5696
|
+
tbody: ['table'],
|
|
5697
|
+
td: ['tr', 'tbody', 'table'],
|
|
5698
|
+
th: ['tr', 'tbody', 'table'],
|
|
5699
|
+
thead: ['table'],
|
|
5700
|
+
tfoot: ['table'],
|
|
5701
|
+
tr: ['tbody', 'table'],
|
|
5702
|
+
};
|
|
5703
|
+
// Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
|
|
5704
|
+
const getTagName = function (text) {
|
|
5705
|
+
return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
|
|
5706
|
+
};
|
|
5707
|
+
// Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
|
|
5708
|
+
createFragment = function (html) {
|
|
5709
|
+
const wrapperTags = topLevelWrappingMap[getTagName(html)];
|
|
5710
|
+
if (!isUndefined(wrapperTags)) {
|
|
5711
|
+
for (const wrapperTag of wrapperTags) {
|
|
5712
|
+
html = `<${wrapperTag}>${html}</${wrapperTag}>`;
|
|
5713
|
+
}
|
|
5422
5714
|
}
|
|
5715
|
+
// For IE11, the document title must not be undefined, but it can be an empty string
|
|
5716
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
|
|
5717
|
+
const doc = document.implementation.createHTMLDocument('');
|
|
5718
|
+
doc.body.innerHTML = html;
|
|
5719
|
+
let content = doc.body;
|
|
5720
|
+
if (!isUndefined(wrapperTags)) {
|
|
5721
|
+
for (let i = 0; i < wrapperTags.length; i++) {
|
|
5722
|
+
content = content.firstChild;
|
|
5723
|
+
}
|
|
5724
|
+
}
|
|
5725
|
+
return content.firstChild;
|
|
5726
|
+
};
|
|
5727
|
+
}
|
|
5728
|
+
function insert(node, parent, anchor) {
|
|
5729
|
+
parent.insertBefore(node, anchor);
|
|
5730
|
+
}
|
|
5731
|
+
function remove(node, parent) {
|
|
5732
|
+
parent.removeChild(node);
|
|
5733
|
+
}
|
|
5734
|
+
function nextSibling(node) {
|
|
5735
|
+
return node.nextSibling;
|
|
5736
|
+
}
|
|
5737
|
+
function attachShadow(element, options) {
|
|
5738
|
+
// `shadowRoot` will be non-null in two cases:
|
|
5739
|
+
// 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
|
|
5740
|
+
// 2. when a webapp author places <c-app> in their static HTML and mounts their
|
|
5741
|
+
// root component with customElement.define('c-app', Ctor)
|
|
5742
|
+
if (!isNull(element.shadowRoot)) {
|
|
5743
|
+
return element.shadowRoot;
|
|
5744
|
+
}
|
|
5745
|
+
return element.attachShadow(options);
|
|
5746
|
+
}
|
|
5747
|
+
function setText(node, content) {
|
|
5748
|
+
node.nodeValue = content;
|
|
5749
|
+
}
|
|
5750
|
+
function getProperty(node, key) {
|
|
5751
|
+
return node[key];
|
|
5752
|
+
}
|
|
5753
|
+
function setProperty(node, key, value) {
|
|
5754
|
+
node[key] = value;
|
|
5755
|
+
}
|
|
5756
|
+
function getAttribute(element, name, namespace) {
|
|
5757
|
+
return isUndefined(namespace)
|
|
5758
|
+
? element.getAttribute(name)
|
|
5759
|
+
: element.getAttributeNS(namespace, name);
|
|
5760
|
+
}
|
|
5761
|
+
function setAttribute(element, name, value, namespace) {
|
|
5762
|
+
return isUndefined(namespace)
|
|
5763
|
+
? element.setAttribute(name, value)
|
|
5764
|
+
: element.setAttributeNS(namespace, name, value);
|
|
5765
|
+
}
|
|
5766
|
+
function removeAttribute(element, name, namespace) {
|
|
5767
|
+
if (isUndefined(namespace)) {
|
|
5768
|
+
element.removeAttribute(name);
|
|
5423
5769
|
}
|
|
5424
|
-
|
|
5770
|
+
else {
|
|
5771
|
+
element.removeAttributeNS(namespace, name);
|
|
5772
|
+
}
|
|
5773
|
+
}
|
|
5774
|
+
function addEventListener(target, type, callback, options) {
|
|
5775
|
+
target.addEventListener(type, callback, options);
|
|
5776
|
+
}
|
|
5777
|
+
function removeEventListener(target, type, callback, options) {
|
|
5778
|
+
target.removeEventListener(type, callback, options);
|
|
5779
|
+
}
|
|
5780
|
+
function dispatchEvent(target, event) {
|
|
5781
|
+
return target.dispatchEvent(event);
|
|
5782
|
+
}
|
|
5783
|
+
function getClassList(element) {
|
|
5784
|
+
return element.classList;
|
|
5785
|
+
}
|
|
5786
|
+
function setCSSStyleProperty(element, name, value, important) {
|
|
5787
|
+
// TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
|
|
5788
|
+
// represent elements in the engine?
|
|
5789
|
+
element.style.setProperty(name, value, important ? 'important' : '');
|
|
5790
|
+
}
|
|
5791
|
+
function getBoundingClientRect(element) {
|
|
5792
|
+
return element.getBoundingClientRect();
|
|
5793
|
+
}
|
|
5794
|
+
function querySelector(element, selectors) {
|
|
5795
|
+
return element.querySelector(selectors);
|
|
5796
|
+
}
|
|
5797
|
+
function querySelectorAll(element, selectors) {
|
|
5798
|
+
return element.querySelectorAll(selectors);
|
|
5799
|
+
}
|
|
5800
|
+
function getElementsByTagName(element, tagNameOrWildCard) {
|
|
5801
|
+
return element.getElementsByTagName(tagNameOrWildCard);
|
|
5802
|
+
}
|
|
5803
|
+
function getElementsByClassName(element, names) {
|
|
5804
|
+
return element.getElementsByClassName(names);
|
|
5805
|
+
}
|
|
5806
|
+
function getChildren(element) {
|
|
5807
|
+
return element.children;
|
|
5808
|
+
}
|
|
5809
|
+
function getChildNodes(element) {
|
|
5810
|
+
return element.childNodes;
|
|
5811
|
+
}
|
|
5812
|
+
function getFirstChild(element) {
|
|
5813
|
+
return element.firstChild;
|
|
5814
|
+
}
|
|
5815
|
+
function getFirstElementChild(element) {
|
|
5816
|
+
return element.firstElementChild;
|
|
5817
|
+
}
|
|
5818
|
+
function getLastChild(element) {
|
|
5819
|
+
return element.lastChild;
|
|
5820
|
+
}
|
|
5821
|
+
function getLastElementChild(element) {
|
|
5822
|
+
return element.lastElementChild;
|
|
5823
|
+
}
|
|
5824
|
+
function isConnected(node) {
|
|
5825
|
+
return node.isConnected;
|
|
5826
|
+
}
|
|
5827
|
+
function assertInstanceOfHTMLElement(elm, msg) {
|
|
5828
|
+
assertInvariant(elm instanceof HTMLElement, msg);
|
|
5829
|
+
}
|
|
5830
|
+
const HTMLElementExported = HTMLElementConstructor;
|
|
5831
|
+
const renderer = {
|
|
5832
|
+
HTMLElementExported,
|
|
5833
|
+
insert,
|
|
5834
|
+
remove,
|
|
5835
|
+
cloneNode,
|
|
5836
|
+
createFragment,
|
|
5837
|
+
createElement,
|
|
5838
|
+
createText,
|
|
5839
|
+
createComment,
|
|
5840
|
+
nextSibling,
|
|
5841
|
+
attachShadow,
|
|
5842
|
+
getProperty,
|
|
5843
|
+
setProperty,
|
|
5844
|
+
setText,
|
|
5845
|
+
getAttribute,
|
|
5846
|
+
setAttribute,
|
|
5847
|
+
removeAttribute,
|
|
5848
|
+
addEventListener,
|
|
5849
|
+
removeEventListener,
|
|
5850
|
+
dispatchEvent,
|
|
5851
|
+
getClassList,
|
|
5852
|
+
setCSSStyleProperty,
|
|
5853
|
+
getBoundingClientRect,
|
|
5854
|
+
querySelector,
|
|
5855
|
+
querySelectorAll,
|
|
5856
|
+
getElementsByTagName,
|
|
5857
|
+
getElementsByClassName,
|
|
5858
|
+
getChildren,
|
|
5859
|
+
getChildNodes,
|
|
5860
|
+
getFirstChild,
|
|
5861
|
+
getFirstElementChild,
|
|
5862
|
+
getLastChild,
|
|
5863
|
+
getLastElementChild,
|
|
5864
|
+
isConnected,
|
|
5865
|
+
assertInstanceOfHTMLElement,
|
|
5866
|
+
defineCustomElement,
|
|
5867
|
+
getCustomElement,
|
|
5425
5868
|
};
|
|
5869
|
+
// Meant to inherit any properties passed via the base renderer as the argument to the factory.
|
|
5870
|
+
Object.setPrototypeOf(renderer, baseRenderer);
|
|
5871
|
+
return renderer;
|
|
5426
5872
|
}
|
|
5427
5873
|
|
|
5428
5874
|
/*
|
|
@@ -5431,239 +5877,21 @@ var LWC = (function (exports) {
|
|
|
5431
5877
|
* SPDX-License-Identifier: MIT
|
|
5432
5878
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5433
5879
|
*/
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
// get wrapped by babel.
|
|
5446
|
-
const HTMLElementAlias = HTMLElement;
|
|
5447
|
-
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
5448
|
-
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
5449
|
-
// which are not equipped to be initialized that way.
|
|
5450
|
-
class clazz extends HTMLElementAlias {
|
|
5451
|
-
}
|
|
5452
|
-
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
5453
|
-
new clazz();
|
|
5454
|
-
return true;
|
|
5455
|
-
}
|
|
5456
|
-
catch (_a) {
|
|
5457
|
-
return false;
|
|
5458
|
-
}
|
|
5459
|
-
}
|
|
5460
|
-
if (isCustomElementRegistryAvailable()) {
|
|
5461
|
-
getCustomElement = customElements.get.bind(customElements);
|
|
5462
|
-
defineCustomElement = customElements.define.bind(customElements);
|
|
5463
|
-
HTMLElementConstructor = HTMLElement;
|
|
5464
|
-
}
|
|
5465
|
-
else {
|
|
5466
|
-
const registry = create(null);
|
|
5467
|
-
const reverseRegistry = new WeakMap();
|
|
5468
|
-
defineCustomElement = function define(name, ctor) {
|
|
5469
|
-
if (name !== StringToLowerCase.call(name) || registry[name]) {
|
|
5470
|
-
throw new TypeError(`Invalid Registration`);
|
|
5471
|
-
}
|
|
5472
|
-
registry[name] = ctor;
|
|
5473
|
-
reverseRegistry.set(ctor, name);
|
|
5474
|
-
};
|
|
5475
|
-
getCustomElement = function get(name) {
|
|
5476
|
-
return registry[name];
|
|
5477
|
-
};
|
|
5478
|
-
HTMLElementConstructor = function HTMLElement() {
|
|
5479
|
-
if (!(this instanceof HTMLElement)) {
|
|
5480
|
-
throw new TypeError(`Invalid Invocation`);
|
|
5481
|
-
}
|
|
5482
|
-
const { constructor } = this;
|
|
5483
|
-
const name = reverseRegistry.get(constructor);
|
|
5484
|
-
if (!name) {
|
|
5485
|
-
throw new TypeError(`Invalid Construction`);
|
|
5486
|
-
}
|
|
5487
|
-
const elm = document.createElement(name);
|
|
5488
|
-
setPrototypeOf(elm, constructor.prototype);
|
|
5489
|
-
return elm;
|
|
5490
|
-
};
|
|
5491
|
-
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
5492
|
-
}
|
|
5493
|
-
let hydrating = false;
|
|
5494
|
-
function setIsHydrating(value) {
|
|
5495
|
-
hydrating = value;
|
|
5496
|
-
}
|
|
5497
|
-
const ssr = false;
|
|
5498
|
-
function isHydrating() {
|
|
5499
|
-
return hydrating;
|
|
5500
|
-
}
|
|
5501
|
-
const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
|
|
5502
|
-
const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
|
|
5503
|
-
function cloneNode(node, deep) {
|
|
5504
|
-
return node.cloneNode(deep);
|
|
5505
|
-
}
|
|
5506
|
-
function createElement$1(tagName, namespace) {
|
|
5507
|
-
return isUndefined$1(namespace)
|
|
5508
|
-
? document.createElement(tagName)
|
|
5509
|
-
: document.createElementNS(namespace, tagName);
|
|
5510
|
-
}
|
|
5511
|
-
function createText(content) {
|
|
5512
|
-
return document.createTextNode(content);
|
|
5513
|
-
}
|
|
5514
|
-
function createComment(content) {
|
|
5515
|
-
return document.createComment(content);
|
|
5516
|
-
}
|
|
5517
|
-
function insert(node, parent, anchor) {
|
|
5518
|
-
parent.insertBefore(node, anchor);
|
|
5519
|
-
}
|
|
5520
|
-
function remove(node, parent) {
|
|
5521
|
-
parent.removeChild(node);
|
|
5522
|
-
}
|
|
5523
|
-
function nextSibling(node) {
|
|
5524
|
-
return node.nextSibling;
|
|
5525
|
-
}
|
|
5526
|
-
function attachShadow(element, options) {
|
|
5527
|
-
// `hydrating` will be true in two cases:
|
|
5528
|
-
// 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
|
|
5529
|
-
// 2. when a webapp author places <c-app> in their static HTML and mounts their
|
|
5530
|
-
// root component with customeElement.define('c-app', Ctor)
|
|
5531
|
-
//
|
|
5532
|
-
// The second case can be treated as a failed hydration with nominal impact
|
|
5533
|
-
// to performance. However, because <c-app> won't have a <template shadowroot>
|
|
5534
|
-
// declarative child, `element.shadowRoot` is `null`.
|
|
5535
|
-
if (hydrating && element.shadowRoot) {
|
|
5536
|
-
return element.shadowRoot;
|
|
5537
|
-
}
|
|
5538
|
-
return element.attachShadow(options);
|
|
5539
|
-
}
|
|
5540
|
-
function setText(node, content) {
|
|
5541
|
-
node.nodeValue = content;
|
|
5542
|
-
}
|
|
5543
|
-
function getProperty(node, key) {
|
|
5544
|
-
return node[key];
|
|
5545
|
-
}
|
|
5546
|
-
function setProperty(node, key, value) {
|
|
5547
|
-
node[key] = value;
|
|
5548
|
-
}
|
|
5549
|
-
function getAttribute(element, name, namespace) {
|
|
5550
|
-
return isUndefined$1(namespace)
|
|
5551
|
-
? element.getAttribute(name)
|
|
5552
|
-
: element.getAttributeNS(namespace, name);
|
|
5553
|
-
}
|
|
5554
|
-
function setAttribute(element, name, value, namespace) {
|
|
5555
|
-
return isUndefined$1(namespace)
|
|
5556
|
-
? element.setAttribute(name, value)
|
|
5557
|
-
: element.setAttributeNS(namespace, name, value);
|
|
5558
|
-
}
|
|
5559
|
-
function removeAttribute(element, name, namespace) {
|
|
5560
|
-
if (isUndefined$1(namespace)) {
|
|
5561
|
-
element.removeAttribute(name);
|
|
5562
|
-
}
|
|
5563
|
-
else {
|
|
5564
|
-
element.removeAttributeNS(namespace, name);
|
|
5565
|
-
}
|
|
5566
|
-
}
|
|
5567
|
-
function addEventListener(target, type, callback, options) {
|
|
5568
|
-
target.addEventListener(type, callback, options);
|
|
5569
|
-
}
|
|
5570
|
-
function removeEventListener(target, type, callback, options) {
|
|
5571
|
-
target.removeEventListener(type, callback, options);
|
|
5572
|
-
}
|
|
5573
|
-
function dispatchEvent(target, event) {
|
|
5574
|
-
return target.dispatchEvent(event);
|
|
5575
|
-
}
|
|
5576
|
-
function getClassList(element) {
|
|
5577
|
-
return element.classList;
|
|
5578
|
-
}
|
|
5579
|
-
function setCSSStyleProperty(element, name, value, important) {
|
|
5580
|
-
// TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
|
|
5581
|
-
// represent elements in the engine?
|
|
5582
|
-
element.style.setProperty(name, value, important ? 'important' : '');
|
|
5583
|
-
}
|
|
5584
|
-
function getBoundingClientRect(element) {
|
|
5585
|
-
return element.getBoundingClientRect();
|
|
5586
|
-
}
|
|
5587
|
-
function querySelector(element, selectors) {
|
|
5588
|
-
return element.querySelector(selectors);
|
|
5589
|
-
}
|
|
5590
|
-
function querySelectorAll(element, selectors) {
|
|
5591
|
-
return element.querySelectorAll(selectors);
|
|
5592
|
-
}
|
|
5593
|
-
function getElementsByTagName(element, tagNameOrWildCard) {
|
|
5594
|
-
return element.getElementsByTagName(tagNameOrWildCard);
|
|
5595
|
-
}
|
|
5596
|
-
function getElementsByClassName(element, names) {
|
|
5597
|
-
return element.getElementsByClassName(names);
|
|
5598
|
-
}
|
|
5599
|
-
function getChildren(element) {
|
|
5600
|
-
return element.children;
|
|
5601
|
-
}
|
|
5602
|
-
function getChildNodes(element) {
|
|
5603
|
-
return element.childNodes;
|
|
5604
|
-
}
|
|
5605
|
-
function getFirstChild(element) {
|
|
5606
|
-
return element.firstChild;
|
|
5607
|
-
}
|
|
5608
|
-
function getFirstElementChild(element) {
|
|
5609
|
-
return element.firstElementChild;
|
|
5610
|
-
}
|
|
5611
|
-
function getLastChild(element) {
|
|
5612
|
-
return element.lastChild;
|
|
5613
|
-
}
|
|
5614
|
-
function getLastElementChild(element) {
|
|
5615
|
-
return element.lastElementChild;
|
|
5616
|
-
}
|
|
5617
|
-
function isConnected(node) {
|
|
5618
|
-
return node.isConnected;
|
|
5619
|
-
}
|
|
5620
|
-
function assertInstanceOfHTMLElement(elm, msg) {
|
|
5621
|
-
assert.invariant(elm instanceof HTMLElement, msg);
|
|
5622
|
-
}
|
|
5623
|
-
const HTMLElementExported = HTMLElementConstructor;
|
|
5624
|
-
const renderer = {
|
|
5625
|
-
ssr,
|
|
5626
|
-
isNativeShadowDefined,
|
|
5627
|
-
isSyntheticShadowDefined,
|
|
5628
|
-
HTMLElementExported,
|
|
5629
|
-
isHydrating,
|
|
5630
|
-
insert,
|
|
5631
|
-
remove,
|
|
5632
|
-
cloneNode,
|
|
5633
|
-
createFragment,
|
|
5634
|
-
createElement: createElement$1,
|
|
5635
|
-
createText,
|
|
5636
|
-
createComment,
|
|
5637
|
-
nextSibling,
|
|
5638
|
-
attachShadow,
|
|
5639
|
-
getProperty,
|
|
5640
|
-
setProperty,
|
|
5641
|
-
setText,
|
|
5642
|
-
getAttribute,
|
|
5643
|
-
setAttribute,
|
|
5644
|
-
removeAttribute,
|
|
5645
|
-
addEventListener,
|
|
5646
|
-
removeEventListener,
|
|
5647
|
-
dispatchEvent,
|
|
5648
|
-
getClassList,
|
|
5649
|
-
setCSSStyleProperty,
|
|
5650
|
-
getBoundingClientRect,
|
|
5651
|
-
querySelector,
|
|
5652
|
-
querySelectorAll,
|
|
5653
|
-
getElementsByTagName,
|
|
5654
|
-
getElementsByClassName,
|
|
5655
|
-
getChildren,
|
|
5656
|
-
getChildNodes,
|
|
5657
|
-
getFirstChild,
|
|
5658
|
-
getFirstElementChild,
|
|
5659
|
-
getLastChild,
|
|
5660
|
-
getLastElementChild,
|
|
5661
|
-
isConnected,
|
|
5880
|
+
/**
|
|
5881
|
+
* The base renderer that will be used by engine-core.
|
|
5882
|
+
* This will be used for DOM operations when lwc is running in a browser environment.
|
|
5883
|
+
*/
|
|
5884
|
+
const renderer = assign(
|
|
5885
|
+
// The base renderer will invoke the factory with null and assign additional properties that are
|
|
5886
|
+
// shared across renderers
|
|
5887
|
+
rendererFactory(null),
|
|
5888
|
+
// Properties that are either not required to be sandboxed or rely on a globally shared information
|
|
5889
|
+
{
|
|
5890
|
+
// insertStyleSheet implementation shares a global cache of stylesheet data
|
|
5662
5891
|
insertStylesheet,
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
};
|
|
5892
|
+
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
5893
|
+
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
|
|
5894
|
+
});
|
|
5667
5895
|
|
|
5668
5896
|
/*
|
|
5669
5897
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5712,13 +5940,8 @@ var LWC = (function (exports) {
|
|
|
5712
5940
|
return;
|
|
5713
5941
|
}
|
|
5714
5942
|
try {
|
|
5715
|
-
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
5716
|
-
// and uses the same algo to create the stylesheets as in SSR.
|
|
5717
|
-
setIsHydrating(true);
|
|
5718
5943
|
const vm = createVMWithProps(element, Ctor, props);
|
|
5719
5944
|
hydrateRoot(vm);
|
|
5720
|
-
// set it back since now we finished hydration.
|
|
5721
|
-
setIsHydrating(false);
|
|
5722
5945
|
}
|
|
5723
5946
|
catch (e) {
|
|
5724
5947
|
// Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
|
|
@@ -5729,13 +5952,8 @@ var LWC = (function (exports) {
|
|
|
5729
5952
|
resetShadowRootAndLightDom(element, Ctor);
|
|
5730
5953
|
// we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
|
|
5731
5954
|
createVMWithProps(element, Ctor, props);
|
|
5732
|
-
setIsHydrating(false);
|
|
5733
5955
|
connectRootElement(element);
|
|
5734
5956
|
}
|
|
5735
|
-
finally {
|
|
5736
|
-
// in case there's an error during recovery
|
|
5737
|
-
setIsHydrating(false);
|
|
5738
|
-
}
|
|
5739
5957
|
}
|
|
5740
5958
|
|
|
5741
5959
|
/*
|
|
@@ -5804,41 +6022,57 @@ var LWC = (function (exports) {
|
|
|
5804
6022
|
* SPDX-License-Identifier: MIT
|
|
5805
6023
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5806
6024
|
*/
|
|
5807
|
-
// TODO [#2472]: Remove this workaround when appropriate.
|
|
5808
6025
|
// eslint-disable-next-line @lwc/lwc-internal/no-global-node
|
|
6026
|
+
|
|
5809
6027
|
const _Node$1 = Node;
|
|
5810
6028
|
const ConnectingSlot = new WeakMap();
|
|
5811
6029
|
const DisconnectingSlot = new WeakMap();
|
|
6030
|
+
|
|
5812
6031
|
function callNodeSlot(node, slot) {
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
6032
|
+
|
|
6033
|
+
const fn = slot.get(node);
|
|
6034
|
+
|
|
6035
|
+
if (!isUndefined$1(fn)) {
|
|
6036
|
+
fn(node);
|
|
6037
|
+
}
|
|
6038
|
+
|
|
6039
|
+
return node; // for convenience
|
|
5818
6040
|
}
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
6041
|
+
|
|
6042
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
6043
|
+
// Monkey patching Node methods to be able to detect the insertions and removal of root elements
|
|
6044
|
+
// created via createElement.
|
|
6045
|
+
const {
|
|
6046
|
+
appendChild,
|
|
6047
|
+
insertBefore,
|
|
6048
|
+
removeChild,
|
|
6049
|
+
replaceChild
|
|
6050
|
+
} = _Node$1.prototype;
|
|
6051
|
+
assign(_Node$1.prototype, {
|
|
5823
6052
|
appendChild(newChild) {
|
|
5824
|
-
|
|
5825
|
-
|
|
6053
|
+
const appendedNode = appendChild.call(this, newChild);
|
|
6054
|
+
return callNodeSlot(appendedNode, ConnectingSlot);
|
|
5826
6055
|
},
|
|
6056
|
+
|
|
5827
6057
|
insertBefore(newChild, referenceNode) {
|
|
5828
|
-
|
|
5829
|
-
|
|
6058
|
+
const insertedNode = insertBefore.call(this, newChild, referenceNode);
|
|
6059
|
+
return callNodeSlot(insertedNode, ConnectingSlot);
|
|
5830
6060
|
},
|
|
6061
|
+
|
|
5831
6062
|
removeChild(oldChild) {
|
|
5832
|
-
|
|
5833
|
-
|
|
6063
|
+
const removedNode = removeChild.call(this, oldChild);
|
|
6064
|
+
return callNodeSlot(removedNode, DisconnectingSlot);
|
|
5834
6065
|
},
|
|
6066
|
+
|
|
5835
6067
|
replaceChild(newChild, oldChild) {
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
}
|
|
5841
|
-
|
|
6068
|
+
const replacedNode = replaceChild.call(this, newChild, oldChild);
|
|
6069
|
+
callNodeSlot(replacedNode, DisconnectingSlot);
|
|
6070
|
+
callNodeSlot(newChild, ConnectingSlot);
|
|
6071
|
+
return replacedNode;
|
|
6072
|
+
}
|
|
6073
|
+
|
|
6074
|
+
});
|
|
6075
|
+
}
|
|
5842
6076
|
/**
|
|
5843
6077
|
* EXPERIMENTAL: This function is almost identical to document.createElement with the slightly
|
|
5844
6078
|
* difference that in the options, you can pass the `is` property set to a Constructor instead of
|
|
@@ -5850,38 +6084,50 @@ var LWC = (function (exports) {
|
|
|
5850
6084
|
* const el = createElement('x-foo', { is: FooCtor });
|
|
5851
6085
|
* ```
|
|
5852
6086
|
*/
|
|
6087
|
+
|
|
6088
|
+
|
|
5853
6089
|
function createElement(sel, options) {
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
6090
|
+
if (!isObject(options) || isNull(options)) {
|
|
6091
|
+
throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
|
|
6092
|
+
}
|
|
6093
|
+
|
|
6094
|
+
const Ctor = options.is;
|
|
6095
|
+
|
|
6096
|
+
if (!isFunction$1(Ctor)) {
|
|
6097
|
+
throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
|
|
6098
|
+
}
|
|
6099
|
+
|
|
6100
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
6101
|
+
let wasComponentUpgraded = false; // the custom element from the registry is expecting an upgrade callback
|
|
6102
|
+
|
|
6103
|
+
/**
|
|
6104
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
6105
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
6106
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
6107
|
+
* an upgradable custom element.
|
|
6108
|
+
*/
|
|
6109
|
+
|
|
6110
|
+
const element = new UpgradableConstructor(elm => {
|
|
6111
|
+
createVM(elm, Ctor, renderer, {
|
|
6112
|
+
tagName: sel,
|
|
6113
|
+
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
6114
|
+
owner: null
|
|
5879
6115
|
});
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
6116
|
+
|
|
6117
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
6118
|
+
ConnectingSlot.set(elm, connectRootElement);
|
|
6119
|
+
DisconnectingSlot.set(elm, disconnectRootElement);
|
|
5883
6120
|
}
|
|
5884
|
-
|
|
6121
|
+
|
|
6122
|
+
wasComponentUpgraded = true;
|
|
6123
|
+
});
|
|
6124
|
+
|
|
6125
|
+
if (!wasComponentUpgraded) {
|
|
6126
|
+
/* eslint-disable-next-line no-console */
|
|
6127
|
+
console.error(`Unexpected tag name "${sel}". This name is a registered custom element, preventing LWC to upgrade the element.`);
|
|
6128
|
+
}
|
|
6129
|
+
|
|
6130
|
+
return element;
|
|
5885
6131
|
}
|
|
5886
6132
|
|
|
5887
6133
|
/*
|
|
@@ -5915,7 +6161,7 @@ var LWC = (function (exports) {
|
|
|
5915
6161
|
}
|
|
5916
6162
|
// TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
|
|
5917
6163
|
// inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
|
|
5918
|
-
return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
|
|
6164
|
+
return renderer.isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
|
|
5919
6165
|
}
|
|
5920
6166
|
|
|
5921
6167
|
/*
|
|
@@ -5952,7 +6198,7 @@ var LWC = (function (exports) {
|
|
|
5952
6198
|
});
|
|
5953
6199
|
freeze(LightningElement);
|
|
5954
6200
|
seal(LightningElement.prototype);
|
|
5955
|
-
/* version: 2.
|
|
6201
|
+
/* version: 2.23.2 */
|
|
5956
6202
|
|
|
5957
6203
|
exports.LightningElement = LightningElement;
|
|
5958
6204
|
exports.__unstable__ProfilerControl = profilerControl;
|
|
@@ -5974,6 +6220,7 @@ var LWC = (function (exports) {
|
|
|
5974
6220
|
exports.registerDecorators = registerDecorators;
|
|
5975
6221
|
exports.registerTemplate = registerTemplate;
|
|
5976
6222
|
exports.renderer = renderer;
|
|
6223
|
+
exports.rendererFactory = rendererFactory;
|
|
5977
6224
|
exports.sanitizeAttribute = sanitizeAttribute;
|
|
5978
6225
|
exports.setFeatureFlag = setFeatureFlag;
|
|
5979
6226
|
exports.setFeatureFlagForTest = setFeatureFlagForTest;
|