@lwc/engine-core 2.21.0 → 2.23.0
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 +187 -192
- package/dist/engine-core.js +188 -193
- 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
|
@@ -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,
|
|
@@ -1834,7 +1879,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
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
|
}
|
|
@@ -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
|
}
|
|
@@ -3419,10 +3458,11 @@ function mountElement(vnode, parent, anchor, renderer) {
|
|
|
3419
3458
|
const { sel, owner, data: { svg }, } = vnode;
|
|
3420
3459
|
const { createElement } = renderer;
|
|
3421
3460
|
const namespace = shared.isTrue(svg) ? shared.SVG_NAMESPACE : undefined;
|
|
3422
|
-
const elm = createElement(sel, namespace);
|
|
3461
|
+
const elm = (vnode.elm = createElement(sel, namespace));
|
|
3423
3462
|
linkNodeToShadow(elm, owner, renderer);
|
|
3424
|
-
|
|
3425
|
-
|
|
3463
|
+
applyStyleScoping(elm, owner, renderer);
|
|
3464
|
+
applyDomManual(elm, vnode);
|
|
3465
|
+
applyElementRestrictions(elm, vnode);
|
|
3426
3466
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3427
3467
|
insertNode(elm, parent, anchor, renderer);
|
|
3428
3468
|
mountVNodes(vnode.children, elm, renderer, null);
|
|
@@ -3437,6 +3477,7 @@ function mountStatic(vnode, parent, anchor, renderer) {
|
|
|
3437
3477
|
const { cloneNode, isSyntheticShadowDefined } = renderer;
|
|
3438
3478
|
const elm = (vnode.elm = cloneNode(vnode.fragment, true));
|
|
3439
3479
|
linkNodeToShadow(elm, owner, renderer);
|
|
3480
|
+
applyElementRestrictions(elm, vnode);
|
|
3440
3481
|
// Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
3441
3482
|
const { renderMode, shadowMode } = owner;
|
|
3442
3483
|
if (isSyntheticShadowDefined) {
|
|
@@ -3444,10 +3485,6 @@ function mountStatic(vnode, parent, anchor, renderer) {
|
|
|
3444
3485
|
elm[shared.KEY__SHADOW_STATIC] = true;
|
|
3445
3486
|
}
|
|
3446
3487
|
}
|
|
3447
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3448
|
-
const isLight = renderMode === 0 /* RenderMode.Light */;
|
|
3449
|
-
patchElementWithRestrictions(elm, { isPortal: false, isLight });
|
|
3450
|
-
}
|
|
3451
3488
|
insertNode(elm, parent, anchor, renderer);
|
|
3452
3489
|
}
|
|
3453
3490
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
@@ -3464,9 +3501,10 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3464
3501
|
// the custom element from the registry is expecting an upgrade callback
|
|
3465
3502
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
3466
3503
|
});
|
|
3467
|
-
linkNodeToShadow(elm, owner, renderer);
|
|
3468
3504
|
vnode.elm = elm;
|
|
3469
3505
|
vnode.vm = vm;
|
|
3506
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3507
|
+
applyStyleScoping(elm, owner, renderer);
|
|
3470
3508
|
if (vm) {
|
|
3471
3509
|
allocateChildren(vnode, vm);
|
|
3472
3510
|
}
|
|
@@ -3486,22 +3524,32 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3486
3524
|
appendVM(vm);
|
|
3487
3525
|
}
|
|
3488
3526
|
}
|
|
3489
|
-
function patchCustomElement(n1, n2, renderer) {
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
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);
|
|
3497
3534
|
}
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
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
|
+
}
|
|
3505
3553
|
}
|
|
3506
3554
|
}
|
|
3507
3555
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
@@ -3550,22 +3598,6 @@ function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, en
|
|
|
3550
3598
|
function isVNode(vnode) {
|
|
3551
3599
|
return vnode != null;
|
|
3552
3600
|
}
|
|
3553
|
-
function observeElementChildNodes(elm) {
|
|
3554
|
-
elm.$domManual$ = true;
|
|
3555
|
-
}
|
|
3556
|
-
function setElementShadowToken(elm, token) {
|
|
3557
|
-
elm.$shadowToken$ = token;
|
|
3558
|
-
}
|
|
3559
|
-
// Set the scope token class for *.scoped.css styles
|
|
3560
|
-
function setScopeTokenClassIfNecessary(elm, owner, renderer) {
|
|
3561
|
-
const token = getScopeTokenClass(owner);
|
|
3562
|
-
if (!shared.isNull(token)) {
|
|
3563
|
-
const { getClassList } = renderer;
|
|
3564
|
-
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3565
|
-
// probably we should have a renderer api for just the add operation
|
|
3566
|
-
getClassList(elm).add(token);
|
|
3567
|
-
}
|
|
3568
|
-
}
|
|
3569
3601
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
3570
3602
|
const { renderRoot, renderMode, shadowMode } = owner;
|
|
3571
3603
|
const { isSyntheticShadowDefined } = renderer;
|
|
@@ -3618,31 +3650,37 @@ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
|
3618
3650
|
patchAttributes(oldVnode, vnode, renderer);
|
|
3619
3651
|
patchProps(oldVnode, vnode, renderer);
|
|
3620
3652
|
}
|
|
3621
|
-
function
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
if (
|
|
3625
|
-
const {
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3653
|
+
function applyStyleScoping(elm, owner, renderer) {
|
|
3654
|
+
// Set the class name for `*.scoped.css` style scoping.
|
|
3655
|
+
const scopeToken = getScopeTokenClass(owner);
|
|
3656
|
+
if (!shared.isNull(scopeToken)) {
|
|
3657
|
+
const { getClassList } = renderer;
|
|
3658
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3659
|
+
// probably we should have a renderer api for just the add operation
|
|
3660
|
+
getClassList(elm).add(scopeToken);
|
|
3661
|
+
}
|
|
3662
|
+
// Set property element for synthetic shadow DOM style scoping.
|
|
3663
|
+
const { stylesheetToken: syntheticToken } = owner.context;
|
|
3664
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !shared.isUndefined(syntheticToken)) {
|
|
3665
|
+
elm.$shadowToken$ = syntheticToken;
|
|
3666
|
+
}
|
|
3667
|
+
}
|
|
3668
|
+
function applyDomManual(elm, vnode) {
|
|
3669
|
+
var _a;
|
|
3670
|
+
const { owner, data: { context }, } = vnode;
|
|
3671
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
|
|
3672
|
+
elm.$domManual$ = true;
|
|
3638
3673
|
}
|
|
3674
|
+
}
|
|
3675
|
+
function applyElementRestrictions(elm, vnode) {
|
|
3676
|
+
var _a, _b;
|
|
3639
3677
|
if (process.env.NODE_ENV !== 'production') {
|
|
3640
|
-
const
|
|
3641
|
-
const
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3678
|
+
const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
|
|
3679
|
+
const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
|
|
3680
|
+
patchElementWithRestrictions(elm, {
|
|
3681
|
+
isPortal,
|
|
3682
|
+
isLight,
|
|
3683
|
+
});
|
|
3646
3684
|
}
|
|
3647
3685
|
}
|
|
3648
3686
|
function allocateChildren(vnode, vm) {
|
|
@@ -3677,15 +3715,6 @@ function createViewModelHook(elm, vnode, renderer) {
|
|
|
3677
3715
|
return vm;
|
|
3678
3716
|
}
|
|
3679
3717
|
const { sel, mode, ctor, owner } = vnode;
|
|
3680
|
-
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
3681
|
-
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3682
|
-
const { stylesheetToken } = owner.context;
|
|
3683
|
-
// when running in synthetic shadow mode, we need to set the shadowToken value
|
|
3684
|
-
// into each element from the template, so they can be styled accordingly.
|
|
3685
|
-
if (!shared.isUndefined(stylesheetToken)) {
|
|
3686
|
-
setElementShadowToken(elm, stylesheetToken);
|
|
3687
|
-
}
|
|
3688
|
-
}
|
|
3689
3718
|
vm = createVM(elm, ctor, renderer, {
|
|
3690
3719
|
mode,
|
|
3691
3720
|
owner,
|
|
@@ -3790,25 +3819,25 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
3790
3819
|
newEndVnode = newCh[--newEndIdx];
|
|
3791
3820
|
}
|
|
3792
3821
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
3793
|
-
patch(oldStartVnode, newStartVnode, renderer);
|
|
3822
|
+
patch(oldStartVnode, newStartVnode, parent, renderer);
|
|
3794
3823
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3795
3824
|
newStartVnode = newCh[++newStartIdx];
|
|
3796
3825
|
}
|
|
3797
3826
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
3798
|
-
patch(oldEndVnode, newEndVnode, renderer);
|
|
3827
|
+
patch(oldEndVnode, newEndVnode, parent, renderer);
|
|
3799
3828
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3800
3829
|
newEndVnode = newCh[--newEndIdx];
|
|
3801
3830
|
}
|
|
3802
3831
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
3803
3832
|
// Vnode moved right
|
|
3804
|
-
patch(oldStartVnode, newEndVnode, renderer);
|
|
3833
|
+
patch(oldStartVnode, newEndVnode, parent, renderer);
|
|
3805
3834
|
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
3806
3835
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3807
3836
|
newEndVnode = newCh[--newEndIdx];
|
|
3808
3837
|
}
|
|
3809
3838
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
3810
3839
|
// Vnode moved left
|
|
3811
|
-
patch(oldEndVnode, newStartVnode, renderer);
|
|
3840
|
+
patch(oldEndVnode, newStartVnode, parent, renderer);
|
|
3812
3841
|
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
3813
3842
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3814
3843
|
newStartVnode = newCh[++newStartIdx];
|
|
@@ -3831,7 +3860,7 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
3831
3860
|
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3832
3861
|
}
|
|
3833
3862
|
else {
|
|
3834
|
-
patch(elmToMove, newStartVnode, renderer);
|
|
3863
|
+
patch(elmToMove, newStartVnode, parent, renderer);
|
|
3835
3864
|
// Delete the old child, but copy the array since it is read-only.
|
|
3836
3865
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
3837
3866
|
// so we only care about the `oldCh` object inside this function.
|
|
@@ -3891,7 +3920,7 @@ function updateStaticChildren(c1, c2, parent, renderer) {
|
|
|
3891
3920
|
if (isVNode(n1)) {
|
|
3892
3921
|
if (isVNode(n2)) {
|
|
3893
3922
|
// both vnodes are equivalent, and we just need to patch them
|
|
3894
|
-
patch(n1, n2, renderer);
|
|
3923
|
+
patch(n1, n2, parent, renderer);
|
|
3895
3924
|
anchor = n2.elm;
|
|
3896
3925
|
}
|
|
3897
3926
|
else {
|
|
@@ -4225,13 +4254,6 @@ function fid(url) {
|
|
|
4225
4254
|
}
|
|
4226
4255
|
return url;
|
|
4227
4256
|
}
|
|
4228
|
-
/**
|
|
4229
|
-
* Map to store an index value assigned to any dynamic component reference ingested
|
|
4230
|
-
* by dc() api. This allows us to generate a unique unique per template per dynamic
|
|
4231
|
-
* component reference to avoid diffing algo mismatches.
|
|
4232
|
-
*/
|
|
4233
|
-
const DynamicImportedComponentMap = new Map();
|
|
4234
|
-
let dynamicImportedComponentCounter = 0;
|
|
4235
4257
|
/**
|
|
4236
4258
|
* create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
4237
4259
|
*/
|
|
@@ -4248,18 +4270,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
|
|
|
4248
4270
|
if (!isComponentConstructor(Ctor)) {
|
|
4249
4271
|
throw new Error(`Invalid LWC Constructor ${shared.toString(Ctor)} for custom element <${sel}>.`);
|
|
4250
4272
|
}
|
|
4251
|
-
|
|
4252
|
-
if (shared.isUndefined(idx)) {
|
|
4253
|
-
idx = dynamicImportedComponentCounter++;
|
|
4254
|
-
DynamicImportedComponentMap.set(Ctor, idx);
|
|
4255
|
-
}
|
|
4256
|
-
// the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
|
|
4257
|
-
// to identify different constructors as vnodes with different keys to avoid reusing the
|
|
4258
|
-
// element used for previous constructors.
|
|
4259
|
-
// Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
|
|
4260
|
-
// hoisting optimization.
|
|
4261
|
-
const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
|
|
4262
|
-
return c(sel, Ctor, newData, children);
|
|
4273
|
+
return c(sel, Ctor, data, children);
|
|
4263
4274
|
}
|
|
4264
4275
|
/**
|
|
4265
4276
|
* slow children collection marking mechanism. this API allows the compiler to signal
|
|
@@ -4735,7 +4746,7 @@ function getComponentRegisteredTemplate(Ctor) {
|
|
|
4735
4746
|
return signedTemplateMap.get(Ctor);
|
|
4736
4747
|
}
|
|
4737
4748
|
function getTemplateReactiveObserver(vm) {
|
|
4738
|
-
return
|
|
4749
|
+
return createReactiveObserver(() => {
|
|
4739
4750
|
const { isDirty } = vm;
|
|
4740
4751
|
if (shared.isFalse(isDirty)) {
|
|
4741
4752
|
markComponentAsDirty(vm);
|
|
@@ -5153,13 +5164,10 @@ function runRenderedCallback(vm) {
|
|
|
5153
5164
|
const {
|
|
5154
5165
|
def: {
|
|
5155
5166
|
renderedCallback
|
|
5156
|
-
},
|
|
5157
|
-
renderer: {
|
|
5158
|
-
ssr
|
|
5159
5167
|
}
|
|
5160
5168
|
} = vm;
|
|
5161
5169
|
|
|
5162
|
-
if (
|
|
5170
|
+
if (!process.env.IS_BROWSER) {
|
|
5163
5171
|
return;
|
|
5164
5172
|
}
|
|
5165
5173
|
|
|
@@ -5412,13 +5420,7 @@ function resetComponentRoot(vm) {
|
|
|
5412
5420
|
vm.velements = EmptyArray;
|
|
5413
5421
|
}
|
|
5414
5422
|
function scheduleRehydration(vm) {
|
|
5415
|
-
|
|
5416
|
-
renderer: {
|
|
5417
|
-
ssr
|
|
5418
|
-
}
|
|
5419
|
-
} = vm;
|
|
5420
|
-
|
|
5421
|
-
if (shared.isTrue(ssr) || shared.isTrue(vm.isScheduled)) {
|
|
5423
|
+
if (!process.env.IS_BROWSER || shared.isTrue(vm.isScheduled)) {
|
|
5422
5424
|
return;
|
|
5423
5425
|
}
|
|
5424
5426
|
|
|
@@ -5525,15 +5527,8 @@ class WireContextRegistrationEvent extends CustomEvent {
|
|
|
5525
5527
|
}
|
|
5526
5528
|
|
|
5527
5529
|
function createFieldDataCallback(vm, name) {
|
|
5528
|
-
const {
|
|
5529
|
-
cmpFields
|
|
5530
|
-
} = vm;
|
|
5531
5530
|
return value => {
|
|
5532
|
-
|
|
5533
|
-
// storing the value in the underlying storage
|
|
5534
|
-
cmpFields[name] = value;
|
|
5535
|
-
componentValueMutated(vm, name);
|
|
5536
|
-
}
|
|
5531
|
+
updateComponentValue(vm, name, value);
|
|
5537
5532
|
};
|
|
5538
5533
|
}
|
|
5539
5534
|
|
|
@@ -5550,7 +5545,7 @@ function createMethodDataCallback(vm, method) {
|
|
|
5550
5545
|
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
5551
5546
|
let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
|
|
5552
5547
|
|
|
5553
|
-
const ro =
|
|
5548
|
+
const ro = createReactiveObserver(() => {
|
|
5554
5549
|
if (hasPendingConfig === false) {
|
|
5555
5550
|
hasPendingConfig = true; // collect new config in the micro-task
|
|
5556
5551
|
|
|
@@ -5846,7 +5841,7 @@ function readonly(obj) {
|
|
|
5846
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.');
|
|
5847
5842
|
}
|
|
5848
5843
|
}
|
|
5849
|
-
return
|
|
5844
|
+
return getReadOnlyProxy(obj);
|
|
5850
5845
|
}
|
|
5851
5846
|
|
|
5852
5847
|
/*
|
|
@@ -6396,4 +6391,4 @@ exports.swapTemplate = swapTemplate;
|
|
|
6396
6391
|
exports.track = track;
|
|
6397
6392
|
exports.unwrap = unwrap;
|
|
6398
6393
|
exports.wire = wire;
|
|
6399
|
-
/* version: 2.
|
|
6394
|
+
/* version: 2.23.0 */
|