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