@lwc/engine-core 2.22.0 → 2.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/engine-core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* proxy-compat-disable */
|
|
2
|
-
import {
|
|
2
|
+
import { lwcRuntimeFlags } from '@lwc/features';
|
|
3
3
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
4
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
|
|
|
@@ -15,7 +15,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
|
15
15
|
window.addEventListener('test-dummy-flag', () => {
|
|
16
16
|
let hasFlag = false;
|
|
17
17
|
|
|
18
|
-
if (
|
|
18
|
+
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
19
19
|
hasFlag = true;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -793,6 +793,14 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
|
793
793
|
defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
794
794
|
}
|
|
795
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
|
+
|
|
796
804
|
/**
|
|
797
805
|
* Copyright (C) 2017 salesforce.com, inc.
|
|
798
806
|
*/
|
|
@@ -1425,10 +1433,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
|
|
|
1425
1433
|
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1426
1434
|
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1427
1435
|
}
|
|
1428
|
-
|
|
1429
|
-
vm.cmpProps[propName] = newValue;
|
|
1430
|
-
componentValueMutated(vm, propName);
|
|
1431
|
-
}
|
|
1436
|
+
updateComponentValue(vm, propName, newValue);
|
|
1432
1437
|
return set.call(vm.elm, newValue);
|
|
1433
1438
|
},
|
|
1434
1439
|
};
|
|
@@ -1723,10 +1728,7 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
1723
1728
|
},
|
|
1724
1729
|
set(newValue) {
|
|
1725
1730
|
const vm = getAssociatedVM(this);
|
|
1726
|
-
|
|
1727
|
-
vm.cmpFields[key] = newValue;
|
|
1728
|
-
componentValueMutated(vm, key);
|
|
1729
|
-
}
|
|
1731
|
+
updateComponentValue(vm, key, newValue);
|
|
1730
1732
|
},
|
|
1731
1733
|
enumerable: true,
|
|
1732
1734
|
configurable: true,
|
|
@@ -1870,7 +1872,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
1870
1872
|
}
|
|
1871
1873
|
|
|
1872
1874
|
if (set) {
|
|
1873
|
-
if (
|
|
1875
|
+
if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
|
|
1874
1876
|
let ro = vm.oar[key];
|
|
1875
1877
|
|
|
1876
1878
|
if (isUndefined$1(ro)) {
|
|
@@ -1928,10 +1930,7 @@ function internalTrackDecorator(key) {
|
|
|
1928
1930
|
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
1929
1931
|
}
|
|
1930
1932
|
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
1931
|
-
|
|
1932
|
-
vm.cmpFields[key] = reactiveOrAnyValue;
|
|
1933
|
-
componentValueMutated(vm, key);
|
|
1934
|
-
}
|
|
1933
|
+
updateComponentValue(vm, key, reactiveOrAnyValue);
|
|
1935
1934
|
},
|
|
1936
1935
|
enumerable: true,
|
|
1937
1936
|
configurable: true,
|
|
@@ -1970,10 +1969,7 @@ function internalWireFieldDecorator(key) {
|
|
|
1970
1969
|
* letting the author to do the wrong thing, but it will keep our
|
|
1971
1970
|
* system to be backward compatible.
|
|
1972
1971
|
*/
|
|
1973
|
-
|
|
1974
|
-
vm.cmpFields[key] = value;
|
|
1975
|
-
componentValueMutated(vm, key);
|
|
1976
|
-
}
|
|
1972
|
+
updateComponentValue(vm, key, value);
|
|
1977
1973
|
},
|
|
1978
1974
|
enumerable: true,
|
|
1979
1975
|
configurable: true,
|
|
@@ -2528,7 +2524,7 @@ function getTemplateOrSwappedTemplate(tpl) {
|
|
|
2528
2524
|
throw new ReferenceError();
|
|
2529
2525
|
}
|
|
2530
2526
|
|
|
2531
|
-
if (
|
|
2527
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2532
2528
|
const visited = new Set();
|
|
2533
2529
|
|
|
2534
2530
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
@@ -2545,7 +2541,7 @@ function getComponentOrSwappedComponent(Ctor) {
|
|
|
2545
2541
|
throw new ReferenceError();
|
|
2546
2542
|
}
|
|
2547
2543
|
|
|
2548
|
-
if (
|
|
2544
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2549
2545
|
const visited = new Set();
|
|
2550
2546
|
|
|
2551
2547
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
@@ -2562,7 +2558,7 @@ function getStyleOrSwappedStyle(style) {
|
|
|
2562
2558
|
throw new ReferenceError();
|
|
2563
2559
|
}
|
|
2564
2560
|
|
|
2565
|
-
if (
|
|
2561
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2566
2562
|
const visited = new Set();
|
|
2567
2563
|
|
|
2568
2564
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
@@ -2579,7 +2575,7 @@ function setActiveVM(vm) {
|
|
|
2579
2575
|
throw new ReferenceError();
|
|
2580
2576
|
}
|
|
2581
2577
|
|
|
2582
|
-
if (
|
|
2578
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2583
2579
|
// tracking active component
|
|
2584
2580
|
const Ctor = vm.def.ctor;
|
|
2585
2581
|
let componentVMs = activeComponents.get(Ctor);
|
|
@@ -2636,7 +2632,7 @@ function removeActiveVM(vm) {
|
|
|
2636
2632
|
throw new ReferenceError();
|
|
2637
2633
|
}
|
|
2638
2634
|
|
|
2639
|
-
if (
|
|
2635
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2640
2636
|
// tracking inactive component
|
|
2641
2637
|
const Ctor = vm.def.ctor;
|
|
2642
2638
|
let list = activeComponents.get(Ctor);
|
|
@@ -2683,7 +2679,7 @@ function swapTemplate(oldTpl, newTpl) {
|
|
|
2683
2679
|
}
|
|
2684
2680
|
}
|
|
2685
2681
|
|
|
2686
|
-
if (!
|
|
2682
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2687
2683
|
throw new Error('HMR is not enabled');
|
|
2688
2684
|
}
|
|
2689
2685
|
|
|
@@ -2699,7 +2695,7 @@ function swapComponent(oldComponent, newComponent) {
|
|
|
2699
2695
|
}
|
|
2700
2696
|
}
|
|
2701
2697
|
|
|
2702
|
-
if (!
|
|
2698
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2703
2699
|
throw new Error('HMR is not enabled');
|
|
2704
2700
|
}
|
|
2705
2701
|
|
|
@@ -2713,7 +2709,7 @@ function swapStyle(oldStyle, newStyle) {
|
|
|
2713
2709
|
return rehydrateHotStyle(oldStyle);
|
|
2714
2710
|
}
|
|
2715
2711
|
|
|
2716
|
-
if (!
|
|
2712
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2717
2713
|
throw new Error('HMR is not enabled');
|
|
2718
2714
|
}
|
|
2719
2715
|
|
|
@@ -3062,13 +3058,13 @@ function getNearestNativeShadowComponent(vm) {
|
|
|
3062
3058
|
return owner;
|
|
3063
3059
|
}
|
|
3064
3060
|
function createStylesheet(vm, stylesheets) {
|
|
3065
|
-
const { renderMode, shadowMode, renderer: {
|
|
3061
|
+
const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
|
|
3066
3062
|
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3067
3063
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3068
3064
|
insertStylesheet(stylesheets[i]);
|
|
3069
3065
|
}
|
|
3070
3066
|
}
|
|
3071
|
-
else if (
|
|
3067
|
+
else if (!process.env.IS_BROWSER || vm.hydrated) {
|
|
3072
3068
|
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3073
3069
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3074
3070
|
// the first time the VM renders.
|
|
@@ -3093,30 +3089,67 @@ function createStylesheet(vm, stylesheets) {
|
|
|
3093
3089
|
* SPDX-License-Identifier: MIT
|
|
3094
3090
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3095
3091
|
*/
|
|
3092
|
+
|
|
3093
|
+
function checkHasVM(elm) {
|
|
3094
|
+
const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
3095
|
+
|
|
3096
|
+
if (process.env.NODE_ENV !== 'production' && !hasVM) {
|
|
3097
|
+
// Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
|
|
3098
|
+
// we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
|
|
3099
|
+
logError(`VM for tag name "${elm.tagName.toLowerCase()}" is undefined. ` + `This indicates that an element was created with this tag name, ` + `which is already reserved by an LWC component. Use lwc.createElement ` + `instead to create elements.`);
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
return hasVM;
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3096
3105
|
function getUpgradableConstructor(tagName, renderer) {
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3106
|
+
const {
|
|
3107
|
+
getCustomElement,
|
|
3108
|
+
HTMLElementExported: RendererHTMLElement,
|
|
3109
|
+
defineCustomElement
|
|
3110
|
+
} = renderer; // Should never get a tag with upper case letter at this point, the compiler should
|
|
3111
|
+
// produce only tags with lowercase letters
|
|
3112
|
+
// But, for backwards compatibility, we will lower case the tagName
|
|
3113
|
+
|
|
3114
|
+
tagName = tagName.toLowerCase();
|
|
3115
|
+
let CE = getCustomElement(tagName);
|
|
3116
|
+
|
|
3117
|
+
if (!isUndefined$1(CE)) {
|
|
3118
|
+
return CE;
|
|
3119
|
+
}
|
|
3120
|
+
/**
|
|
3121
|
+
* LWC Upgradable Element reference to an element that was created
|
|
3122
|
+
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3123
|
+
*/
|
|
3124
|
+
|
|
3125
|
+
|
|
3126
|
+
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3127
|
+
constructor(upgradeCallback) {
|
|
3128
|
+
super();
|
|
3129
|
+
|
|
3130
|
+
if (isFunction$1(upgradeCallback)) {
|
|
3131
|
+
upgradeCallback(this); // nothing to do with the result for now
|
|
3132
|
+
}
|
|
3105
3133
|
}
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
CE =
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
upgradeCallback(this); // nothing to do with the result for now
|
|
3115
|
-
}
|
|
3116
|
-
}
|
|
3134
|
+
|
|
3135
|
+
};
|
|
3136
|
+
|
|
3137
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3138
|
+
CE.prototype.connectedCallback = function () {
|
|
3139
|
+
if (checkHasVM(this)) {
|
|
3140
|
+
connectRootElement(this);
|
|
3141
|
+
}
|
|
3117
3142
|
};
|
|
3118
|
-
|
|
3119
|
-
|
|
3143
|
+
|
|
3144
|
+
CE.prototype.disconnectedCallback = function () {
|
|
3145
|
+
if (checkHasVM(this)) {
|
|
3146
|
+
disconnectRootElement(this);
|
|
3147
|
+
}
|
|
3148
|
+
};
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3151
|
+
defineCustomElement(tagName, CE);
|
|
3152
|
+
return CE;
|
|
3120
3153
|
}
|
|
3121
3154
|
|
|
3122
3155
|
/*
|
|
@@ -3204,6 +3237,14 @@ function patchProps(oldVnode, vnode, renderer) {
|
|
|
3204
3237
|
// different than the one previously set.
|
|
3205
3238
|
if (isFirstPatch ||
|
|
3206
3239
|
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
|
|
3240
|
+
// Additional verification if properties are supported by the element
|
|
3241
|
+
// Validation relies on html properties and public properties being defined on the element,
|
|
3242
|
+
// SSR has its own custom validation.
|
|
3243
|
+
if (process.env.IS_BROWSER && process.env.NODE_ENV !== 'production') {
|
|
3244
|
+
if (!(key in elm)) {
|
|
3245
|
+
logWarn(`Unknown public property "${key}" of element <${elm.tagName.toLowerCase()}>. This is either a typo on the corresponding attribute "${htmlPropertyToAttribute(key)}", or the attribute does not exist in this browser or DOM implementation.`);
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3207
3248
|
setProperty(elm, key, cur);
|
|
3208
3249
|
}
|
|
3209
3250
|
}
|
|
@@ -3362,569 +3403,802 @@ function applyStaticStyleAttribute(vnode, renderer) {
|
|
|
3362
3403
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3363
3404
|
*/
|
|
3364
3405
|
function patchChildren(c1, c2, parent, renderer) {
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
}
|
|
3406
|
+
if (hasDynamicChildren(c2)) {
|
|
3407
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
3408
|
+
} else {
|
|
3409
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
3410
|
+
}
|
|
3371
3411
|
}
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
break;
|
|
3390
|
-
case 1 /* VNodeType.Comment */:
|
|
3391
|
-
// VComment has no special capability, fallback to the owner's renderer
|
|
3392
|
-
patchComment(n1, n2, renderer);
|
|
3393
|
-
break;
|
|
3394
|
-
case 4 /* VNodeType.Static */:
|
|
3395
|
-
n2.elm = n1.elm;
|
|
3396
|
-
break;
|
|
3397
|
-
case 2 /* VNodeType.Element */:
|
|
3398
|
-
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3399
|
-
break;
|
|
3400
|
-
case 3 /* VNodeType.CustomElement */:
|
|
3401
|
-
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3402
|
-
break;
|
|
3412
|
+
|
|
3413
|
+
function patch(n1, n2, parent, renderer) {
|
|
3414
|
+
var _a, _b;
|
|
3415
|
+
|
|
3416
|
+
if (n1 === n2) {
|
|
3417
|
+
return;
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3420
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3421
|
+
if (!isSameVnode(n1, n2)) {
|
|
3422
|
+
throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
|
|
3423
|
+
sel: n1.sel,
|
|
3424
|
+
key: n1.key
|
|
3425
|
+
}) + ', ' + JSON.stringify({
|
|
3426
|
+
sel: n2.sel,
|
|
3427
|
+
key: n2.key
|
|
3428
|
+
}));
|
|
3403
3429
|
}
|
|
3430
|
+
}
|
|
3431
|
+
|
|
3432
|
+
switch (n2.type) {
|
|
3433
|
+
case 0
|
|
3434
|
+
/* VNodeType.Text */
|
|
3435
|
+
:
|
|
3436
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3437
|
+
patchText(n1, n2, renderer);
|
|
3438
|
+
break;
|
|
3439
|
+
|
|
3440
|
+
case 1
|
|
3441
|
+
/* VNodeType.Comment */
|
|
3442
|
+
:
|
|
3443
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3444
|
+
patchComment(n1, n2, renderer);
|
|
3445
|
+
break;
|
|
3446
|
+
|
|
3447
|
+
case 4
|
|
3448
|
+
/* VNodeType.Static */
|
|
3449
|
+
:
|
|
3450
|
+
n2.elm = n1.elm;
|
|
3451
|
+
break;
|
|
3452
|
+
|
|
3453
|
+
case 2
|
|
3454
|
+
/* VNodeType.Element */
|
|
3455
|
+
:
|
|
3456
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3457
|
+
break;
|
|
3458
|
+
|
|
3459
|
+
case 3
|
|
3460
|
+
/* VNodeType.CustomElement */
|
|
3461
|
+
:
|
|
3462
|
+
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3463
|
+
break;
|
|
3464
|
+
}
|
|
3404
3465
|
}
|
|
3466
|
+
|
|
3405
3467
|
function mount(node, parent, renderer, anchor) {
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3468
|
+
var _a, _b;
|
|
3469
|
+
|
|
3470
|
+
switch (node.type) {
|
|
3471
|
+
case 0
|
|
3472
|
+
/* VNodeType.Text */
|
|
3473
|
+
:
|
|
3474
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3475
|
+
mountText(node, parent, anchor, renderer);
|
|
3476
|
+
break;
|
|
3477
|
+
|
|
3478
|
+
case 1
|
|
3479
|
+
/* VNodeType.Comment */
|
|
3480
|
+
:
|
|
3481
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3482
|
+
mountComment(node, parent, anchor, renderer);
|
|
3483
|
+
break;
|
|
3484
|
+
|
|
3485
|
+
case 4
|
|
3486
|
+
/* VNodeType.Static */
|
|
3487
|
+
:
|
|
3488
|
+
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
3489
|
+
mountStatic(node, parent, anchor, renderer);
|
|
3490
|
+
break;
|
|
3491
|
+
|
|
3492
|
+
case 2
|
|
3493
|
+
/* VNodeType.Element */
|
|
3494
|
+
:
|
|
3495
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3496
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3497
|
+
break;
|
|
3498
|
+
|
|
3499
|
+
case 3
|
|
3500
|
+
/* VNodeType.CustomElement */
|
|
3501
|
+
:
|
|
3502
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3503
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3504
|
+
break;
|
|
3505
|
+
}
|
|
3429
3506
|
}
|
|
3507
|
+
|
|
3430
3508
|
function patchText(n1, n2, renderer) {
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3509
|
+
n2.elm = n1.elm;
|
|
3510
|
+
|
|
3511
|
+
if (n2.text !== n1.text) {
|
|
3512
|
+
updateTextContent(n2, renderer);
|
|
3513
|
+
}
|
|
3435
3514
|
}
|
|
3515
|
+
|
|
3436
3516
|
function mountText(vnode, parent, anchor, renderer) {
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3517
|
+
const {
|
|
3518
|
+
owner
|
|
3519
|
+
} = vnode;
|
|
3520
|
+
const {
|
|
3521
|
+
createText
|
|
3522
|
+
} = renderer;
|
|
3523
|
+
const textNode = vnode.elm = createText(vnode.text);
|
|
3524
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
3525
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
3442
3526
|
}
|
|
3527
|
+
|
|
3443
3528
|
function patchComment(n1, n2, renderer) {
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3529
|
+
n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3530
|
+
// it is the case today.
|
|
3531
|
+
|
|
3532
|
+
if (n2.text !== n1.text) {
|
|
3533
|
+
updateTextContent(n2, renderer);
|
|
3534
|
+
}
|
|
3450
3535
|
}
|
|
3536
|
+
|
|
3451
3537
|
function mountComment(vnode, parent, anchor, renderer) {
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3538
|
+
const {
|
|
3539
|
+
owner
|
|
3540
|
+
} = vnode;
|
|
3541
|
+
const {
|
|
3542
|
+
createComment
|
|
3543
|
+
} = renderer;
|
|
3544
|
+
const commentNode = vnode.elm = createComment(vnode.text);
|
|
3545
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
3546
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
3457
3547
|
}
|
|
3548
|
+
|
|
3458
3549
|
function mountElement(vnode, parent, anchor, renderer) {
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3550
|
+
const {
|
|
3551
|
+
sel,
|
|
3552
|
+
owner,
|
|
3553
|
+
data: {
|
|
3554
|
+
svg
|
|
3555
|
+
}
|
|
3556
|
+
} = vnode;
|
|
3557
|
+
const {
|
|
3558
|
+
createElement
|
|
3559
|
+
} = renderer;
|
|
3560
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
3561
|
+
const elm = vnode.elm = createElement(sel, namespace);
|
|
3562
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3563
|
+
applyStyleScoping(elm, owner, renderer);
|
|
3564
|
+
applyDomManual(elm, vnode);
|
|
3565
|
+
applyElementRestrictions(elm, vnode);
|
|
3566
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3567
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3568
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3470
3569
|
}
|
|
3570
|
+
|
|
3471
3571
|
function patchElement(n1, n2, renderer) {
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3572
|
+
const elm = n2.elm = n1.elm;
|
|
3573
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3574
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3475
3575
|
}
|
|
3576
|
+
|
|
3476
3577
|
function mountStatic(vnode, parent, anchor, renderer) {
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3578
|
+
const {
|
|
3579
|
+
owner
|
|
3580
|
+
} = vnode;
|
|
3581
|
+
const {
|
|
3582
|
+
cloneNode,
|
|
3583
|
+
isSyntheticShadowDefined
|
|
3584
|
+
} = renderer;
|
|
3585
|
+
const elm = vnode.elm = cloneNode(vnode.fragment, true);
|
|
3586
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3587
|
+
applyElementRestrictions(elm, vnode); // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
3588
|
+
|
|
3589
|
+
const {
|
|
3590
|
+
renderMode,
|
|
3591
|
+
shadowMode
|
|
3592
|
+
} = owner;
|
|
3593
|
+
|
|
3594
|
+
if (isSyntheticShadowDefined) {
|
|
3595
|
+
if (shadowMode === 1
|
|
3596
|
+
/* ShadowMode.Synthetic */
|
|
3597
|
+
|| renderMode === 0
|
|
3598
|
+
/* RenderMode.Light */
|
|
3599
|
+
) {
|
|
3600
|
+
elm[KEY__SHADOW_STATIC] = true;
|
|
3488
3601
|
}
|
|
3489
|
-
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3604
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3490
3605
|
}
|
|
3606
|
+
|
|
3491
3607
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3608
|
+
const {
|
|
3609
|
+
sel,
|
|
3610
|
+
owner
|
|
3611
|
+
} = vnode;
|
|
3612
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
3613
|
+
/**
|
|
3614
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3615
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
3616
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
3617
|
+
* an upgradable custom element.
|
|
3618
|
+
*/
|
|
3619
|
+
|
|
3620
|
+
let vm;
|
|
3621
|
+
const elm = new UpgradableConstructor(elm => {
|
|
3622
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
3623
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
3624
|
+
});
|
|
3625
|
+
vnode.elm = elm;
|
|
3626
|
+
vnode.vm = vm;
|
|
3627
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3628
|
+
applyStyleScoping(elm, owner, renderer);
|
|
3629
|
+
|
|
3630
|
+
if (vm) {
|
|
3631
|
+
allocateChildren(vnode, vm);
|
|
3632
|
+
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
3633
|
+
throw new TypeError(`Incorrect Component Constructor`);
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3637
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3638
|
+
|
|
3639
|
+
if (vm) {
|
|
3640
|
+
if (process.env.IS_BROWSER) {
|
|
3641
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3518
3642
|
if (process.env.NODE_ENV !== 'production') {
|
|
3519
|
-
|
|
3643
|
+
// With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
|
|
3644
|
+
// noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
|
|
3645
|
+
assert.isTrue(vm.state === 0
|
|
3646
|
+
/* VMState.created */
|
|
3647
|
+
, `${vm} cannot be recycled.`);
|
|
3520
3648
|
}
|
|
3649
|
+
|
|
3521
3650
|
runConnectedCallback(vm);
|
|
3651
|
+
}
|
|
3652
|
+
} else {
|
|
3653
|
+
// On the server, we don't have native custom element lifecycle callbacks, so we must
|
|
3654
|
+
// manually invoke the connectedCallback for a child component.
|
|
3655
|
+
runConnectedCallback(vm);
|
|
3522
3656
|
}
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3657
|
+
}
|
|
3658
|
+
|
|
3659
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3660
|
+
|
|
3661
|
+
if (vm) {
|
|
3662
|
+
appendVM(vm);
|
|
3663
|
+
}
|
|
3527
3664
|
}
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3665
|
+
|
|
3666
|
+
function patchCustomElement(n1, n2, parent, renderer) {
|
|
3667
|
+
if (n1.ctor !== n2.ctor) {
|
|
3668
|
+
// If the constructor, unmount the current component and mount a new one using the new
|
|
3669
|
+
// constructor.
|
|
3670
|
+
const anchor = renderer.nextSibling(n1.elm);
|
|
3671
|
+
unmount(n1, parent, renderer, true);
|
|
3672
|
+
mountCustomElement(n2, parent, anchor, renderer);
|
|
3673
|
+
} else {
|
|
3674
|
+
// Otherwise patch the existing component with new props/attrs/etc.
|
|
3675
|
+
const elm = n2.elm = n1.elm;
|
|
3676
|
+
const vm = n2.vm = n1.vm;
|
|
3531
3677
|
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3678
|
+
|
|
3532
3679
|
if (!isUndefined$1(vm)) {
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
}
|
|
3537
|
-
// in fallback mode, the children will be always empty, so, nothing
|
|
3680
|
+
// in fallback mode, the allocation will always set children to
|
|
3681
|
+
// empty and delegate the real allocation to the slot elements
|
|
3682
|
+
allocateChildren(n2, vm);
|
|
3683
|
+
} // in fallback mode, the children will be always empty, so, nothing
|
|
3538
3684
|
// will happen, but in native, it does allocate the light dom
|
|
3685
|
+
|
|
3686
|
+
|
|
3539
3687
|
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3688
|
+
|
|
3540
3689
|
if (!isUndefined$1(vm)) {
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3690
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3691
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
3692
|
+
rerenderVM(vm);
|
|
3544
3693
|
}
|
|
3694
|
+
}
|
|
3545
3695
|
}
|
|
3696
|
+
|
|
3546
3697
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3698
|
+
for (; start < end; ++start) {
|
|
3699
|
+
const vnode = vnodes[start];
|
|
3700
|
+
|
|
3701
|
+
if (isVNode(vnode)) {
|
|
3702
|
+
mount(vnode, parent, renderer, anchor);
|
|
3552
3703
|
}
|
|
3704
|
+
}
|
|
3553
3705
|
}
|
|
3706
|
+
|
|
3554
3707
|
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3708
|
+
const {
|
|
3709
|
+
type,
|
|
3710
|
+
elm,
|
|
3711
|
+
sel
|
|
3712
|
+
} = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3713
|
+
// subtree root, is the only element worth unmounting from the subtree.
|
|
3714
|
+
|
|
3715
|
+
if (doRemove) {
|
|
3716
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
3717
|
+
// but the removal used here is from the owner instead.
|
|
3718
|
+
removeNode(elm, parent, renderer);
|
|
3719
|
+
}
|
|
3720
|
+
|
|
3721
|
+
switch (type) {
|
|
3722
|
+
case 2
|
|
3723
|
+
/* VNodeType.Element */
|
|
3724
|
+
:
|
|
3725
|
+
{
|
|
3726
|
+
// Slot content is removed to trigger slotchange event when removing slot.
|
|
3727
|
+
// Only required for synthetic shadow.
|
|
3728
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
|
|
3729
|
+
/* ShadowMode.Synthetic */
|
|
3730
|
+
;
|
|
3731
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
3732
|
+
break;
|
|
3733
|
+
}
|
|
3734
|
+
|
|
3735
|
+
case 3
|
|
3736
|
+
/* VNodeType.CustomElement */
|
|
3737
|
+
:
|
|
3738
|
+
{
|
|
3739
|
+
const {
|
|
3740
|
+
vm
|
|
3741
|
+
} = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
|
|
3742
|
+
// children.
|
|
3743
|
+
|
|
3744
|
+
if (!isUndefined$1(vm)) {
|
|
3745
|
+
removeVM(vm);
|
|
3578
3746
|
}
|
|
3579
|
-
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3580
3749
|
}
|
|
3750
|
+
|
|
3581
3751
|
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3752
|
+
for (; start < end; ++start) {
|
|
3753
|
+
const ch = vnodes[start];
|
|
3754
|
+
|
|
3755
|
+
if (isVNode(ch)) {
|
|
3756
|
+
unmount(ch, parent, renderer, doRemove);
|
|
3587
3757
|
}
|
|
3758
|
+
}
|
|
3588
3759
|
}
|
|
3760
|
+
|
|
3589
3761
|
function isVNode(vnode) {
|
|
3590
|
-
|
|
3762
|
+
return vnode != null;
|
|
3591
3763
|
}
|
|
3764
|
+
|
|
3592
3765
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3766
|
+
const {
|
|
3767
|
+
renderRoot,
|
|
3768
|
+
renderMode,
|
|
3769
|
+
shadowMode
|
|
3770
|
+
} = owner;
|
|
3771
|
+
const {
|
|
3772
|
+
isSyntheticShadowDefined
|
|
3773
|
+
} = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
|
|
3774
|
+
|
|
3775
|
+
if (isSyntheticShadowDefined) {
|
|
3776
|
+
if (shadowMode === 1
|
|
3777
|
+
/* ShadowMode.Synthetic */
|
|
3778
|
+
|| renderMode === 0
|
|
3779
|
+
/* RenderMode.Light */
|
|
3780
|
+
) {
|
|
3781
|
+
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
3600
3782
|
}
|
|
3783
|
+
}
|
|
3601
3784
|
}
|
|
3785
|
+
|
|
3602
3786
|
function updateTextContent(vnode, renderer) {
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
setText
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3787
|
+
const {
|
|
3788
|
+
elm,
|
|
3789
|
+
text
|
|
3790
|
+
} = vnode;
|
|
3791
|
+
const {
|
|
3792
|
+
setText
|
|
3793
|
+
} = renderer;
|
|
3794
|
+
|
|
3795
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3796
|
+
unlockDomMutation();
|
|
3797
|
+
}
|
|
3798
|
+
|
|
3799
|
+
setText(elm, text);
|
|
3800
|
+
|
|
3801
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3802
|
+
lockDomMutation();
|
|
3803
|
+
}
|
|
3612
3804
|
}
|
|
3805
|
+
|
|
3613
3806
|
function insertNode(node, parent, anchor, renderer) {
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3807
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3808
|
+
unlockDomMutation();
|
|
3809
|
+
}
|
|
3810
|
+
|
|
3811
|
+
renderer.insert(node, parent, anchor);
|
|
3812
|
+
|
|
3813
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3814
|
+
lockDomMutation();
|
|
3815
|
+
}
|
|
3621
3816
|
}
|
|
3817
|
+
|
|
3622
3818
|
function removeNode(node, parent, renderer) {
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3819
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3820
|
+
unlockDomMutation();
|
|
3821
|
+
}
|
|
3822
|
+
|
|
3823
|
+
renderer.remove(node, parent);
|
|
3824
|
+
|
|
3825
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3826
|
+
lockDomMutation();
|
|
3827
|
+
}
|
|
3630
3828
|
}
|
|
3829
|
+
|
|
3631
3830
|
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3831
|
+
if (isNull(oldVnode)) {
|
|
3832
|
+
applyEventListeners(vnode, renderer);
|
|
3833
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
3834
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
3835
|
+
} // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
3836
|
+
// value is set before type=radio.
|
|
3837
|
+
|
|
3838
|
+
|
|
3839
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
3840
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
3841
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
3842
|
+
patchProps(oldVnode, vnode, renderer);
|
|
3643
3843
|
}
|
|
3844
|
+
|
|
3644
3845
|
function applyStyleScoping(elm, owner, renderer) {
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3846
|
+
// Set the class name for `*.scoped.css` style scoping.
|
|
3847
|
+
const scopeToken = getScopeTokenClass(owner);
|
|
3848
|
+
|
|
3849
|
+
if (!isNull(scopeToken)) {
|
|
3850
|
+
const {
|
|
3851
|
+
getClassList
|
|
3852
|
+
} = renderer; // TODO [#2762]: this dot notation with add is probably problematic
|
|
3853
|
+
// probably we should have a renderer api for just the add operation
|
|
3854
|
+
|
|
3855
|
+
getClassList(elm).add(scopeToken);
|
|
3856
|
+
} // Set property element for synthetic shadow DOM style scoping.
|
|
3857
|
+
|
|
3858
|
+
|
|
3859
|
+
const {
|
|
3860
|
+
stylesheetToken: syntheticToken
|
|
3861
|
+
} = owner.context;
|
|
3862
|
+
|
|
3863
|
+
if (owner.shadowMode === 1
|
|
3864
|
+
/* ShadowMode.Synthetic */
|
|
3865
|
+
&& !isUndefined$1(syntheticToken)) {
|
|
3866
|
+
elm.$shadowToken$ = syntheticToken;
|
|
3867
|
+
}
|
|
3658
3868
|
}
|
|
3869
|
+
|
|
3659
3870
|
function applyDomManual(elm, vnode) {
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3871
|
+
var _a;
|
|
3872
|
+
|
|
3873
|
+
const {
|
|
3874
|
+
owner,
|
|
3875
|
+
data: {
|
|
3876
|
+
context
|
|
3664
3877
|
}
|
|
3878
|
+
} = vnode;
|
|
3879
|
+
|
|
3880
|
+
if (owner.shadowMode === 1
|
|
3881
|
+
/* ShadowMode.Synthetic */
|
|
3882
|
+
&& ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
|
|
3883
|
+
/* LwcDomMode.Manual */
|
|
3884
|
+
) {
|
|
3885
|
+
elm.$domManual$ = true;
|
|
3886
|
+
}
|
|
3665
3887
|
}
|
|
3888
|
+
|
|
3666
3889
|
function applyElementRestrictions(elm, vnode) {
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3890
|
+
var _a, _b;
|
|
3891
|
+
|
|
3892
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3893
|
+
const isPortal = vnode.type === 2
|
|
3894
|
+
/* VNodeType.Element */
|
|
3895
|
+
&& ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
|
|
3896
|
+
/* LwcDomMode.Manual */
|
|
3897
|
+
;
|
|
3898
|
+
const isLight = vnode.owner.renderMode === 0
|
|
3899
|
+
/* RenderMode.Light */
|
|
3900
|
+
;
|
|
3901
|
+
patchElementWithRestrictions(elm, {
|
|
3902
|
+
isPortal,
|
|
3903
|
+
isLight
|
|
3904
|
+
});
|
|
3905
|
+
}
|
|
3676
3906
|
}
|
|
3907
|
+
|
|
3677
3908
|
function allocateChildren(vnode, vm) {
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3909
|
+
// A component with slots will re-render because:
|
|
3910
|
+
// 1- There is a change of the internal state.
|
|
3911
|
+
// 2- There is a change on the external api (ex: slots)
|
|
3912
|
+
//
|
|
3913
|
+
// In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
|
|
3914
|
+
// slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
|
|
3915
|
+
// in a reused VCustomElement, there won't be any slotted children.
|
|
3916
|
+
// For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
|
|
3917
|
+
//
|
|
3918
|
+
// In case #2, we will always get a fresh VCustomElement.
|
|
3919
|
+
const children = vnode.aChildren || vnode.children;
|
|
3920
|
+
vm.aChildren = children;
|
|
3921
|
+
const {
|
|
3922
|
+
renderMode,
|
|
3923
|
+
shadowMode
|
|
3924
|
+
} = vm;
|
|
3925
|
+
|
|
3926
|
+
if (shadowMode === 1
|
|
3927
|
+
/* ShadowMode.Synthetic */
|
|
3928
|
+
|| renderMode === 0
|
|
3929
|
+
/* RenderMode.Light */
|
|
3930
|
+
) {
|
|
3931
|
+
// slow path
|
|
3932
|
+
allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
|
|
3933
|
+
|
|
3934
|
+
vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
3935
|
+
|
|
3936
|
+
vnode.children = EmptyArray;
|
|
3937
|
+
}
|
|
3699
3938
|
}
|
|
3939
|
+
|
|
3700
3940
|
function createViewModelHook(elm, vnode, renderer) {
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
return vm;
|
|
3707
|
-
}
|
|
3708
|
-
const { sel, mode, ctor, owner } = vnode;
|
|
3709
|
-
vm = createVM(elm, ctor, renderer, {
|
|
3710
|
-
mode,
|
|
3711
|
-
owner,
|
|
3712
|
-
tagName: sel,
|
|
3713
|
-
});
|
|
3714
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3715
|
-
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
3716
|
-
}
|
|
3941
|
+
let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
|
|
3942
|
+
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
3943
|
+
// called right after invoking `document.createElement`.
|
|
3944
|
+
|
|
3945
|
+
if (!isUndefined$1(vm)) {
|
|
3717
3946
|
return vm;
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3949
|
+
const {
|
|
3950
|
+
sel,
|
|
3951
|
+
mode,
|
|
3952
|
+
ctor,
|
|
3953
|
+
owner
|
|
3954
|
+
} = vnode;
|
|
3955
|
+
vm = createVM(elm, ctor, renderer, {
|
|
3956
|
+
mode,
|
|
3957
|
+
owner,
|
|
3958
|
+
tagName: sel
|
|
3959
|
+
});
|
|
3960
|
+
|
|
3961
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3962
|
+
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3965
|
+
return vm;
|
|
3718
3966
|
}
|
|
3967
|
+
|
|
3719
3968
|
function allocateInSlot(vm, children) {
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3969
|
+
var _a;
|
|
3970
|
+
|
|
3971
|
+
const {
|
|
3972
|
+
cmpSlots: oldSlots
|
|
3973
|
+
} = vm;
|
|
3974
|
+
const cmpSlots = vm.cmpSlots = create(null);
|
|
3975
|
+
|
|
3976
|
+
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
3977
|
+
const vnode = children[i];
|
|
3978
|
+
|
|
3979
|
+
if (isNull(vnode)) {
|
|
3980
|
+
continue;
|
|
3981
|
+
}
|
|
3982
|
+
|
|
3983
|
+
let slotName = '';
|
|
3984
|
+
|
|
3985
|
+
if (isVBaseElement(vnode)) {
|
|
3986
|
+
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
|
|
3990
|
+
ArrayPush$1.call(vnodes, vnode);
|
|
3991
|
+
}
|
|
3992
|
+
|
|
3993
|
+
if (isFalse(vm.isDirty)) {
|
|
3994
|
+
// We need to determine if the old allocation is really different from the new one
|
|
3995
|
+
// and mark the vm as dirty
|
|
3996
|
+
const oldKeys = keys(oldSlots);
|
|
3997
|
+
|
|
3998
|
+
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
3999
|
+
markComponentAsDirty(vm);
|
|
4000
|
+
return;
|
|
4001
|
+
}
|
|
4002
|
+
|
|
4003
|
+
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4004
|
+
const key = oldKeys[i];
|
|
4005
|
+
|
|
4006
|
+
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
4007
|
+
markComponentAsDirty(vm);
|
|
4008
|
+
return;
|
|
4009
|
+
}
|
|
4010
|
+
|
|
4011
|
+
const oldVNodes = oldSlots[key];
|
|
4012
|
+
const vnodes = cmpSlots[key];
|
|
4013
|
+
|
|
4014
|
+
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
4015
|
+
if (oldVNodes[j] !== vnodes[j]) {
|
|
4016
|
+
markComponentAsDirty(vm);
|
|
4017
|
+
return;
|
|
3757
4018
|
}
|
|
4019
|
+
}
|
|
3758
4020
|
}
|
|
3759
|
-
}
|
|
3760
|
-
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
3761
|
-
|
|
3762
|
-
|
|
4021
|
+
}
|
|
4022
|
+
} // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4023
|
+
|
|
4024
|
+
|
|
4025
|
+
const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
|
|
3763
4026
|
// in a template, and will require a more complex diffing algo.
|
|
4027
|
+
|
|
3764
4028
|
function markAsDynamicChildren(children) {
|
|
3765
|
-
|
|
4029
|
+
FromIteration.set(children, 1);
|
|
3766
4030
|
}
|
|
4031
|
+
|
|
3767
4032
|
function hasDynamicChildren(children) {
|
|
3768
|
-
|
|
4033
|
+
return FromIteration.has(children);
|
|
3769
4034
|
}
|
|
4035
|
+
|
|
3770
4036
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
4037
|
+
const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
4038
|
+
|
|
4039
|
+
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
4040
|
+
const ch = children[j];
|
|
4041
|
+
|
|
4042
|
+
if (isVNode(ch)) {
|
|
4043
|
+
const {
|
|
4044
|
+
key
|
|
4045
|
+
} = ch;
|
|
4046
|
+
|
|
4047
|
+
if (key !== undefined) {
|
|
4048
|
+
map[key] = j;
|
|
4049
|
+
}
|
|
3781
4050
|
}
|
|
3782
|
-
|
|
4051
|
+
}
|
|
4052
|
+
|
|
4053
|
+
return map;
|
|
3783
4054
|
}
|
|
4055
|
+
|
|
3784
4056
|
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
}
|
|
3864
|
-
// We've already cloned at least once, so it's no longer read-only
|
|
3865
|
-
oldCh[idxInOld] = undefined;
|
|
3866
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
3867
|
-
}
|
|
3868
|
-
}
|
|
3869
|
-
newStartVnode = newCh[++newStartIdx];
|
|
3870
|
-
}
|
|
4057
|
+
let oldStartIdx = 0;
|
|
4058
|
+
let newStartIdx = 0;
|
|
4059
|
+
let oldEndIdx = oldCh.length - 1;
|
|
4060
|
+
let oldStartVnode = oldCh[0];
|
|
4061
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
4062
|
+
const newChEnd = newCh.length - 1;
|
|
4063
|
+
let newEndIdx = newChEnd;
|
|
4064
|
+
let newStartVnode = newCh[0];
|
|
4065
|
+
let newEndVnode = newCh[newEndIdx];
|
|
4066
|
+
let oldKeyToIdx;
|
|
4067
|
+
let idxInOld;
|
|
4068
|
+
let elmToMove;
|
|
4069
|
+
let before;
|
|
4070
|
+
let clonedOldCh = false;
|
|
4071
|
+
|
|
4072
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
4073
|
+
if (!isVNode(oldStartVnode)) {
|
|
4074
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
4075
|
+
} else if (!isVNode(oldEndVnode)) {
|
|
4076
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4077
|
+
} else if (!isVNode(newStartVnode)) {
|
|
4078
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4079
|
+
} else if (!isVNode(newEndVnode)) {
|
|
4080
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4081
|
+
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
4082
|
+
patch(oldStartVnode, newStartVnode, parent, renderer);
|
|
4083
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4084
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4085
|
+
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
4086
|
+
patch(oldEndVnode, newEndVnode, parent, renderer);
|
|
4087
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4088
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4089
|
+
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
4090
|
+
// Vnode moved right
|
|
4091
|
+
patch(oldStartVnode, newEndVnode, parent, renderer);
|
|
4092
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
4093
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4094
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4095
|
+
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
4096
|
+
// Vnode moved left
|
|
4097
|
+
patch(oldEndVnode, newStartVnode, parent, renderer);
|
|
4098
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
4099
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4100
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4101
|
+
} else {
|
|
4102
|
+
if (oldKeyToIdx === undefined) {
|
|
4103
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
4104
|
+
}
|
|
4105
|
+
|
|
4106
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
4107
|
+
|
|
4108
|
+
if (isUndefined$1(idxInOld)) {
|
|
4109
|
+
// New element
|
|
4110
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4111
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4112
|
+
} else {
|
|
4113
|
+
elmToMove = oldCh[idxInOld];
|
|
4114
|
+
|
|
4115
|
+
if (isVNode(elmToMove)) {
|
|
4116
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4117
|
+
// New element
|
|
4118
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4119
|
+
} else {
|
|
4120
|
+
patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
|
|
4121
|
+
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4122
|
+
// so we only care about the `oldCh` object inside this function.
|
|
4123
|
+
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4124
|
+
// and only clone once.
|
|
4125
|
+
|
|
4126
|
+
if (!clonedOldCh) {
|
|
4127
|
+
clonedOldCh = true;
|
|
4128
|
+
oldCh = [...oldCh];
|
|
4129
|
+
} // We've already cloned at least once, so it's no longer read-only
|
|
4130
|
+
|
|
4131
|
+
|
|
4132
|
+
oldCh[idxInOld] = undefined;
|
|
4133
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4134
|
+
}
|
|
3871
4135
|
}
|
|
4136
|
+
|
|
4137
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4138
|
+
}
|
|
3872
4139
|
}
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4142
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
4143
|
+
if (oldStartIdx > oldEndIdx) {
|
|
4144
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
4145
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
4146
|
+
let i = newEndIdx;
|
|
4147
|
+
let n;
|
|
4148
|
+
|
|
4149
|
+
do {
|
|
4150
|
+
n = newCh[++i];
|
|
4151
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
4152
|
+
|
|
4153
|
+
before = isVNode(n) ? n.elm : null;
|
|
4154
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
4155
|
+
} else {
|
|
4156
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
3888
4157
|
}
|
|
4158
|
+
}
|
|
3889
4159
|
}
|
|
4160
|
+
|
|
3890
4161
|
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
anchor = n2.elm;
|
|
3925
|
-
}
|
|
4162
|
+
const c1Length = c1.length;
|
|
4163
|
+
const c2Length = c2.length;
|
|
4164
|
+
|
|
4165
|
+
if (c1Length === 0) {
|
|
4166
|
+
// the old list is empty, we can directly insert anything new
|
|
4167
|
+
mountVNodes(c2, parent, renderer, null);
|
|
4168
|
+
return;
|
|
4169
|
+
}
|
|
4170
|
+
|
|
4171
|
+
if (c2Length === 0) {
|
|
4172
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4173
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4174
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
4175
|
+
return;
|
|
4176
|
+
} // if the old list is not empty, the new list MUST have the same
|
|
4177
|
+
// amount of nodes, that's why we call this static children
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
let anchor = null;
|
|
4181
|
+
|
|
4182
|
+
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
4183
|
+
const n1 = c1[i];
|
|
4184
|
+
const n2 = c2[i];
|
|
4185
|
+
|
|
4186
|
+
if (n2 !== n1) {
|
|
4187
|
+
if (isVNode(n1)) {
|
|
4188
|
+
if (isVNode(n2)) {
|
|
4189
|
+
// both vnodes are equivalent, and we just need to patch them
|
|
4190
|
+
patch(n1, n2, parent, renderer);
|
|
4191
|
+
anchor = n2.elm;
|
|
4192
|
+
} else {
|
|
4193
|
+
// removing the old vnode since the new one is null
|
|
4194
|
+
unmount(n1, parent, renderer, true);
|
|
3926
4195
|
}
|
|
4196
|
+
} else if (isVNode(n2)) {
|
|
4197
|
+
mount(n2, parent, renderer, anchor);
|
|
4198
|
+
anchor = n2.elm;
|
|
4199
|
+
}
|
|
3927
4200
|
}
|
|
4201
|
+
}
|
|
3928
4202
|
}
|
|
3929
4203
|
|
|
3930
4204
|
/*
|
|
@@ -4245,13 +4519,6 @@ function fid(url) {
|
|
|
4245
4519
|
}
|
|
4246
4520
|
return url;
|
|
4247
4521
|
}
|
|
4248
|
-
/**
|
|
4249
|
-
* Map to store an index value assigned to any dynamic component reference ingested
|
|
4250
|
-
* by dc() api. This allows us to generate a unique unique per template per dynamic
|
|
4251
|
-
* component reference to avoid diffing algo mismatches.
|
|
4252
|
-
*/
|
|
4253
|
-
const DynamicImportedComponentMap = new Map();
|
|
4254
|
-
let dynamicImportedComponentCounter = 0;
|
|
4255
4522
|
/**
|
|
4256
4523
|
* create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
4257
4524
|
*/
|
|
@@ -4268,18 +4535,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
|
|
|
4268
4535
|
if (!isComponentConstructor(Ctor)) {
|
|
4269
4536
|
throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
|
|
4270
4537
|
}
|
|
4271
|
-
|
|
4272
|
-
if (isUndefined$1(idx)) {
|
|
4273
|
-
idx = dynamicImportedComponentCounter++;
|
|
4274
|
-
DynamicImportedComponentMap.set(Ctor, idx);
|
|
4275
|
-
}
|
|
4276
|
-
// the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
|
|
4277
|
-
// to identify different constructors as vnodes with different keys to avoid reusing the
|
|
4278
|
-
// element used for previous constructors.
|
|
4279
|
-
// Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
|
|
4280
|
-
// hoisting optimization.
|
|
4281
|
-
const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
|
|
4282
|
-
return c(sel, Ctor, newData, children);
|
|
4538
|
+
return c(sel, Ctor, data, children);
|
|
4283
4539
|
}
|
|
4284
4540
|
/**
|
|
4285
4541
|
* slow children collection marking mechanism. this API allows the compiler to signal
|
|
@@ -5005,7 +5261,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5005
5261
|
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
5006
5262
|
};
|
|
5007
5263
|
|
|
5008
|
-
if (
|
|
5264
|
+
if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5009
5265
|
vm.shadowMode = 0
|
|
5010
5266
|
/* ShadowMode.Native */
|
|
5011
5267
|
;
|
|
@@ -5044,7 +5300,7 @@ function computeShadowMode(vm, renderer) {
|
|
|
5044
5300
|
} else if (isNativeShadowDefined) {
|
|
5045
5301
|
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
5046
5302
|
// the if-condition.
|
|
5047
|
-
if (
|
|
5303
|
+
if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
5048
5304
|
if (def.shadowSupportMode === "any"
|
|
5049
5305
|
/* ShadowSupportMode.Any */
|
|
5050
5306
|
) {
|
|
@@ -5173,13 +5429,10 @@ function runRenderedCallback(vm) {
|
|
|
5173
5429
|
const {
|
|
5174
5430
|
def: {
|
|
5175
5431
|
renderedCallback
|
|
5176
|
-
},
|
|
5177
|
-
renderer: {
|
|
5178
|
-
ssr
|
|
5179
5432
|
}
|
|
5180
5433
|
} = vm;
|
|
5181
5434
|
|
|
5182
|
-
if (
|
|
5435
|
+
if (!process.env.IS_BROWSER) {
|
|
5183
5436
|
return;
|
|
5184
5437
|
}
|
|
5185
5438
|
|
|
@@ -5432,13 +5685,7 @@ function resetComponentRoot(vm) {
|
|
|
5432
5685
|
vm.velements = EmptyArray;
|
|
5433
5686
|
}
|
|
5434
5687
|
function scheduleRehydration(vm) {
|
|
5435
|
-
|
|
5436
|
-
renderer: {
|
|
5437
|
-
ssr
|
|
5438
|
-
}
|
|
5439
|
-
} = vm;
|
|
5440
|
-
|
|
5441
|
-
if (isTrue(ssr) || isTrue(vm.isScheduled)) {
|
|
5688
|
+
if (!process.env.IS_BROWSER || isTrue(vm.isScheduled)) {
|
|
5442
5689
|
return;
|
|
5443
5690
|
}
|
|
5444
5691
|
|
|
@@ -5545,15 +5792,8 @@ class WireContextRegistrationEvent extends CustomEvent {
|
|
|
5545
5792
|
}
|
|
5546
5793
|
|
|
5547
5794
|
function createFieldDataCallback(vm, name) {
|
|
5548
|
-
const {
|
|
5549
|
-
cmpFields
|
|
5550
|
-
} = vm;
|
|
5551
5795
|
return value => {
|
|
5552
|
-
|
|
5553
|
-
// storing the value in the underlying storage
|
|
5554
|
-
cmpFields[name] = value;
|
|
5555
|
-
componentValueMutated(vm, name);
|
|
5556
|
-
}
|
|
5796
|
+
updateComponentValue(vm, name, value);
|
|
5557
5797
|
};
|
|
5558
5798
|
}
|
|
5559
5799
|
|
|
@@ -5771,7 +6011,7 @@ function installWireAdapters(vm) {
|
|
|
5771
6011
|
ArrayPush$1.call(wiredConnecting, () => {
|
|
5772
6012
|
connector.connect();
|
|
5773
6013
|
|
|
5774
|
-
if (!
|
|
6014
|
+
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
5775
6015
|
if (hasDynamicParams) {
|
|
5776
6016
|
Promise.resolve().then(computeConfigAndUpdate);
|
|
5777
6017
|
return;
|
|
@@ -5917,6 +6157,7 @@ function hydrateNode(node, vnode, renderer) {
|
|
|
5917
6157
|
}
|
|
5918
6158
|
return renderer.nextSibling(hydratedNode);
|
|
5919
6159
|
}
|
|
6160
|
+
const NODE_VALUE_PROP = 'nodeValue';
|
|
5920
6161
|
function hydrateText(node, vnode, renderer) {
|
|
5921
6162
|
var _a;
|
|
5922
6163
|
if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
@@ -5924,7 +6165,7 @@ function hydrateText(node, vnode, renderer) {
|
|
|
5924
6165
|
}
|
|
5925
6166
|
if (process.env.NODE_ENV !== 'production') {
|
|
5926
6167
|
const { getProperty } = renderer;
|
|
5927
|
-
const nodeValue = getProperty(node,
|
|
6168
|
+
const nodeValue = getProperty(node, NODE_VALUE_PROP);
|
|
5928
6169
|
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
5929
6170
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
5930
6171
|
}
|
|
@@ -5941,13 +6182,13 @@ function hydrateComment(node, vnode, renderer) {
|
|
|
5941
6182
|
}
|
|
5942
6183
|
if (process.env.NODE_ENV !== 'production') {
|
|
5943
6184
|
const { getProperty } = renderer;
|
|
5944
|
-
const nodeValue = getProperty(node,
|
|
6185
|
+
const nodeValue = getProperty(node, NODE_VALUE_PROP);
|
|
5945
6186
|
if (nodeValue !== vnode.text) {
|
|
5946
6187
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
5947
6188
|
}
|
|
5948
6189
|
}
|
|
5949
6190
|
const { setProperty } = renderer;
|
|
5950
|
-
setProperty(node,
|
|
6191
|
+
setProperty(node, NODE_VALUE_PROP, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5951
6192
|
vnode.elm = node;
|
|
5952
6193
|
return node;
|
|
5953
6194
|
}
|
|
@@ -6215,13 +6456,13 @@ function areCompatibleNodes(client, ssr, vnode, renderer) {
|
|
|
6215
6456
|
if (!hasCorrectNodeType(vnode, ssr, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
6216
6457
|
return false;
|
|
6217
6458
|
}
|
|
6218
|
-
return getProperty(client,
|
|
6459
|
+
return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
|
|
6219
6460
|
}
|
|
6220
6461
|
if (getProperty(client, 'nodeType') === 8 /* EnvNodeTypes.COMMENT */) {
|
|
6221
6462
|
if (!hasCorrectNodeType(vnode, ssr, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
|
|
6222
6463
|
return false;
|
|
6223
6464
|
}
|
|
6224
|
-
return getProperty(client,
|
|
6465
|
+
return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
|
|
6225
6466
|
}
|
|
6226
6467
|
if (!hasCorrectNodeType(vnode, ssr, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
|
|
6227
6468
|
return false;
|
|
@@ -6379,4 +6620,4 @@ function getComponentConstructor(elm) {
|
|
|
6379
6620
|
}
|
|
6380
6621
|
|
|
6381
6622
|
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 };
|
|
6382
|
-
/* version: 2.
|
|
6623
|
+
/* version: 2.23.2 */
|