@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.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* proxy-compat-disable */
|
|
2
2
|
import { runtimeFlags } from '@lwc/features';
|
|
3
3
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
4
|
-
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1,
|
|
4
|
+
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, isFalse, isTrue, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, isNumber, StringReplace, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -213,11 +213,28 @@ class ReactiveObserver {
|
|
|
213
213
|
* SPDX-License-Identifier: MIT
|
|
214
214
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
215
215
|
*/
|
|
216
|
+
const DUMMY_REACTIVE_OBSERVER = {
|
|
217
|
+
observe(job) {
|
|
218
|
+
job();
|
|
219
|
+
},
|
|
220
|
+
reset() { },
|
|
221
|
+
link() { },
|
|
222
|
+
};
|
|
216
223
|
function componentValueMutated(vm, key) {
|
|
217
|
-
|
|
224
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
225
|
+
if (process.env.IS_BROWSER) {
|
|
226
|
+
valueMutated(vm.component, key);
|
|
227
|
+
}
|
|
218
228
|
}
|
|
219
229
|
function componentValueObserved(vm, key) {
|
|
220
|
-
|
|
230
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
231
|
+
if (process.env.IS_BROWSER) {
|
|
232
|
+
valueObserved(vm.component, key);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function createReactiveObserver(callback) {
|
|
236
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
237
|
+
return process.env.IS_BROWSER ? new ReactiveObserver(callback) : DUMMY_REACTIVE_OBSERVER;
|
|
221
238
|
}
|
|
222
239
|
|
|
223
240
|
/*
|
|
@@ -776,6 +793,14 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
|
776
793
|
defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
777
794
|
}
|
|
778
795
|
|
|
796
|
+
function updateComponentValue(vm, key, newValue) {
|
|
797
|
+
const { cmpFields } = vm;
|
|
798
|
+
if (newValue !== cmpFields[key]) {
|
|
799
|
+
cmpFields[key] = newValue;
|
|
800
|
+
componentValueMutated(vm, key);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
779
804
|
/**
|
|
780
805
|
* Copyright (C) 2017 salesforce.com, inc.
|
|
781
806
|
*/
|
|
@@ -1339,7 +1364,24 @@ const reactiveMembrane = new ObservableMembrane({
|
|
|
1339
1364
|
* change or being removed.
|
|
1340
1365
|
*/
|
|
1341
1366
|
function unwrap(value) {
|
|
1342
|
-
|
|
1367
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1368
|
+
return process.env.IS_BROWSER ? reactiveMembrane.unwrapProxy(value) : value;
|
|
1369
|
+
}
|
|
1370
|
+
function getReadOnlyProxy(value) {
|
|
1371
|
+
// We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
|
|
1372
|
+
// them from their parents. This applies to both the client and server.
|
|
1373
|
+
return reactiveMembrane.getReadOnlyProxy(value);
|
|
1374
|
+
}
|
|
1375
|
+
function getReactiveProxy(value) {
|
|
1376
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1377
|
+
return process.env.IS_BROWSER ? reactiveMembrane.getProxy(value) : value;
|
|
1378
|
+
}
|
|
1379
|
+
// Making the component instance a live value when using Locker to support expandos.
|
|
1380
|
+
function markLockerLiveObject(obj) {
|
|
1381
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1382
|
+
if (process.env.IS_BROWSER) {
|
|
1383
|
+
obj[lockerLivePropertyKey] = undefined;
|
|
1384
|
+
}
|
|
1343
1385
|
}
|
|
1344
1386
|
|
|
1345
1387
|
/*
|
|
@@ -1391,10 +1433,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
|
|
|
1391
1433
|
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1392
1434
|
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1393
1435
|
}
|
|
1394
|
-
|
|
1395
|
-
vm.cmpProps[propName] = newValue;
|
|
1396
|
-
componentValueMutated(vm, propName);
|
|
1397
|
-
}
|
|
1436
|
+
updateComponentValue(vm, propName, newValue);
|
|
1398
1437
|
return set.call(vm.elm, newValue);
|
|
1399
1438
|
},
|
|
1400
1439
|
};
|
|
@@ -1429,8 +1468,7 @@ const LightningElement = function () {
|
|
|
1429
1468
|
vm.setHook = setHook;
|
|
1430
1469
|
vm.getHook = getHook;
|
|
1431
1470
|
}
|
|
1432
|
-
|
|
1433
|
-
this[lockerLivePropertyKey] = undefined;
|
|
1471
|
+
markLockerLiveObject(this);
|
|
1434
1472
|
// Linking elm, shadow root and component with the VM.
|
|
1435
1473
|
associateVM(component, vm);
|
|
1436
1474
|
associateVM(elm, vm);
|
|
@@ -1690,16 +1728,67 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
1690
1728
|
},
|
|
1691
1729
|
set(newValue) {
|
|
1692
1730
|
const vm = getAssociatedVM(this);
|
|
1693
|
-
|
|
1694
|
-
vm.cmpFields[key] = newValue;
|
|
1695
|
-
componentValueMutated(vm, key);
|
|
1696
|
-
}
|
|
1731
|
+
updateComponentValue(vm, key, newValue);
|
|
1697
1732
|
},
|
|
1698
1733
|
enumerable: true,
|
|
1699
1734
|
configurable: true,
|
|
1700
1735
|
};
|
|
1701
1736
|
}
|
|
1702
1737
|
|
|
1738
|
+
/*
|
|
1739
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
1740
|
+
* All rights reserved.
|
|
1741
|
+
* SPDX-License-Identifier: MIT
|
|
1742
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1743
|
+
*/
|
|
1744
|
+
const DUMMY_ACCESSOR_REACTIVE_OBSERVER = {
|
|
1745
|
+
observe(job) {
|
|
1746
|
+
job();
|
|
1747
|
+
},
|
|
1748
|
+
reset() { },
|
|
1749
|
+
link() { },
|
|
1750
|
+
};
|
|
1751
|
+
class AccessorReactiveObserver extends ReactiveObserver {
|
|
1752
|
+
constructor(vm, set) {
|
|
1753
|
+
super(() => {
|
|
1754
|
+
if (isFalse(this.debouncing)) {
|
|
1755
|
+
this.debouncing = true;
|
|
1756
|
+
addCallbackToNextTick(() => {
|
|
1757
|
+
if (isTrue(this.debouncing)) {
|
|
1758
|
+
const { value } = this;
|
|
1759
|
+
const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
|
|
1760
|
+
set.call(component, value);
|
|
1761
|
+
// de-bouncing after the call to the original setter to prevent
|
|
1762
|
+
// infinity loop if the setter itself is mutating things that
|
|
1763
|
+
// were accessed during the previous invocation.
|
|
1764
|
+
this.debouncing = false;
|
|
1765
|
+
if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
|
|
1766
|
+
// immediate rehydration due to a setter driven mutation, otherwise
|
|
1767
|
+
// the component will get rendered on the second tick, which it is not
|
|
1768
|
+
// desirable.
|
|
1769
|
+
rerenderVM(vm);
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
});
|
|
1775
|
+
this.debouncing = false;
|
|
1776
|
+
}
|
|
1777
|
+
reset(value) {
|
|
1778
|
+
super.reset();
|
|
1779
|
+
this.debouncing = false;
|
|
1780
|
+
if (arguments.length > 0) {
|
|
1781
|
+
this.value = value;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
function createAccessorReactiveObserver(vm, set) {
|
|
1786
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1787
|
+
return process.env.IS_BROWSER
|
|
1788
|
+
? new AccessorReactiveObserver(vm, set)
|
|
1789
|
+
: DUMMY_ACCESSOR_REACTIVE_OBSERVER;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1703
1792
|
/*
|
|
1704
1793
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1705
1794
|
* All rights reserved.
|
|
@@ -1747,50 +1836,6 @@ function createPublicPropertyDescriptor(key) {
|
|
|
1747
1836
|
configurable: true
|
|
1748
1837
|
};
|
|
1749
1838
|
}
|
|
1750
|
-
class AccessorReactiveObserver extends ReactiveObserver {
|
|
1751
|
-
constructor(vm, set) {
|
|
1752
|
-
super(() => {
|
|
1753
|
-
if (isFalse(this.debouncing)) {
|
|
1754
|
-
this.debouncing = true;
|
|
1755
|
-
addCallbackToNextTick(() => {
|
|
1756
|
-
if (isTrue(this.debouncing)) {
|
|
1757
|
-
const {
|
|
1758
|
-
value
|
|
1759
|
-
} = this;
|
|
1760
|
-
const {
|
|
1761
|
-
isDirty: dirtyStateBeforeSetterCall,
|
|
1762
|
-
component,
|
|
1763
|
-
idx
|
|
1764
|
-
} = vm;
|
|
1765
|
-
set.call(component, value); // de-bouncing after the call to the original setter to prevent
|
|
1766
|
-
// infinity loop if the setter itself is mutating things that
|
|
1767
|
-
// were accessed during the previous invocation.
|
|
1768
|
-
|
|
1769
|
-
this.debouncing = false;
|
|
1770
|
-
|
|
1771
|
-
if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
|
|
1772
|
-
// immediate rehydration due to a setter driven mutation, otherwise
|
|
1773
|
-
// the component will get rendered on the second tick, which it is not
|
|
1774
|
-
// desirable.
|
|
1775
|
-
rerenderVM(vm);
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
});
|
|
1779
|
-
}
|
|
1780
|
-
});
|
|
1781
|
-
this.debouncing = false;
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
reset(value) {
|
|
1785
|
-
super.reset();
|
|
1786
|
-
this.debouncing = false;
|
|
1787
|
-
|
|
1788
|
-
if (arguments.length > 0) {
|
|
1789
|
-
this.value = value;
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
}
|
|
1794
1839
|
function createPublicAccessorDescriptor(key, descriptor) {
|
|
1795
1840
|
const {
|
|
1796
1841
|
get,
|
|
@@ -1831,7 +1876,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
1831
1876
|
let ro = vm.oar[key];
|
|
1832
1877
|
|
|
1833
1878
|
if (isUndefined$1(ro)) {
|
|
1834
|
-
ro = vm.oar[key] =
|
|
1879
|
+
ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
|
|
1835
1880
|
} // every time we invoke this setter from outside (through this wrapper setter)
|
|
1836
1881
|
// we should reset the value and then debounce just in case there is a pending
|
|
1837
1882
|
// invocation the next tick that is not longer relevant since the value is changing
|
|
@@ -1863,7 +1908,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
1863
1908
|
*/
|
|
1864
1909
|
function track(target) {
|
|
1865
1910
|
if (arguments.length === 1) {
|
|
1866
|
-
return
|
|
1911
|
+
return getReactiveProxy(target);
|
|
1867
1912
|
}
|
|
1868
1913
|
if (process.env.NODE_ENV !== 'production') {
|
|
1869
1914
|
assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
|
|
@@ -1884,11 +1929,8 @@ function internalTrackDecorator(key) {
|
|
|
1884
1929
|
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
1885
1930
|
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
1886
1931
|
}
|
|
1887
|
-
const reactiveOrAnyValue =
|
|
1888
|
-
|
|
1889
|
-
vm.cmpFields[key] = reactiveOrAnyValue;
|
|
1890
|
-
componentValueMutated(vm, key);
|
|
1891
|
-
}
|
|
1932
|
+
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
1933
|
+
updateComponentValue(vm, key, reactiveOrAnyValue);
|
|
1892
1934
|
},
|
|
1893
1935
|
enumerable: true,
|
|
1894
1936
|
configurable: true,
|
|
@@ -1927,10 +1969,7 @@ function internalWireFieldDecorator(key) {
|
|
|
1927
1969
|
* letting the author to do the wrong thing, but it will keep our
|
|
1928
1970
|
* system to be backward compatible.
|
|
1929
1971
|
*/
|
|
1930
|
-
|
|
1931
|
-
vm.cmpFields[key] = value;
|
|
1932
|
-
componentValueMutated(vm, key);
|
|
1933
|
-
}
|
|
1972
|
+
updateComponentValue(vm, key, value);
|
|
1934
1973
|
},
|
|
1935
1974
|
enumerable: true,
|
|
1936
1975
|
configurable: true,
|
|
@@ -2276,7 +2315,7 @@ function createSetter(key) {
|
|
|
2276
2315
|
fn = cachedSetterByKey[key] = function (newValue) {
|
|
2277
2316
|
const vm = getAssociatedVM(this);
|
|
2278
2317
|
const { setHook } = vm;
|
|
2279
|
-
newValue =
|
|
2318
|
+
newValue = getReadOnlyProxy(newValue);
|
|
2280
2319
|
setHook(vm.component, key, newValue);
|
|
2281
2320
|
};
|
|
2282
2321
|
}
|
|
@@ -3019,13 +3058,13 @@ function getNearestNativeShadowComponent(vm) {
|
|
|
3019
3058
|
return owner;
|
|
3020
3059
|
}
|
|
3021
3060
|
function createStylesheet(vm, stylesheets) {
|
|
3022
|
-
const { renderMode, shadowMode, renderer: {
|
|
3061
|
+
const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
|
|
3023
3062
|
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3024
3063
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3025
3064
|
insertStylesheet(stylesheets[i]);
|
|
3026
3065
|
}
|
|
3027
3066
|
}
|
|
3028
|
-
else if (
|
|
3067
|
+
else if (!process.env.IS_BROWSER || vm.hydrated) {
|
|
3029
3068
|
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3030
3069
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3031
3070
|
// the first time the VM renders.
|
|
@@ -3326,7 +3365,7 @@ function patchChildren(c1, c2, parent, renderer) {
|
|
|
3326
3365
|
updateStaticChildren(c1, c2, parent, renderer);
|
|
3327
3366
|
}
|
|
3328
3367
|
}
|
|
3329
|
-
function patch(n1, n2, renderer) {
|
|
3368
|
+
function patch(n1, n2, parent, renderer) {
|
|
3330
3369
|
var _a, _b;
|
|
3331
3370
|
if (n1 === n2) {
|
|
3332
3371
|
return;
|
|
@@ -3355,7 +3394,7 @@ function patch(n1, n2, renderer) {
|
|
|
3355
3394
|
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3356
3395
|
break;
|
|
3357
3396
|
case 3 /* VNodeType.CustomElement */:
|
|
3358
|
-
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3397
|
+
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3359
3398
|
break;
|
|
3360
3399
|
}
|
|
3361
3400
|
}
|
|
@@ -3416,10 +3455,11 @@ function mountElement(vnode, parent, anchor, renderer) {
|
|
|
3416
3455
|
const { sel, owner, data: { svg }, } = vnode;
|
|
3417
3456
|
const { createElement } = renderer;
|
|
3418
3457
|
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
3419
|
-
const elm = createElement(sel, namespace);
|
|
3458
|
+
const elm = (vnode.elm = createElement(sel, namespace));
|
|
3420
3459
|
linkNodeToShadow(elm, owner, renderer);
|
|
3421
|
-
|
|
3422
|
-
|
|
3460
|
+
applyStyleScoping(elm, owner, renderer);
|
|
3461
|
+
applyDomManual(elm, vnode);
|
|
3462
|
+
applyElementRestrictions(elm, vnode);
|
|
3423
3463
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3424
3464
|
insertNode(elm, parent, anchor, renderer);
|
|
3425
3465
|
mountVNodes(vnode.children, elm, renderer, null);
|
|
@@ -3434,6 +3474,7 @@ function mountStatic(vnode, parent, anchor, renderer) {
|
|
|
3434
3474
|
const { cloneNode, isSyntheticShadowDefined } = renderer;
|
|
3435
3475
|
const elm = (vnode.elm = cloneNode(vnode.fragment, true));
|
|
3436
3476
|
linkNodeToShadow(elm, owner, renderer);
|
|
3477
|
+
applyElementRestrictions(elm, vnode);
|
|
3437
3478
|
// Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
3438
3479
|
const { renderMode, shadowMode } = owner;
|
|
3439
3480
|
if (isSyntheticShadowDefined) {
|
|
@@ -3441,10 +3482,6 @@ function mountStatic(vnode, parent, anchor, renderer) {
|
|
|
3441
3482
|
elm[KEY__SHADOW_STATIC] = true;
|
|
3442
3483
|
}
|
|
3443
3484
|
}
|
|
3444
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3445
|
-
const isLight = renderMode === 0 /* RenderMode.Light */;
|
|
3446
|
-
patchElementWithRestrictions(elm, { isPortal: false, isLight });
|
|
3447
|
-
}
|
|
3448
3485
|
insertNode(elm, parent, anchor, renderer);
|
|
3449
3486
|
}
|
|
3450
3487
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
@@ -3461,9 +3498,10 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3461
3498
|
// the custom element from the registry is expecting an upgrade callback
|
|
3462
3499
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
3463
3500
|
});
|
|
3464
|
-
linkNodeToShadow(elm, owner, renderer);
|
|
3465
3501
|
vnode.elm = elm;
|
|
3466
3502
|
vnode.vm = vm;
|
|
3503
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3504
|
+
applyStyleScoping(elm, owner, renderer);
|
|
3467
3505
|
if (vm) {
|
|
3468
3506
|
allocateChildren(vnode, vm);
|
|
3469
3507
|
}
|
|
@@ -3483,22 +3521,32 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3483
3521
|
appendVM(vm);
|
|
3484
3522
|
}
|
|
3485
3523
|
}
|
|
3486
|
-
function patchCustomElement(n1, n2, renderer) {
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
allocateChildren(n2, vm);
|
|
3524
|
+
function patchCustomElement(n1, n2, parent, renderer) {
|
|
3525
|
+
if (n1.ctor !== n2.ctor) {
|
|
3526
|
+
// If the constructor, unmount the current component and mount a new one using the new
|
|
3527
|
+
// constructor.
|
|
3528
|
+
const anchor = renderer.nextSibling(n1.elm);
|
|
3529
|
+
unmount(n1, parent, renderer, true);
|
|
3530
|
+
mountCustomElement(n2, parent, anchor, renderer);
|
|
3494
3531
|
}
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3532
|
+
else {
|
|
3533
|
+
// Otherwise patch the existing component with new props/attrs/etc.
|
|
3534
|
+
const elm = (n2.elm = n1.elm);
|
|
3535
|
+
const vm = (n2.vm = n1.vm);
|
|
3536
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3537
|
+
if (!isUndefined$1(vm)) {
|
|
3538
|
+
// in fallback mode, the allocation will always set children to
|
|
3539
|
+
// empty and delegate the real allocation to the slot elements
|
|
3540
|
+
allocateChildren(n2, vm);
|
|
3541
|
+
}
|
|
3542
|
+
// in fallback mode, the children will be always empty, so, nothing
|
|
3543
|
+
// will happen, but in native, it does allocate the light dom
|
|
3544
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3545
|
+
if (!isUndefined$1(vm)) {
|
|
3546
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3547
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
3548
|
+
rerenderVM(vm);
|
|
3549
|
+
}
|
|
3502
3550
|
}
|
|
3503
3551
|
}
|
|
3504
3552
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
@@ -3547,22 +3595,6 @@ function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, en
|
|
|
3547
3595
|
function isVNode(vnode) {
|
|
3548
3596
|
return vnode != null;
|
|
3549
3597
|
}
|
|
3550
|
-
function observeElementChildNodes(elm) {
|
|
3551
|
-
elm.$domManual$ = true;
|
|
3552
|
-
}
|
|
3553
|
-
function setElementShadowToken(elm, token) {
|
|
3554
|
-
elm.$shadowToken$ = token;
|
|
3555
|
-
}
|
|
3556
|
-
// Set the scope token class for *.scoped.css styles
|
|
3557
|
-
function setScopeTokenClassIfNecessary(elm, owner, renderer) {
|
|
3558
|
-
const token = getScopeTokenClass(owner);
|
|
3559
|
-
if (!isNull(token)) {
|
|
3560
|
-
const { getClassList } = renderer;
|
|
3561
|
-
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3562
|
-
// probably we should have a renderer api for just the add operation
|
|
3563
|
-
getClassList(elm).add(token);
|
|
3564
|
-
}
|
|
3565
|
-
}
|
|
3566
3598
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
3567
3599
|
const { renderRoot, renderMode, shadowMode } = owner;
|
|
3568
3600
|
const { isSyntheticShadowDefined } = renderer;
|
|
@@ -3615,31 +3647,37 @@ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
|
3615
3647
|
patchAttributes(oldVnode, vnode, renderer);
|
|
3616
3648
|
patchProps(oldVnode, vnode, renderer);
|
|
3617
3649
|
}
|
|
3618
|
-
function
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
if (
|
|
3622
|
-
const {
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3650
|
+
function applyStyleScoping(elm, owner, renderer) {
|
|
3651
|
+
// Set the class name for `*.scoped.css` style scoping.
|
|
3652
|
+
const scopeToken = getScopeTokenClass(owner);
|
|
3653
|
+
if (!isNull(scopeToken)) {
|
|
3654
|
+
const { getClassList } = renderer;
|
|
3655
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3656
|
+
// probably we should have a renderer api for just the add operation
|
|
3657
|
+
getClassList(elm).add(scopeToken);
|
|
3658
|
+
}
|
|
3659
|
+
// Set property element for synthetic shadow DOM style scoping.
|
|
3660
|
+
const { stylesheetToken: syntheticToken } = owner.context;
|
|
3661
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
|
|
3662
|
+
elm.$shadowToken$ = syntheticToken;
|
|
3663
|
+
}
|
|
3664
|
+
}
|
|
3665
|
+
function applyDomManual(elm, vnode) {
|
|
3666
|
+
var _a;
|
|
3667
|
+
const { owner, data: { context }, } = vnode;
|
|
3668
|
+
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 */) {
|
|
3669
|
+
elm.$domManual$ = true;
|
|
3635
3670
|
}
|
|
3671
|
+
}
|
|
3672
|
+
function applyElementRestrictions(elm, vnode) {
|
|
3673
|
+
var _a, _b;
|
|
3636
3674
|
if (process.env.NODE_ENV !== 'production') {
|
|
3637
|
-
const
|
|
3638
|
-
const
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3675
|
+
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 */;
|
|
3676
|
+
const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
|
|
3677
|
+
patchElementWithRestrictions(elm, {
|
|
3678
|
+
isPortal,
|
|
3679
|
+
isLight,
|
|
3680
|
+
});
|
|
3643
3681
|
}
|
|
3644
3682
|
}
|
|
3645
3683
|
function allocateChildren(vnode, vm) {
|
|
@@ -3674,15 +3712,6 @@ function createViewModelHook(elm, vnode, renderer) {
|
|
|
3674
3712
|
return vm;
|
|
3675
3713
|
}
|
|
3676
3714
|
const { sel, mode, ctor, owner } = vnode;
|
|
3677
|
-
setScopeTokenClassIfNecessary(elm, owner, renderer);
|
|
3678
|
-
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3679
|
-
const { stylesheetToken } = owner.context;
|
|
3680
|
-
// when running in synthetic shadow mode, we need to set the shadowToken value
|
|
3681
|
-
// into each element from the template, so they can be styled accordingly.
|
|
3682
|
-
if (!isUndefined$1(stylesheetToken)) {
|
|
3683
|
-
setElementShadowToken(elm, stylesheetToken);
|
|
3684
|
-
}
|
|
3685
|
-
}
|
|
3686
3715
|
vm = createVM(elm, ctor, renderer, {
|
|
3687
3716
|
mode,
|
|
3688
3717
|
owner,
|
|
@@ -3787,25 +3816,25 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
3787
3816
|
newEndVnode = newCh[--newEndIdx];
|
|
3788
3817
|
}
|
|
3789
3818
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
3790
|
-
patch(oldStartVnode, newStartVnode, renderer);
|
|
3819
|
+
patch(oldStartVnode, newStartVnode, parent, renderer);
|
|
3791
3820
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3792
3821
|
newStartVnode = newCh[++newStartIdx];
|
|
3793
3822
|
}
|
|
3794
3823
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
3795
|
-
patch(oldEndVnode, newEndVnode, renderer);
|
|
3824
|
+
patch(oldEndVnode, newEndVnode, parent, renderer);
|
|
3796
3825
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3797
3826
|
newEndVnode = newCh[--newEndIdx];
|
|
3798
3827
|
}
|
|
3799
3828
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
3800
3829
|
// Vnode moved right
|
|
3801
|
-
patch(oldStartVnode, newEndVnode, renderer);
|
|
3830
|
+
patch(oldStartVnode, newEndVnode, parent, renderer);
|
|
3802
3831
|
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
3803
3832
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
3804
3833
|
newEndVnode = newCh[--newEndIdx];
|
|
3805
3834
|
}
|
|
3806
3835
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
3807
3836
|
// Vnode moved left
|
|
3808
|
-
patch(oldEndVnode, newStartVnode, renderer);
|
|
3837
|
+
patch(oldEndVnode, newStartVnode, parent, renderer);
|
|
3809
3838
|
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
3810
3839
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
3811
3840
|
newStartVnode = newCh[++newStartIdx];
|
|
@@ -3828,7 +3857,7 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
3828
3857
|
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
3829
3858
|
}
|
|
3830
3859
|
else {
|
|
3831
|
-
patch(elmToMove, newStartVnode, renderer);
|
|
3860
|
+
patch(elmToMove, newStartVnode, parent, renderer);
|
|
3832
3861
|
// Delete the old child, but copy the array since it is read-only.
|
|
3833
3862
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
3834
3863
|
// so we only care about the `oldCh` object inside this function.
|
|
@@ -3888,7 +3917,7 @@ function updateStaticChildren(c1, c2, parent, renderer) {
|
|
|
3888
3917
|
if (isVNode(n1)) {
|
|
3889
3918
|
if (isVNode(n2)) {
|
|
3890
3919
|
// both vnodes are equivalent, and we just need to patch them
|
|
3891
|
-
patch(n1, n2, renderer);
|
|
3920
|
+
patch(n1, n2, parent, renderer);
|
|
3892
3921
|
anchor = n2.elm;
|
|
3893
3922
|
}
|
|
3894
3923
|
else {
|
|
@@ -4222,13 +4251,6 @@ function fid(url) {
|
|
|
4222
4251
|
}
|
|
4223
4252
|
return url;
|
|
4224
4253
|
}
|
|
4225
|
-
/**
|
|
4226
|
-
* Map to store an index value assigned to any dynamic component reference ingested
|
|
4227
|
-
* by dc() api. This allows us to generate a unique unique per template per dynamic
|
|
4228
|
-
* component reference to avoid diffing algo mismatches.
|
|
4229
|
-
*/
|
|
4230
|
-
const DynamicImportedComponentMap = new Map();
|
|
4231
|
-
let dynamicImportedComponentCounter = 0;
|
|
4232
4254
|
/**
|
|
4233
4255
|
* create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
4234
4256
|
*/
|
|
@@ -4245,18 +4267,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
|
|
|
4245
4267
|
if (!isComponentConstructor(Ctor)) {
|
|
4246
4268
|
throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
|
|
4247
4269
|
}
|
|
4248
|
-
|
|
4249
|
-
if (isUndefined$1(idx)) {
|
|
4250
|
-
idx = dynamicImportedComponentCounter++;
|
|
4251
|
-
DynamicImportedComponentMap.set(Ctor, idx);
|
|
4252
|
-
}
|
|
4253
|
-
// the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
|
|
4254
|
-
// to identify different constructors as vnodes with different keys to avoid reusing the
|
|
4255
|
-
// element used for previous constructors.
|
|
4256
|
-
// Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
|
|
4257
|
-
// hoisting optimization.
|
|
4258
|
-
const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
|
|
4259
|
-
return c(sel, Ctor, newData, children);
|
|
4270
|
+
return c(sel, Ctor, data, children);
|
|
4260
4271
|
}
|
|
4261
4272
|
/**
|
|
4262
4273
|
* slow children collection marking mechanism. this API allows the compiler to signal
|
|
@@ -4732,7 +4743,7 @@ function getComponentRegisteredTemplate(Ctor) {
|
|
|
4732
4743
|
return signedTemplateMap.get(Ctor);
|
|
4733
4744
|
}
|
|
4734
4745
|
function getTemplateReactiveObserver(vm) {
|
|
4735
|
-
return
|
|
4746
|
+
return createReactiveObserver(() => {
|
|
4736
4747
|
const { isDirty } = vm;
|
|
4737
4748
|
if (isFalse(isDirty)) {
|
|
4738
4749
|
markComponentAsDirty(vm);
|
|
@@ -5150,13 +5161,10 @@ function runRenderedCallback(vm) {
|
|
|
5150
5161
|
const {
|
|
5151
5162
|
def: {
|
|
5152
5163
|
renderedCallback
|
|
5153
|
-
},
|
|
5154
|
-
renderer: {
|
|
5155
|
-
ssr
|
|
5156
5164
|
}
|
|
5157
5165
|
} = vm;
|
|
5158
5166
|
|
|
5159
|
-
if (
|
|
5167
|
+
if (!process.env.IS_BROWSER) {
|
|
5160
5168
|
return;
|
|
5161
5169
|
}
|
|
5162
5170
|
|
|
@@ -5409,13 +5417,7 @@ function resetComponentRoot(vm) {
|
|
|
5409
5417
|
vm.velements = EmptyArray;
|
|
5410
5418
|
}
|
|
5411
5419
|
function scheduleRehydration(vm) {
|
|
5412
|
-
|
|
5413
|
-
renderer: {
|
|
5414
|
-
ssr
|
|
5415
|
-
}
|
|
5416
|
-
} = vm;
|
|
5417
|
-
|
|
5418
|
-
if (isTrue(ssr) || isTrue(vm.isScheduled)) {
|
|
5420
|
+
if (!process.env.IS_BROWSER || isTrue(vm.isScheduled)) {
|
|
5419
5421
|
return;
|
|
5420
5422
|
}
|
|
5421
5423
|
|
|
@@ -5522,15 +5524,8 @@ class WireContextRegistrationEvent extends CustomEvent {
|
|
|
5522
5524
|
}
|
|
5523
5525
|
|
|
5524
5526
|
function createFieldDataCallback(vm, name) {
|
|
5525
|
-
const {
|
|
5526
|
-
cmpFields
|
|
5527
|
-
} = vm;
|
|
5528
5527
|
return value => {
|
|
5529
|
-
|
|
5530
|
-
// storing the value in the underlying storage
|
|
5531
|
-
cmpFields[name] = value;
|
|
5532
|
-
componentValueMutated(vm, name);
|
|
5533
|
-
}
|
|
5528
|
+
updateComponentValue(vm, name, value);
|
|
5534
5529
|
};
|
|
5535
5530
|
}
|
|
5536
5531
|
|
|
@@ -5547,7 +5542,7 @@ function createMethodDataCallback(vm, method) {
|
|
|
5547
5542
|
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
5548
5543
|
let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
|
|
5549
5544
|
|
|
5550
|
-
const ro =
|
|
5545
|
+
const ro = createReactiveObserver(() => {
|
|
5551
5546
|
if (hasPendingConfig === false) {
|
|
5552
5547
|
hasPendingConfig = true; // collect new config in the micro-task
|
|
5553
5548
|
|
|
@@ -5843,7 +5838,7 @@ function readonly(obj) {
|
|
|
5843
5838
|
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.');
|
|
5844
5839
|
}
|
|
5845
5840
|
}
|
|
5846
|
-
return
|
|
5841
|
+
return getReadOnlyProxy(obj);
|
|
5847
5842
|
}
|
|
5848
5843
|
|
|
5849
5844
|
/*
|
|
@@ -6356,4 +6351,4 @@ function getComponentConstructor(elm) {
|
|
|
6356
6351
|
}
|
|
6357
6352
|
|
|
6358
6353
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6359
|
-
/* version: 2.
|
|
6354
|
+
/* version: 2.23.0 */
|