@lwc/engine-core 2.21.1 → 2.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-core.cjs.js +164 -149
- package/dist/engine-core.js +166 -151
- package/package.json +3 -3
- package/types/framework/accessor-reactive-observer.d.ts +9 -0
- package/types/framework/component.d.ts +1 -1
- package/types/framework/decorators/api.d.ts +0 -8
- package/types/framework/membrane.d.ts +3 -3
- package/types/framework/mutation-tracker.d.ts +2 -0
- package/types/framework/renderer.d.ts +0 -2
- package/types/framework/update-component-value.d.ts +2 -0
- package/types/framework/vm.d.ts +1 -1
- package/types/libs/mutation-tracker/index.d.ts +2 -3
package/dist/engine-core.cjs.js
CHANGED
|
@@ -18,7 +18,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
|
18
18
|
window.addEventListener('test-dummy-flag', () => {
|
|
19
19
|
let hasFlag = false;
|
|
20
20
|
|
|
21
|
-
if (features.
|
|
21
|
+
if (features.lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
22
22
|
hasFlag = true;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -216,11 +216,28 @@ class ReactiveObserver {
|
|
|
216
216
|
* SPDX-License-Identifier: MIT
|
|
217
217
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
218
218
|
*/
|
|
219
|
+
const DUMMY_REACTIVE_OBSERVER = {
|
|
220
|
+
observe(job) {
|
|
221
|
+
job();
|
|
222
|
+
},
|
|
223
|
+
reset() { },
|
|
224
|
+
link() { },
|
|
225
|
+
};
|
|
219
226
|
function componentValueMutated(vm, key) {
|
|
220
|
-
|
|
227
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
228
|
+
if (process.env.IS_BROWSER) {
|
|
229
|
+
valueMutated(vm.component, key);
|
|
230
|
+
}
|
|
221
231
|
}
|
|
222
232
|
function componentValueObserved(vm, key) {
|
|
223
|
-
|
|
233
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
234
|
+
if (process.env.IS_BROWSER) {
|
|
235
|
+
valueObserved(vm.component, key);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function createReactiveObserver(callback) {
|
|
239
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
240
|
+
return process.env.IS_BROWSER ? new ReactiveObserver(callback) : DUMMY_REACTIVE_OBSERVER;
|
|
224
241
|
}
|
|
225
242
|
|
|
226
243
|
/*
|
|
@@ -779,6 +796,14 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
|
779
796
|
shared.defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
780
797
|
}
|
|
781
798
|
|
|
799
|
+
function updateComponentValue(vm, key, newValue) {
|
|
800
|
+
const { cmpFields } = vm;
|
|
801
|
+
if (newValue !== cmpFields[key]) {
|
|
802
|
+
cmpFields[key] = newValue;
|
|
803
|
+
componentValueMutated(vm, key);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
782
807
|
/**
|
|
783
808
|
* Copyright (C) 2017 salesforce.com, inc.
|
|
784
809
|
*/
|
|
@@ -1342,7 +1367,24 @@ const reactiveMembrane = new ObservableMembrane({
|
|
|
1342
1367
|
* change or being removed.
|
|
1343
1368
|
*/
|
|
1344
1369
|
function unwrap(value) {
|
|
1345
|
-
|
|
1370
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1371
|
+
return process.env.IS_BROWSER ? reactiveMembrane.unwrapProxy(value) : value;
|
|
1372
|
+
}
|
|
1373
|
+
function getReadOnlyProxy(value) {
|
|
1374
|
+
// We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
|
|
1375
|
+
// them from their parents. This applies to both the client and server.
|
|
1376
|
+
return reactiveMembrane.getReadOnlyProxy(value);
|
|
1377
|
+
}
|
|
1378
|
+
function getReactiveProxy(value) {
|
|
1379
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1380
|
+
return process.env.IS_BROWSER ? reactiveMembrane.getProxy(value) : value;
|
|
1381
|
+
}
|
|
1382
|
+
// Making the component instance a live value when using Locker to support expandos.
|
|
1383
|
+
function markLockerLiveObject(obj) {
|
|
1384
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1385
|
+
if (process.env.IS_BROWSER) {
|
|
1386
|
+
obj[lockerLivePropertyKey] = undefined;
|
|
1387
|
+
}
|
|
1346
1388
|
}
|
|
1347
1389
|
|
|
1348
1390
|
/*
|
|
@@ -1394,10 +1436,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
|
|
|
1394
1436
|
shared.assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1395
1437
|
shared.assert.invariant(!shared.isObject(newValue) || shared.isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1396
1438
|
}
|
|
1397
|
-
|
|
1398
|
-
vm.cmpProps[propName] = newValue;
|
|
1399
|
-
componentValueMutated(vm, propName);
|
|
1400
|
-
}
|
|
1439
|
+
updateComponentValue(vm, propName, newValue);
|
|
1401
1440
|
return set.call(vm.elm, newValue);
|
|
1402
1441
|
},
|
|
1403
1442
|
};
|
|
@@ -1432,8 +1471,7 @@ const LightningElement = function () {
|
|
|
1432
1471
|
vm.setHook = setHook;
|
|
1433
1472
|
vm.getHook = getHook;
|
|
1434
1473
|
}
|
|
1435
|
-
|
|
1436
|
-
this[lockerLivePropertyKey] = undefined;
|
|
1474
|
+
markLockerLiveObject(this);
|
|
1437
1475
|
// Linking elm, shadow root and component with the VM.
|
|
1438
1476
|
associateVM(component, vm);
|
|
1439
1477
|
associateVM(elm, vm);
|
|
@@ -1693,16 +1731,67 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
1693
1731
|
},
|
|
1694
1732
|
set(newValue) {
|
|
1695
1733
|
const vm = getAssociatedVM(this);
|
|
1696
|
-
|
|
1697
|
-
vm.cmpFields[key] = newValue;
|
|
1698
|
-
componentValueMutated(vm, key);
|
|
1699
|
-
}
|
|
1734
|
+
updateComponentValue(vm, key, newValue);
|
|
1700
1735
|
},
|
|
1701
1736
|
enumerable: true,
|
|
1702
1737
|
configurable: true,
|
|
1703
1738
|
};
|
|
1704
1739
|
}
|
|
1705
1740
|
|
|
1741
|
+
/*
|
|
1742
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
1743
|
+
* All rights reserved.
|
|
1744
|
+
* SPDX-License-Identifier: MIT
|
|
1745
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1746
|
+
*/
|
|
1747
|
+
const DUMMY_ACCESSOR_REACTIVE_OBSERVER = {
|
|
1748
|
+
observe(job) {
|
|
1749
|
+
job();
|
|
1750
|
+
},
|
|
1751
|
+
reset() { },
|
|
1752
|
+
link() { },
|
|
1753
|
+
};
|
|
1754
|
+
class AccessorReactiveObserver extends ReactiveObserver {
|
|
1755
|
+
constructor(vm, set) {
|
|
1756
|
+
super(() => {
|
|
1757
|
+
if (shared.isFalse(this.debouncing)) {
|
|
1758
|
+
this.debouncing = true;
|
|
1759
|
+
addCallbackToNextTick(() => {
|
|
1760
|
+
if (shared.isTrue(this.debouncing)) {
|
|
1761
|
+
const { value } = this;
|
|
1762
|
+
const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
|
|
1763
|
+
set.call(component, value);
|
|
1764
|
+
// de-bouncing after the call to the original setter to prevent
|
|
1765
|
+
// infinity loop if the setter itself is mutating things that
|
|
1766
|
+
// were accessed during the previous invocation.
|
|
1767
|
+
this.debouncing = false;
|
|
1768
|
+
if (shared.isTrue(vm.isDirty) && shared.isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
|
|
1769
|
+
// immediate rehydration due to a setter driven mutation, otherwise
|
|
1770
|
+
// the component will get rendered on the second tick, which it is not
|
|
1771
|
+
// desirable.
|
|
1772
|
+
rerenderVM(vm);
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
});
|
|
1778
|
+
this.debouncing = false;
|
|
1779
|
+
}
|
|
1780
|
+
reset(value) {
|
|
1781
|
+
super.reset();
|
|
1782
|
+
this.debouncing = false;
|
|
1783
|
+
if (arguments.length > 0) {
|
|
1784
|
+
this.value = value;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
function createAccessorReactiveObserver(vm, set) {
|
|
1789
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1790
|
+
return process.env.IS_BROWSER
|
|
1791
|
+
? new AccessorReactiveObserver(vm, set)
|
|
1792
|
+
: DUMMY_ACCESSOR_REACTIVE_OBSERVER;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1706
1795
|
/*
|
|
1707
1796
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1708
1797
|
* All rights reserved.
|
|
@@ -1750,50 +1839,6 @@ function createPublicPropertyDescriptor(key) {
|
|
|
1750
1839
|
configurable: true
|
|
1751
1840
|
};
|
|
1752
1841
|
}
|
|
1753
|
-
class AccessorReactiveObserver extends ReactiveObserver {
|
|
1754
|
-
constructor(vm, set) {
|
|
1755
|
-
super(() => {
|
|
1756
|
-
if (shared.isFalse(this.debouncing)) {
|
|
1757
|
-
this.debouncing = true;
|
|
1758
|
-
addCallbackToNextTick(() => {
|
|
1759
|
-
if (shared.isTrue(this.debouncing)) {
|
|
1760
|
-
const {
|
|
1761
|
-
value
|
|
1762
|
-
} = this;
|
|
1763
|
-
const {
|
|
1764
|
-
isDirty: dirtyStateBeforeSetterCall,
|
|
1765
|
-
component,
|
|
1766
|
-
idx
|
|
1767
|
-
} = vm;
|
|
1768
|
-
set.call(component, value); // de-bouncing after the call to the original setter to prevent
|
|
1769
|
-
// infinity loop if the setter itself is mutating things that
|
|
1770
|
-
// were accessed during the previous invocation.
|
|
1771
|
-
|
|
1772
|
-
this.debouncing = false;
|
|
1773
|
-
|
|
1774
|
-
if (shared.isTrue(vm.isDirty) && shared.isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
|
|
1775
|
-
// immediate rehydration due to a setter driven mutation, otherwise
|
|
1776
|
-
// the component will get rendered on the second tick, which it is not
|
|
1777
|
-
// desirable.
|
|
1778
|
-
rerenderVM(vm);
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
});
|
|
1782
|
-
}
|
|
1783
|
-
});
|
|
1784
|
-
this.debouncing = false;
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
reset(value) {
|
|
1788
|
-
super.reset();
|
|
1789
|
-
this.debouncing = false;
|
|
1790
|
-
|
|
1791
|
-
if (arguments.length > 0) {
|
|
1792
|
-
this.value = value;
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
}
|
|
1797
1842
|
function createPublicAccessorDescriptor(key, descriptor) {
|
|
1798
1843
|
const {
|
|
1799
1844
|
get,
|
|
@@ -1830,11 +1875,11 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
1830
1875
|
}
|
|
1831
1876
|
|
|
1832
1877
|
if (set) {
|
|
1833
|
-
if (features.
|
|
1878
|
+
if (features.lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
|
|
1834
1879
|
let ro = vm.oar[key];
|
|
1835
1880
|
|
|
1836
1881
|
if (shared.isUndefined(ro)) {
|
|
1837
|
-
ro = vm.oar[key] =
|
|
1882
|
+
ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
|
|
1838
1883
|
} // every time we invoke this setter from outside (through this wrapper setter)
|
|
1839
1884
|
// we should reset the value and then debounce just in case there is a pending
|
|
1840
1885
|
// invocation the next tick that is not longer relevant since the value is changing
|
|
@@ -1866,7 +1911,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
1866
1911
|
*/
|
|
1867
1912
|
function track(target) {
|
|
1868
1913
|
if (arguments.length === 1) {
|
|
1869
|
-
return
|
|
1914
|
+
return getReactiveProxy(target);
|
|
1870
1915
|
}
|
|
1871
1916
|
if (process.env.NODE_ENV !== 'production') {
|
|
1872
1917
|
shared.assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
|
|
@@ -1887,11 +1932,8 @@ function internalTrackDecorator(key) {
|
|
|
1887
1932
|
shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
|
|
1888
1933
|
shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
|
|
1889
1934
|
}
|
|
1890
|
-
const reactiveOrAnyValue =
|
|
1891
|
-
|
|
1892
|
-
vm.cmpFields[key] = reactiveOrAnyValue;
|
|
1893
|
-
componentValueMutated(vm, key);
|
|
1894
|
-
}
|
|
1935
|
+
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
1936
|
+
updateComponentValue(vm, key, reactiveOrAnyValue);
|
|
1895
1937
|
},
|
|
1896
1938
|
enumerable: true,
|
|
1897
1939
|
configurable: true,
|
|
@@ -1930,10 +1972,7 @@ function internalWireFieldDecorator(key) {
|
|
|
1930
1972
|
* letting the author to do the wrong thing, but it will keep our
|
|
1931
1973
|
* system to be backward compatible.
|
|
1932
1974
|
*/
|
|
1933
|
-
|
|
1934
|
-
vm.cmpFields[key] = value;
|
|
1935
|
-
componentValueMutated(vm, key);
|
|
1936
|
-
}
|
|
1975
|
+
updateComponentValue(vm, key, value);
|
|
1937
1976
|
},
|
|
1938
1977
|
enumerable: true,
|
|
1939
1978
|
configurable: true,
|
|
@@ -2279,7 +2318,7 @@ function createSetter(key) {
|
|
|
2279
2318
|
fn = cachedSetterByKey[key] = function (newValue) {
|
|
2280
2319
|
const vm = getAssociatedVM(this);
|
|
2281
2320
|
const { setHook } = vm;
|
|
2282
|
-
newValue =
|
|
2321
|
+
newValue = getReadOnlyProxy(newValue);
|
|
2283
2322
|
setHook(vm.component, key, newValue);
|
|
2284
2323
|
};
|
|
2285
2324
|
}
|
|
@@ -2488,7 +2527,7 @@ function getTemplateOrSwappedTemplate(tpl) {
|
|
|
2488
2527
|
throw new ReferenceError();
|
|
2489
2528
|
}
|
|
2490
2529
|
|
|
2491
|
-
if (features.
|
|
2530
|
+
if (features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2492
2531
|
const visited = new Set();
|
|
2493
2532
|
|
|
2494
2533
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
@@ -2505,7 +2544,7 @@ function getComponentOrSwappedComponent(Ctor) {
|
|
|
2505
2544
|
throw new ReferenceError();
|
|
2506
2545
|
}
|
|
2507
2546
|
|
|
2508
|
-
if (features.
|
|
2547
|
+
if (features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2509
2548
|
const visited = new Set();
|
|
2510
2549
|
|
|
2511
2550
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
@@ -2522,7 +2561,7 @@ function getStyleOrSwappedStyle(style) {
|
|
|
2522
2561
|
throw new ReferenceError();
|
|
2523
2562
|
}
|
|
2524
2563
|
|
|
2525
|
-
if (features.
|
|
2564
|
+
if (features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2526
2565
|
const visited = new Set();
|
|
2527
2566
|
|
|
2528
2567
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
@@ -2539,7 +2578,7 @@ function setActiveVM(vm) {
|
|
|
2539
2578
|
throw new ReferenceError();
|
|
2540
2579
|
}
|
|
2541
2580
|
|
|
2542
|
-
if (features.
|
|
2581
|
+
if (features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2543
2582
|
// tracking active component
|
|
2544
2583
|
const Ctor = vm.def.ctor;
|
|
2545
2584
|
let componentVMs = activeComponents.get(Ctor);
|
|
@@ -2596,7 +2635,7 @@ function removeActiveVM(vm) {
|
|
|
2596
2635
|
throw new ReferenceError();
|
|
2597
2636
|
}
|
|
2598
2637
|
|
|
2599
|
-
if (features.
|
|
2638
|
+
if (features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2600
2639
|
// tracking inactive component
|
|
2601
2640
|
const Ctor = vm.def.ctor;
|
|
2602
2641
|
let list = activeComponents.get(Ctor);
|
|
@@ -2643,7 +2682,7 @@ function swapTemplate(oldTpl, newTpl) {
|
|
|
2643
2682
|
}
|
|
2644
2683
|
}
|
|
2645
2684
|
|
|
2646
|
-
if (!features.
|
|
2685
|
+
if (!features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2647
2686
|
throw new Error('HMR is not enabled');
|
|
2648
2687
|
}
|
|
2649
2688
|
|
|
@@ -2659,7 +2698,7 @@ function swapComponent(oldComponent, newComponent) {
|
|
|
2659
2698
|
}
|
|
2660
2699
|
}
|
|
2661
2700
|
|
|
2662
|
-
if (!features.
|
|
2701
|
+
if (!features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2663
2702
|
throw new Error('HMR is not enabled');
|
|
2664
2703
|
}
|
|
2665
2704
|
|
|
@@ -2673,7 +2712,7 @@ function swapStyle(oldStyle, newStyle) {
|
|
|
2673
2712
|
return rehydrateHotStyle(oldStyle);
|
|
2674
2713
|
}
|
|
2675
2714
|
|
|
2676
|
-
if (!features.
|
|
2715
|
+
if (!features.lwcRuntimeFlags.ENABLE_HMR) {
|
|
2677
2716
|
throw new Error('HMR is not enabled');
|
|
2678
2717
|
}
|
|
2679
2718
|
|
|
@@ -3022,13 +3061,13 @@ function getNearestNativeShadowComponent(vm) {
|
|
|
3022
3061
|
return owner;
|
|
3023
3062
|
}
|
|
3024
3063
|
function createStylesheet(vm, stylesheets) {
|
|
3025
|
-
const { renderMode, shadowMode, renderer: {
|
|
3064
|
+
const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
|
|
3026
3065
|
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3027
3066
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3028
3067
|
insertStylesheet(stylesheets[i]);
|
|
3029
3068
|
}
|
|
3030
3069
|
}
|
|
3031
|
-
else if (
|
|
3070
|
+
else if (!process.env.IS_BROWSER || vm.hydrated) {
|
|
3032
3071
|
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3033
3072
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3034
3073
|
// the first time the VM renders.
|
|
@@ -3329,7 +3368,7 @@ function patchChildren(c1, c2, parent, renderer) {
|
|
|
3329
3368
|
updateStaticChildren(c1, c2, parent, renderer);
|
|
3330
3369
|
}
|
|
3331
3370
|
}
|
|
3332
|
-
function patch(n1, n2, renderer) {
|
|
3371
|
+
function patch(n1, n2, parent, renderer) {
|
|
3333
3372
|
var _a, _b;
|
|
3334
3373
|
if (n1 === n2) {
|
|
3335
3374
|
return;
|
|
@@ -3358,7 +3397,7 @@ function patch(n1, n2, renderer) {
|
|
|
3358
3397
|
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3359
3398
|
break;
|
|
3360
3399
|
case 3 /* VNodeType.CustomElement */:
|
|
3361
|
-
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3400
|
+
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3362
3401
|
break;
|
|
3363
3402
|
}
|
|
3364
3403
|
}
|
|
@@ -3485,22 +3524,32 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3485
3524
|
appendVM(vm);
|
|
3486
3525
|
}
|
|
3487
3526
|
}
|
|
3488
|
-
function patchCustomElement(n1, n2, renderer) {
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
allocateChildren(n2, vm);
|
|
3527
|
+
function patchCustomElement(n1, n2, parent, renderer) {
|
|
3528
|
+
if (n1.ctor !== n2.ctor) {
|
|
3529
|
+
// If the constructor, unmount the current component and mount a new one using the new
|
|
3530
|
+
// constructor.
|
|
3531
|
+
const anchor = renderer.nextSibling(n1.elm);
|
|
3532
|
+
unmount(n1, parent, renderer, true);
|
|
3533
|
+
mountCustomElement(n2, parent, anchor, renderer);
|
|
3496
3534
|
}
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3535
|
+
else {
|
|
3536
|
+
// Otherwise patch the existing component with new props/attrs/etc.
|
|
3537
|
+
const elm = (n2.elm = n1.elm);
|
|
3538
|
+
const vm = (n2.vm = n1.vm);
|
|
3539
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3540
|
+
if (!shared.isUndefined(vm)) {
|
|
3541
|
+
// in fallback mode, the allocation will always set children to
|
|
3542
|
+
// empty and delegate the real allocation to the slot elements
|
|
3543
|
+
allocateChildren(n2, vm);
|
|
3544
|
+
}
|
|
3545
|
+
// in fallback mode, the children will be always empty, so, nothing
|
|
3546
|
+
// will happen, but in native, it does allocate the light dom
|
|
3547
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3548
|
+
if (!shared.isUndefined(vm)) {
|
|
3549
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3550
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
3551
|
+
rerenderVM(vm);
|
|
3552
|
+
}
|
|
3504
3553
|
}
|
|
3505
3554
|
}
|
|
3506
3555
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
@@ -3770,25 +3819,25 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
3770
3819
|
newEndVnode = newCh[--newEndIdx];
|
|
3771
3820
|
}
|
|
3772
3821
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
3773
|
-
patch(oldStartVnode, newStartVnode, renderer);
|
|
3822
|
+
patch(oldStartVnode, newStartVnode, parent, renderer);
|
|
3774
3823
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3775
3824
|
newStartVnode = newCh[++newStartIdx];
|
|
3776
3825
|
}
|
|
3777
3826
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
3778
|
-
patch(oldEndVnode, newEndVnode, renderer);
|
|
3827
|
+
patch(oldEndVnode, newEndVnode, parent, renderer);
|
|
3779
3828
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3780
3829
|
newEndVnode = newCh[--newEndIdx];
|
|
3781
3830
|
}
|
|
3782
3831
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
3783
3832
|
// Vnode moved right
|
|
3784
|
-
patch(oldStartVnode, newEndVnode, renderer);
|
|
3833
|
+
patch(oldStartVnode, newEndVnode, parent, renderer);
|
|
3785
3834
|
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
3786
3835
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3787
3836
|
newEndVnode = newCh[--newEndIdx];
|
|
3788
3837
|
}
|
|
3789
3838
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
3790
3839
|
// Vnode moved left
|
|
3791
|
-
patch(oldEndVnode, newStartVnode, renderer);
|
|
3840
|
+
patch(oldEndVnode, newStartVnode, parent, renderer);
|
|
3792
3841
|
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
3793
3842
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3794
3843
|
newStartVnode = newCh[++newStartIdx];
|
|
@@ -3811,7 +3860,7 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
3811
3860
|
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3812
3861
|
}
|
|
3813
3862
|
else {
|
|
3814
|
-
patch(elmToMove, newStartVnode, renderer);
|
|
3863
|
+
patch(elmToMove, newStartVnode, parent, renderer);
|
|
3815
3864
|
// Delete the old child, but copy the array since it is read-only.
|
|
3816
3865
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
3817
3866
|
// so we only care about the `oldCh` object inside this function.
|
|
@@ -3871,7 +3920,7 @@ function updateStaticChildren(c1, c2, parent, renderer) {
|
|
|
3871
3920
|
if (isVNode(n1)) {
|
|
3872
3921
|
if (isVNode(n2)) {
|
|
3873
3922
|
// both vnodes are equivalent, and we just need to patch them
|
|
3874
|
-
patch(n1, n2, renderer);
|
|
3923
|
+
patch(n1, n2, parent, renderer);
|
|
3875
3924
|
anchor = n2.elm;
|
|
3876
3925
|
}
|
|
3877
3926
|
else {
|
|
@@ -4205,13 +4254,6 @@ function fid(url) {
|
|
|
4205
4254
|
}
|
|
4206
4255
|
return url;
|
|
4207
4256
|
}
|
|
4208
|
-
/**
|
|
4209
|
-
* Map to store an index value assigned to any dynamic component reference ingested
|
|
4210
|
-
* by dc() api. This allows us to generate a unique unique per template per dynamic
|
|
4211
|
-
* component reference to avoid diffing algo mismatches.
|
|
4212
|
-
*/
|
|
4213
|
-
const DynamicImportedComponentMap = new Map();
|
|
4214
|
-
let dynamicImportedComponentCounter = 0;
|
|
4215
4257
|
/**
|
|
4216
4258
|
* create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
4217
4259
|
*/
|
|
@@ -4228,18 +4270,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
|
|
|
4228
4270
|
if (!isComponentConstructor(Ctor)) {
|
|
4229
4271
|
throw new Error(`Invalid LWC Constructor ${shared.toString(Ctor)} for custom element <${sel}>.`);
|
|
4230
4272
|
}
|
|
4231
|
-
|
|
4232
|
-
if (shared.isUndefined(idx)) {
|
|
4233
|
-
idx = dynamicImportedComponentCounter++;
|
|
4234
|
-
DynamicImportedComponentMap.set(Ctor, idx);
|
|
4235
|
-
}
|
|
4236
|
-
// the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
|
|
4237
|
-
// to identify different constructors as vnodes with different keys to avoid reusing the
|
|
4238
|
-
// element used for previous constructors.
|
|
4239
|
-
// Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
|
|
4240
|
-
// hoisting optimization.
|
|
4241
|
-
const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
|
|
4242
|
-
return c(sel, Ctor, newData, children);
|
|
4273
|
+
return c(sel, Ctor, data, children);
|
|
4243
4274
|
}
|
|
4244
4275
|
/**
|
|
4245
4276
|
* slow children collection marking mechanism. this API allows the compiler to signal
|
|
@@ -4715,7 +4746,7 @@ function getComponentRegisteredTemplate(Ctor) {
|
|
|
4715
4746
|
return signedTemplateMap.get(Ctor);
|
|
4716
4747
|
}
|
|
4717
4748
|
function getTemplateReactiveObserver(vm) {
|
|
4718
|
-
return
|
|
4749
|
+
return createReactiveObserver(() => {
|
|
4719
4750
|
const { isDirty } = vm;
|
|
4720
4751
|
if (shared.isFalse(isDirty)) {
|
|
4721
4752
|
markComponentAsDirty(vm);
|
|
@@ -4965,7 +4996,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
4965
4996
|
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
4966
4997
|
};
|
|
4967
4998
|
|
|
4968
|
-
if (features.
|
|
4999
|
+
if (features.lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
4969
5000
|
vm.shadowMode = 0
|
|
4970
5001
|
/* ShadowMode.Native */
|
|
4971
5002
|
;
|
|
@@ -5004,7 +5035,7 @@ function computeShadowMode(vm, renderer) {
|
|
|
5004
5035
|
} else if (isNativeShadowDefined) {
|
|
5005
5036
|
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
5006
5037
|
// the if-condition.
|
|
5007
|
-
if (features.
|
|
5038
|
+
if (features.lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
5008
5039
|
if (def.shadowSupportMode === "any"
|
|
5009
5040
|
/* ShadowSupportMode.Any */
|
|
5010
5041
|
) {
|
|
@@ -5133,13 +5164,10 @@ function runRenderedCallback(vm) {
|
|
|
5133
5164
|
const {
|
|
5134
5165
|
def: {
|
|
5135
5166
|
renderedCallback
|
|
5136
|
-
},
|
|
5137
|
-
renderer: {
|
|
5138
|
-
ssr
|
|
5139
5167
|
}
|
|
5140
5168
|
} = vm;
|
|
5141
5169
|
|
|
5142
|
-
if (
|
|
5170
|
+
if (!process.env.IS_BROWSER) {
|
|
5143
5171
|
return;
|
|
5144
5172
|
}
|
|
5145
5173
|
|
|
@@ -5392,13 +5420,7 @@ function resetComponentRoot(vm) {
|
|
|
5392
5420
|
vm.velements = EmptyArray;
|
|
5393
5421
|
}
|
|
5394
5422
|
function scheduleRehydration(vm) {
|
|
5395
|
-
|
|
5396
|
-
renderer: {
|
|
5397
|
-
ssr
|
|
5398
|
-
}
|
|
5399
|
-
} = vm;
|
|
5400
|
-
|
|
5401
|
-
if (shared.isTrue(ssr) || shared.isTrue(vm.isScheduled)) {
|
|
5423
|
+
if (!process.env.IS_BROWSER || shared.isTrue(vm.isScheduled)) {
|
|
5402
5424
|
return;
|
|
5403
5425
|
}
|
|
5404
5426
|
|
|
@@ -5505,15 +5527,8 @@ class WireContextRegistrationEvent extends CustomEvent {
|
|
|
5505
5527
|
}
|
|
5506
5528
|
|
|
5507
5529
|
function createFieldDataCallback(vm, name) {
|
|
5508
|
-
const {
|
|
5509
|
-
cmpFields
|
|
5510
|
-
} = vm;
|
|
5511
5530
|
return value => {
|
|
5512
|
-
|
|
5513
|
-
// storing the value in the underlying storage
|
|
5514
|
-
cmpFields[name] = value;
|
|
5515
|
-
componentValueMutated(vm, name);
|
|
5516
|
-
}
|
|
5531
|
+
updateComponentValue(vm, name, value);
|
|
5517
5532
|
};
|
|
5518
5533
|
}
|
|
5519
5534
|
|
|
@@ -5530,7 +5545,7 @@ function createMethodDataCallback(vm, method) {
|
|
|
5530
5545
|
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
5531
5546
|
let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
|
|
5532
5547
|
|
|
5533
|
-
const ro =
|
|
5548
|
+
const ro = createReactiveObserver(() => {
|
|
5534
5549
|
if (hasPendingConfig === false) {
|
|
5535
5550
|
hasPendingConfig = true; // collect new config in the micro-task
|
|
5536
5551
|
|
|
@@ -5731,7 +5746,7 @@ function installWireAdapters(vm) {
|
|
|
5731
5746
|
shared.ArrayPush.call(wiredConnecting, () => {
|
|
5732
5747
|
connector.connect();
|
|
5733
5748
|
|
|
5734
|
-
if (!features.
|
|
5749
|
+
if (!features.lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
5735
5750
|
if (hasDynamicParams) {
|
|
5736
5751
|
Promise.resolve().then(computeConfigAndUpdate);
|
|
5737
5752
|
return;
|
|
@@ -5826,7 +5841,7 @@ function readonly(obj) {
|
|
|
5826
5841
|
shared.assert.fail('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
|
|
5827
5842
|
}
|
|
5828
5843
|
}
|
|
5829
|
-
return
|
|
5844
|
+
return getReadOnlyProxy(obj);
|
|
5830
5845
|
}
|
|
5831
5846
|
|
|
5832
5847
|
/*
|
|
@@ -6376,4 +6391,4 @@ exports.swapTemplate = swapTemplate;
|
|
|
6376
6391
|
exports.track = track;
|
|
6377
6392
|
exports.unwrap = unwrap;
|
|
6378
6393
|
exports.wire = wire;
|
|
6379
|
-
/* version: 2.
|
|
6394
|
+
/* version: 2.23.1 */
|