lwc 2.22.0 → 2.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-dom/esm/es2017/engine-dom.js +1222 -947
- package/dist/engine-dom/iife/es2017/engine-dom.js +1222 -946
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +1129 -882
- package/dist/engine-dom/iife/es5/engine-dom.js +524 -499
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +475 -457
- package/dist/engine-dom/umd/es2017/engine-dom.js +1222 -946
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +1129 -882
- package/dist/engine-dom/umd/es5/engine-dom.js +524 -499
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +475 -457
- package/dist/engine-server/commonjs/es2017/engine-server.js +809 -626
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +809 -626
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +30 -27
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +30 -27
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +29 -26
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +32 -31
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +31 -30
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +30 -27
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +29 -26
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +32 -31
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +31 -30
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +7 -7
|
@@ -313,24 +313,36 @@ function isBooleanAttribute(attrName, tagName) {
|
|
|
313
313
|
return (allowedTagNames !== undefined &&
|
|
314
314
|
(allowedTagNames.size === 0 || allowedTagNames.has(tagName)));
|
|
315
315
|
}
|
|
316
|
+
// This list is based on https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
|
|
316
317
|
const GLOBAL_ATTRIBUTE = new Set([
|
|
317
|
-
'role',
|
|
318
318
|
'accesskey',
|
|
319
|
+
'autocapitalize',
|
|
320
|
+
'autofocus',
|
|
319
321
|
'class',
|
|
320
322
|
'contenteditable',
|
|
321
323
|
'contextmenu',
|
|
322
324
|
'dir',
|
|
323
325
|
'draggable',
|
|
324
|
-
'
|
|
326
|
+
'enterkeyhint',
|
|
327
|
+
'exportparts',
|
|
325
328
|
'hidden',
|
|
326
329
|
'id',
|
|
330
|
+
'inputmode',
|
|
331
|
+
'is',
|
|
332
|
+
'itemid',
|
|
327
333
|
'itemprop',
|
|
334
|
+
'itemref',
|
|
335
|
+
'itemscope',
|
|
336
|
+
'itemtype',
|
|
328
337
|
'lang',
|
|
338
|
+
'nonce',
|
|
339
|
+
'part',
|
|
329
340
|
'slot',
|
|
330
341
|
'spellcheck',
|
|
331
342
|
'style',
|
|
332
343
|
'tabindex',
|
|
333
344
|
'title',
|
|
345
|
+
'translate',
|
|
334
346
|
]);
|
|
335
347
|
function isGlobalHtmlAttribute(attrName) {
|
|
336
348
|
return GLOBAL_ATTRIBUTE.has(attrName);
|
|
@@ -415,9 +427,9 @@ function htmlEscape(str, attrMode = false) {
|
|
|
415
427
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
416
428
|
*/
|
|
417
429
|
// Increment whenever the LWC template compiler changes
|
|
418
|
-
const LWC_VERSION = "2.
|
|
430
|
+
const LWC_VERSION = "2.23.2";
|
|
419
431
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
420
|
-
/** version: 2.
|
|
432
|
+
/** version: 2.23.2 */
|
|
421
433
|
|
|
422
434
|
/*
|
|
423
435
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -469,6 +481,7 @@ const features = {
|
|
|
469
481
|
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
470
482
|
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
471
483
|
ENABLE_MIXED_SHADOW_MODE: null,
|
|
484
|
+
ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
|
|
472
485
|
ENABLE_NODE_LIST_PATCH: null,
|
|
473
486
|
ENABLE_NODE_PATCH: null,
|
|
474
487
|
ENABLE_REACTIVE_SETTER: null,
|
|
@@ -477,7 +490,7 @@ const features = {
|
|
|
477
490
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
478
491
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
479
492
|
}
|
|
480
|
-
const
|
|
493
|
+
const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
|
|
481
494
|
/**
|
|
482
495
|
* Set the value at runtime of a given feature flag. This method only be invoked once per feature
|
|
483
496
|
* flag. It is meant to be used during the app initialization.
|
|
@@ -504,17 +517,17 @@ function setFeatureFlag(name, value) {
|
|
|
504
517
|
}
|
|
505
518
|
if (process.env.NODE_ENV !== 'production') {
|
|
506
519
|
// Allow the same flag to be set more than once outside of production to enable testing
|
|
507
|
-
|
|
520
|
+
lwcRuntimeFlags[name] = value;
|
|
508
521
|
}
|
|
509
522
|
else {
|
|
510
523
|
// Disallow the same flag to be set more than once in production
|
|
511
|
-
const runtimeValue =
|
|
524
|
+
const runtimeValue = lwcRuntimeFlags[name];
|
|
512
525
|
if (!isUndefined$1(runtimeValue)) {
|
|
513
526
|
// eslint-disable-next-line no-console
|
|
514
527
|
console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
|
|
515
528
|
return;
|
|
516
529
|
}
|
|
517
|
-
defineProperty(
|
|
530
|
+
defineProperty(lwcRuntimeFlags, name, { value });
|
|
518
531
|
}
|
|
519
532
|
}
|
|
520
533
|
/**
|
|
@@ -526,7 +539,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
526
539
|
setFeatureFlag(name, value);
|
|
527
540
|
}
|
|
528
541
|
}
|
|
529
|
-
/** version: 2.
|
|
542
|
+
/** version: 2.23.2 */
|
|
530
543
|
|
|
531
544
|
/* proxy-compat-disable */
|
|
532
545
|
|
|
@@ -542,7 +555,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
|
542
555
|
window.addEventListener('test-dummy-flag', () => {
|
|
543
556
|
let hasFlag = false;
|
|
544
557
|
|
|
545
|
-
if (
|
|
558
|
+
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
546
559
|
hasFlag = true;
|
|
547
560
|
}
|
|
548
561
|
|
|
@@ -1175,6 +1188,13 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
|
1175
1188
|
defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
1176
1189
|
}
|
|
1177
1190
|
|
|
1191
|
+
function updateComponentValue(vm, key, newValue) {
|
|
1192
|
+
const { cmpFields } = vm;
|
|
1193
|
+
if (newValue !== cmpFields[key]) {
|
|
1194
|
+
cmpFields[key] = newValue;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1178
1198
|
/**
|
|
1179
1199
|
* Copyright (C) 2017 salesforce.com, inc.
|
|
1180
1200
|
*/
|
|
@@ -1799,9 +1819,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
|
|
|
1799
1819
|
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1800
1820
|
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1801
1821
|
}
|
|
1802
|
-
|
|
1803
|
-
vm.cmpProps[propName] = newValue;
|
|
1804
|
-
}
|
|
1822
|
+
updateComponentValue(vm, propName, newValue);
|
|
1805
1823
|
return set.call(vm.elm, newValue);
|
|
1806
1824
|
},
|
|
1807
1825
|
};
|
|
@@ -2094,9 +2112,7 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
2094
2112
|
},
|
|
2095
2113
|
set(newValue) {
|
|
2096
2114
|
const vm = getAssociatedVM(this);
|
|
2097
|
-
|
|
2098
|
-
vm.cmpFields[key] = newValue;
|
|
2099
|
-
}
|
|
2115
|
+
updateComponentValue(vm, key, newValue);
|
|
2100
2116
|
},
|
|
2101
2117
|
enumerable: true,
|
|
2102
2118
|
configurable: true,
|
|
@@ -2201,7 +2217,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
2201
2217
|
}
|
|
2202
2218
|
|
|
2203
2219
|
if (set) {
|
|
2204
|
-
if (
|
|
2220
|
+
if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
|
|
2205
2221
|
let ro = vm.oar[key];
|
|
2206
2222
|
|
|
2207
2223
|
if (isUndefined$1(ro)) {
|
|
@@ -2258,9 +2274,7 @@ function internalTrackDecorator(key) {
|
|
|
2258
2274
|
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2259
2275
|
}
|
|
2260
2276
|
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
2261
|
-
|
|
2262
|
-
vm.cmpFields[key] = reactiveOrAnyValue;
|
|
2263
|
-
}
|
|
2277
|
+
updateComponentValue(vm, key, reactiveOrAnyValue);
|
|
2264
2278
|
},
|
|
2265
2279
|
enumerable: true,
|
|
2266
2280
|
configurable: true,
|
|
@@ -2298,9 +2312,7 @@ function internalWireFieldDecorator(key) {
|
|
|
2298
2312
|
* letting the author to do the wrong thing, but it will keep our
|
|
2299
2313
|
* system to be backward compatible.
|
|
2300
2314
|
*/
|
|
2301
|
-
|
|
2302
|
-
vm.cmpFields[key] = value;
|
|
2303
|
-
}
|
|
2315
|
+
updateComponentValue(vm, key, value);
|
|
2304
2316
|
},
|
|
2305
2317
|
enumerable: true,
|
|
2306
2318
|
configurable: true,
|
|
@@ -2784,7 +2796,7 @@ function getTemplateOrSwappedTemplate(tpl) {
|
|
|
2784
2796
|
throw new ReferenceError();
|
|
2785
2797
|
}
|
|
2786
2798
|
|
|
2787
|
-
if (
|
|
2799
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2788
2800
|
const visited = new Set();
|
|
2789
2801
|
|
|
2790
2802
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
@@ -2801,7 +2813,7 @@ function getComponentOrSwappedComponent(Ctor) {
|
|
|
2801
2813
|
throw new ReferenceError();
|
|
2802
2814
|
}
|
|
2803
2815
|
|
|
2804
|
-
if (
|
|
2816
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2805
2817
|
const visited = new Set();
|
|
2806
2818
|
|
|
2807
2819
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
@@ -2818,7 +2830,7 @@ function getStyleOrSwappedStyle(style) {
|
|
|
2818
2830
|
throw new ReferenceError();
|
|
2819
2831
|
}
|
|
2820
2832
|
|
|
2821
|
-
if (
|
|
2833
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2822
2834
|
const visited = new Set();
|
|
2823
2835
|
|
|
2824
2836
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
@@ -2835,7 +2847,7 @@ function setActiveVM(vm) {
|
|
|
2835
2847
|
throw new ReferenceError();
|
|
2836
2848
|
}
|
|
2837
2849
|
|
|
2838
|
-
if (
|
|
2850
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2839
2851
|
// tracking active component
|
|
2840
2852
|
const Ctor = vm.def.ctor;
|
|
2841
2853
|
let componentVMs = activeComponents.get(Ctor);
|
|
@@ -2892,7 +2904,7 @@ function removeActiveVM(vm) {
|
|
|
2892
2904
|
throw new ReferenceError();
|
|
2893
2905
|
}
|
|
2894
2906
|
|
|
2895
|
-
if (
|
|
2907
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2896
2908
|
// tracking inactive component
|
|
2897
2909
|
const Ctor = vm.def.ctor;
|
|
2898
2910
|
let list = activeComponents.get(Ctor);
|
|
@@ -3258,38 +3270,20 @@ function getScopeTokenClass(owner) {
|
|
|
3258
3270
|
const { cmpTemplate, context } = owner;
|
|
3259
3271
|
return (context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) || null;
|
|
3260
3272
|
}
|
|
3261
|
-
function getNearestNativeShadowComponent(vm) {
|
|
3262
|
-
const owner = getNearestShadowComponent(vm);
|
|
3263
|
-
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3264
|
-
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
3265
|
-
// synthetic, we know we won't find a native component if we go any further.
|
|
3266
|
-
return null;
|
|
3267
|
-
}
|
|
3268
|
-
return owner;
|
|
3269
|
-
}
|
|
3270
3273
|
function createStylesheet(vm, stylesheets) {
|
|
3271
|
-
const { renderMode, shadowMode, renderer: {
|
|
3274
|
+
const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
|
|
3272
3275
|
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3273
3276
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3274
3277
|
insertStylesheet(stylesheets[i]);
|
|
3275
3278
|
}
|
|
3276
3279
|
}
|
|
3277
|
-
else
|
|
3280
|
+
else {
|
|
3278
3281
|
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3279
3282
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3280
3283
|
// the first time the VM renders.
|
|
3281
3284
|
// native shadow or light DOM, SSR
|
|
3282
3285
|
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3283
3286
|
}
|
|
3284
|
-
else {
|
|
3285
|
-
// native shadow or light DOM, DOM renderer
|
|
3286
|
-
const root = getNearestNativeShadowComponent(vm);
|
|
3287
|
-
// null root means a global style
|
|
3288
|
-
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
3289
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
3290
|
-
insertStylesheet(stylesheets[i], target);
|
|
3291
|
-
}
|
|
3292
|
-
}
|
|
3293
3287
|
return null;
|
|
3294
3288
|
}
|
|
3295
3289
|
|
|
@@ -3299,30 +3293,67 @@ function createStylesheet(vm, stylesheets) {
|
|
|
3299
3293
|
* SPDX-License-Identifier: MIT
|
|
3300
3294
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3301
3295
|
*/
|
|
3296
|
+
|
|
3297
|
+
function checkHasVM(elm) {
|
|
3298
|
+
const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
3299
|
+
|
|
3300
|
+
if (process.env.NODE_ENV !== 'production' && !hasVM) {
|
|
3301
|
+
// Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
|
|
3302
|
+
// we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
|
|
3303
|
+
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.`);
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
return hasVM;
|
|
3307
|
+
}
|
|
3308
|
+
|
|
3302
3309
|
function getUpgradableConstructor(tagName, renderer) {
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3310
|
+
const {
|
|
3311
|
+
getCustomElement,
|
|
3312
|
+
HTMLElementExported: RendererHTMLElement,
|
|
3313
|
+
defineCustomElement
|
|
3314
|
+
} = renderer; // Should never get a tag with upper case letter at this point, the compiler should
|
|
3315
|
+
// produce only tags with lowercase letters
|
|
3316
|
+
// But, for backwards compatibility, we will lower case the tagName
|
|
3317
|
+
|
|
3318
|
+
tagName = tagName.toLowerCase();
|
|
3319
|
+
let CE = getCustomElement(tagName);
|
|
3320
|
+
|
|
3321
|
+
if (!isUndefined$1(CE)) {
|
|
3322
|
+
return CE;
|
|
3323
|
+
}
|
|
3324
|
+
/**
|
|
3325
|
+
* LWC Upgradable Element reference to an element that was created
|
|
3326
|
+
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3327
|
+
*/
|
|
3328
|
+
|
|
3329
|
+
|
|
3330
|
+
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3331
|
+
constructor(upgradeCallback) {
|
|
3332
|
+
super();
|
|
3333
|
+
|
|
3334
|
+
if (isFunction$1(upgradeCallback)) {
|
|
3335
|
+
upgradeCallback(this); // nothing to do with the result for now
|
|
3336
|
+
}
|
|
3311
3337
|
}
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
CE =
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
upgradeCallback(this); // nothing to do with the result for now
|
|
3321
|
-
}
|
|
3322
|
-
}
|
|
3338
|
+
|
|
3339
|
+
};
|
|
3340
|
+
|
|
3341
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3342
|
+
CE.prototype.connectedCallback = function () {
|
|
3343
|
+
if (checkHasVM(this)) {
|
|
3344
|
+
connectRootElement(this);
|
|
3345
|
+
}
|
|
3323
3346
|
};
|
|
3324
|
-
|
|
3325
|
-
|
|
3347
|
+
|
|
3348
|
+
CE.prototype.disconnectedCallback = function () {
|
|
3349
|
+
if (checkHasVM(this)) {
|
|
3350
|
+
disconnectRootElement(this);
|
|
3351
|
+
}
|
|
3352
|
+
};
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
defineCustomElement(tagName, CE);
|
|
3356
|
+
return CE;
|
|
3326
3357
|
}
|
|
3327
3358
|
|
|
3328
3359
|
/*
|
|
@@ -3568,569 +3599,790 @@ function applyStaticStyleAttribute(vnode, renderer) {
|
|
|
3568
3599
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3569
3600
|
*/
|
|
3570
3601
|
function patchChildren(c1, c2, parent, renderer) {
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
}
|
|
3602
|
+
if (hasDynamicChildren(c2)) {
|
|
3603
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
3604
|
+
} else {
|
|
3605
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
3606
|
+
}
|
|
3577
3607
|
}
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
break;
|
|
3596
|
-
case 1 /* VNodeType.Comment */:
|
|
3597
|
-
// VComment has no special capability, fallback to the owner's renderer
|
|
3598
|
-
patchComment(n1, n2, renderer);
|
|
3599
|
-
break;
|
|
3600
|
-
case 4 /* VNodeType.Static */:
|
|
3601
|
-
n2.elm = n1.elm;
|
|
3602
|
-
break;
|
|
3603
|
-
case 2 /* VNodeType.Element */:
|
|
3604
|
-
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3605
|
-
break;
|
|
3606
|
-
case 3 /* VNodeType.CustomElement */:
|
|
3607
|
-
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3608
|
-
break;
|
|
3608
|
+
|
|
3609
|
+
function patch(n1, n2, parent, renderer) {
|
|
3610
|
+
var _a, _b;
|
|
3611
|
+
|
|
3612
|
+
if (n1 === n2) {
|
|
3613
|
+
return;
|
|
3614
|
+
}
|
|
3615
|
+
|
|
3616
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3617
|
+
if (!isSameVnode(n1, n2)) {
|
|
3618
|
+
throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
|
|
3619
|
+
sel: n1.sel,
|
|
3620
|
+
key: n1.key
|
|
3621
|
+
}) + ', ' + JSON.stringify({
|
|
3622
|
+
sel: n2.sel,
|
|
3623
|
+
key: n2.key
|
|
3624
|
+
}));
|
|
3609
3625
|
}
|
|
3626
|
+
}
|
|
3627
|
+
|
|
3628
|
+
switch (n2.type) {
|
|
3629
|
+
case 0
|
|
3630
|
+
/* VNodeType.Text */
|
|
3631
|
+
:
|
|
3632
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3633
|
+
patchText(n1, n2, renderer);
|
|
3634
|
+
break;
|
|
3635
|
+
|
|
3636
|
+
case 1
|
|
3637
|
+
/* VNodeType.Comment */
|
|
3638
|
+
:
|
|
3639
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3640
|
+
patchComment(n1, n2, renderer);
|
|
3641
|
+
break;
|
|
3642
|
+
|
|
3643
|
+
case 4
|
|
3644
|
+
/* VNodeType.Static */
|
|
3645
|
+
:
|
|
3646
|
+
n2.elm = n1.elm;
|
|
3647
|
+
break;
|
|
3648
|
+
|
|
3649
|
+
case 2
|
|
3650
|
+
/* VNodeType.Element */
|
|
3651
|
+
:
|
|
3652
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3653
|
+
break;
|
|
3654
|
+
|
|
3655
|
+
case 3
|
|
3656
|
+
/* VNodeType.CustomElement */
|
|
3657
|
+
:
|
|
3658
|
+
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3659
|
+
break;
|
|
3660
|
+
}
|
|
3610
3661
|
}
|
|
3662
|
+
|
|
3611
3663
|
function mount(node, parent, renderer, anchor) {
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3664
|
+
var _a, _b;
|
|
3665
|
+
|
|
3666
|
+
switch (node.type) {
|
|
3667
|
+
case 0
|
|
3668
|
+
/* VNodeType.Text */
|
|
3669
|
+
:
|
|
3670
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3671
|
+
mountText(node, parent, anchor, renderer);
|
|
3672
|
+
break;
|
|
3673
|
+
|
|
3674
|
+
case 1
|
|
3675
|
+
/* VNodeType.Comment */
|
|
3676
|
+
:
|
|
3677
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3678
|
+
mountComment(node, parent, anchor, renderer);
|
|
3679
|
+
break;
|
|
3680
|
+
|
|
3681
|
+
case 4
|
|
3682
|
+
/* VNodeType.Static */
|
|
3683
|
+
:
|
|
3684
|
+
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
3685
|
+
mountStatic(node, parent, anchor, renderer);
|
|
3686
|
+
break;
|
|
3687
|
+
|
|
3688
|
+
case 2
|
|
3689
|
+
/* VNodeType.Element */
|
|
3690
|
+
:
|
|
3691
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3692
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3693
|
+
break;
|
|
3694
|
+
|
|
3695
|
+
case 3
|
|
3696
|
+
/* VNodeType.CustomElement */
|
|
3697
|
+
:
|
|
3698
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3699
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3700
|
+
break;
|
|
3701
|
+
}
|
|
3635
3702
|
}
|
|
3703
|
+
|
|
3636
3704
|
function patchText(n1, n2, renderer) {
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3705
|
+
n2.elm = n1.elm;
|
|
3706
|
+
|
|
3707
|
+
if (n2.text !== n1.text) {
|
|
3708
|
+
updateTextContent(n2, renderer);
|
|
3709
|
+
}
|
|
3641
3710
|
}
|
|
3711
|
+
|
|
3642
3712
|
function mountText(vnode, parent, anchor, renderer) {
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3713
|
+
const {
|
|
3714
|
+
owner
|
|
3715
|
+
} = vnode;
|
|
3716
|
+
const {
|
|
3717
|
+
createText
|
|
3718
|
+
} = renderer;
|
|
3719
|
+
const textNode = vnode.elm = createText(vnode.text);
|
|
3720
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
3721
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
3648
3722
|
}
|
|
3723
|
+
|
|
3649
3724
|
function patchComment(n1, n2, renderer) {
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3725
|
+
n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3726
|
+
// it is the case today.
|
|
3727
|
+
|
|
3728
|
+
if (n2.text !== n1.text) {
|
|
3729
|
+
updateTextContent(n2, renderer);
|
|
3730
|
+
}
|
|
3656
3731
|
}
|
|
3732
|
+
|
|
3657
3733
|
function mountComment(vnode, parent, anchor, renderer) {
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3734
|
+
const {
|
|
3735
|
+
owner
|
|
3736
|
+
} = vnode;
|
|
3737
|
+
const {
|
|
3738
|
+
createComment
|
|
3739
|
+
} = renderer;
|
|
3740
|
+
const commentNode = vnode.elm = createComment(vnode.text);
|
|
3741
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
3742
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
3663
3743
|
}
|
|
3744
|
+
|
|
3664
3745
|
function mountElement(vnode, parent, anchor, renderer) {
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3746
|
+
const {
|
|
3747
|
+
sel,
|
|
3748
|
+
owner,
|
|
3749
|
+
data: {
|
|
3750
|
+
svg
|
|
3751
|
+
}
|
|
3752
|
+
} = vnode;
|
|
3753
|
+
const {
|
|
3754
|
+
createElement
|
|
3755
|
+
} = renderer;
|
|
3756
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
3757
|
+
const elm = vnode.elm = createElement(sel, namespace);
|
|
3758
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3759
|
+
applyStyleScoping(elm, owner, renderer);
|
|
3760
|
+
applyDomManual(elm, vnode);
|
|
3761
|
+
applyElementRestrictions(elm, vnode);
|
|
3762
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3763
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3764
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3676
3765
|
}
|
|
3766
|
+
|
|
3677
3767
|
function patchElement(n1, n2, renderer) {
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3768
|
+
const elm = n2.elm = n1.elm;
|
|
3769
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3770
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3681
3771
|
}
|
|
3772
|
+
|
|
3682
3773
|
function mountStatic(vnode, parent, anchor, renderer) {
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3774
|
+
const {
|
|
3775
|
+
owner
|
|
3776
|
+
} = vnode;
|
|
3777
|
+
const {
|
|
3778
|
+
cloneNode,
|
|
3779
|
+
isSyntheticShadowDefined
|
|
3780
|
+
} = renderer;
|
|
3781
|
+
const elm = vnode.elm = cloneNode(vnode.fragment, true);
|
|
3782
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3783
|
+
applyElementRestrictions(elm, vnode); // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
3784
|
+
|
|
3785
|
+
const {
|
|
3786
|
+
renderMode,
|
|
3787
|
+
shadowMode
|
|
3788
|
+
} = owner;
|
|
3789
|
+
|
|
3790
|
+
if (isSyntheticShadowDefined) {
|
|
3791
|
+
if (shadowMode === 1
|
|
3792
|
+
/* ShadowMode.Synthetic */
|
|
3793
|
+
|| renderMode === 0
|
|
3794
|
+
/* RenderMode.Light */
|
|
3795
|
+
) {
|
|
3796
|
+
elm[KEY__SHADOW_STATIC] = true;
|
|
3694
3797
|
}
|
|
3695
|
-
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3696
3801
|
}
|
|
3802
|
+
|
|
3697
3803
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3804
|
+
const {
|
|
3805
|
+
sel,
|
|
3806
|
+
owner
|
|
3807
|
+
} = vnode;
|
|
3808
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
3809
|
+
/**
|
|
3810
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3811
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
3812
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
3813
|
+
* an upgradable custom element.
|
|
3814
|
+
*/
|
|
3815
|
+
|
|
3816
|
+
let vm;
|
|
3817
|
+
const elm = new UpgradableConstructor(elm => {
|
|
3818
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
3819
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
3820
|
+
});
|
|
3821
|
+
vnode.elm = elm;
|
|
3822
|
+
vnode.vm = vm;
|
|
3823
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3824
|
+
applyStyleScoping(elm, owner, renderer);
|
|
3825
|
+
|
|
3826
|
+
if (vm) {
|
|
3827
|
+
allocateChildren(vnode, vm);
|
|
3828
|
+
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
3829
|
+
throw new TypeError(`Incorrect Component Constructor`);
|
|
3830
|
+
}
|
|
3831
|
+
|
|
3832
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3833
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3834
|
+
|
|
3835
|
+
if (vm) {
|
|
3836
|
+
{
|
|
3837
|
+
// On the server, we don't have native custom element lifecycle callbacks, so we must
|
|
3838
|
+
// manually invoke the connectedCallback for a child component.
|
|
3839
|
+
runConnectedCallback(vm);
|
|
3732
3840
|
}
|
|
3841
|
+
}
|
|
3842
|
+
|
|
3843
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3844
|
+
|
|
3845
|
+
if (vm) {
|
|
3846
|
+
appendVM(vm);
|
|
3847
|
+
}
|
|
3733
3848
|
}
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3849
|
+
|
|
3850
|
+
function patchCustomElement(n1, n2, parent, renderer) {
|
|
3851
|
+
if (n1.ctor !== n2.ctor) {
|
|
3852
|
+
// If the constructor, unmount the current component and mount a new one using the new
|
|
3853
|
+
// constructor.
|
|
3854
|
+
const anchor = renderer.nextSibling(n1.elm);
|
|
3855
|
+
unmount(n1, parent, renderer, true);
|
|
3856
|
+
mountCustomElement(n2, parent, anchor, renderer);
|
|
3857
|
+
} else {
|
|
3858
|
+
// Otherwise patch the existing component with new props/attrs/etc.
|
|
3859
|
+
const elm = n2.elm = n1.elm;
|
|
3860
|
+
const vm = n2.vm = n1.vm;
|
|
3737
3861
|
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3862
|
+
|
|
3738
3863
|
if (!isUndefined$1(vm)) {
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
}
|
|
3743
|
-
// in fallback mode, the children will be always empty, so, nothing
|
|
3864
|
+
// in fallback mode, the allocation will always set children to
|
|
3865
|
+
// empty and delegate the real allocation to the slot elements
|
|
3866
|
+
allocateChildren(n2, vm);
|
|
3867
|
+
} // in fallback mode, the children will be always empty, so, nothing
|
|
3744
3868
|
// will happen, but in native, it does allocate the light dom
|
|
3869
|
+
|
|
3870
|
+
|
|
3745
3871
|
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3872
|
+
|
|
3746
3873
|
if (!isUndefined$1(vm)) {
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3874
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3875
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
3876
|
+
rerenderVM(vm);
|
|
3750
3877
|
}
|
|
3878
|
+
}
|
|
3751
3879
|
}
|
|
3880
|
+
|
|
3752
3881
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3882
|
+
for (; start < end; ++start) {
|
|
3883
|
+
const vnode = vnodes[start];
|
|
3884
|
+
|
|
3885
|
+
if (isVNode(vnode)) {
|
|
3886
|
+
mount(vnode, parent, renderer, anchor);
|
|
3758
3887
|
}
|
|
3888
|
+
}
|
|
3759
3889
|
}
|
|
3890
|
+
|
|
3760
3891
|
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3892
|
+
const {
|
|
3893
|
+
type,
|
|
3894
|
+
elm,
|
|
3895
|
+
sel
|
|
3896
|
+
} = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3897
|
+
// subtree root, is the only element worth unmounting from the subtree.
|
|
3898
|
+
|
|
3899
|
+
if (doRemove) {
|
|
3900
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
3901
|
+
// but the removal used here is from the owner instead.
|
|
3902
|
+
removeNode(elm, parent, renderer);
|
|
3903
|
+
}
|
|
3904
|
+
|
|
3905
|
+
switch (type) {
|
|
3906
|
+
case 2
|
|
3907
|
+
/* VNodeType.Element */
|
|
3908
|
+
:
|
|
3909
|
+
{
|
|
3910
|
+
// Slot content is removed to trigger slotchange event when removing slot.
|
|
3911
|
+
// Only required for synthetic shadow.
|
|
3912
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
|
|
3913
|
+
/* ShadowMode.Synthetic */
|
|
3914
|
+
;
|
|
3915
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
3916
|
+
break;
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3919
|
+
case 3
|
|
3920
|
+
/* VNodeType.CustomElement */
|
|
3921
|
+
:
|
|
3922
|
+
{
|
|
3923
|
+
const {
|
|
3924
|
+
vm
|
|
3925
|
+
} = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
|
|
3926
|
+
// children.
|
|
3927
|
+
|
|
3928
|
+
if (!isUndefined$1(vm)) {
|
|
3929
|
+
removeVM(vm);
|
|
3784
3930
|
}
|
|
3785
|
-
|
|
3931
|
+
}
|
|
3932
|
+
}
|
|
3786
3933
|
}
|
|
3934
|
+
|
|
3787
3935
|
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3936
|
+
for (; start < end; ++start) {
|
|
3937
|
+
const ch = vnodes[start];
|
|
3938
|
+
|
|
3939
|
+
if (isVNode(ch)) {
|
|
3940
|
+
unmount(ch, parent, renderer, doRemove);
|
|
3793
3941
|
}
|
|
3942
|
+
}
|
|
3794
3943
|
}
|
|
3944
|
+
|
|
3795
3945
|
function isVNode(vnode) {
|
|
3796
|
-
|
|
3946
|
+
return vnode != null;
|
|
3797
3947
|
}
|
|
3948
|
+
|
|
3798
3949
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3950
|
+
const {
|
|
3951
|
+
renderRoot,
|
|
3952
|
+
renderMode,
|
|
3953
|
+
shadowMode
|
|
3954
|
+
} = owner;
|
|
3955
|
+
const {
|
|
3956
|
+
isSyntheticShadowDefined
|
|
3957
|
+
} = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
|
|
3958
|
+
|
|
3959
|
+
if (isSyntheticShadowDefined) {
|
|
3960
|
+
if (shadowMode === 1
|
|
3961
|
+
/* ShadowMode.Synthetic */
|
|
3962
|
+
|| renderMode === 0
|
|
3963
|
+
/* RenderMode.Light */
|
|
3964
|
+
) {
|
|
3965
|
+
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
3806
3966
|
}
|
|
3967
|
+
}
|
|
3807
3968
|
}
|
|
3969
|
+
|
|
3808
3970
|
function updateTextContent(vnode, renderer) {
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
setText
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3971
|
+
const {
|
|
3972
|
+
elm,
|
|
3973
|
+
text
|
|
3974
|
+
} = vnode;
|
|
3975
|
+
const {
|
|
3976
|
+
setText
|
|
3977
|
+
} = renderer;
|
|
3978
|
+
|
|
3979
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3980
|
+
unlockDomMutation();
|
|
3981
|
+
}
|
|
3982
|
+
|
|
3983
|
+
setText(elm, text);
|
|
3984
|
+
|
|
3985
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3986
|
+
lockDomMutation();
|
|
3987
|
+
}
|
|
3818
3988
|
}
|
|
3989
|
+
|
|
3819
3990
|
function insertNode(node, parent, anchor, renderer) {
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3991
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3992
|
+
unlockDomMutation();
|
|
3993
|
+
}
|
|
3994
|
+
|
|
3995
|
+
renderer.insert(node, parent, anchor);
|
|
3996
|
+
|
|
3997
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3998
|
+
lockDomMutation();
|
|
3999
|
+
}
|
|
3827
4000
|
}
|
|
4001
|
+
|
|
3828
4002
|
function removeNode(node, parent, renderer) {
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
4003
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4004
|
+
unlockDomMutation();
|
|
4005
|
+
}
|
|
4006
|
+
|
|
4007
|
+
renderer.remove(node, parent);
|
|
4008
|
+
|
|
4009
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4010
|
+
lockDomMutation();
|
|
4011
|
+
}
|
|
3836
4012
|
}
|
|
4013
|
+
|
|
3837
4014
|
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
4015
|
+
if (isNull(oldVnode)) {
|
|
4016
|
+
applyEventListeners(vnode, renderer);
|
|
4017
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
4018
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
4019
|
+
} // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
4020
|
+
// value is set before type=radio.
|
|
4021
|
+
|
|
4022
|
+
|
|
4023
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
4024
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
4025
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
4026
|
+
patchProps(oldVnode, vnode, renderer);
|
|
3849
4027
|
}
|
|
4028
|
+
|
|
3850
4029
|
function applyStyleScoping(elm, owner, renderer) {
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
4030
|
+
// Set the class name for `*.scoped.css` style scoping.
|
|
4031
|
+
const scopeToken = getScopeTokenClass(owner);
|
|
4032
|
+
|
|
4033
|
+
if (!isNull(scopeToken)) {
|
|
4034
|
+
const {
|
|
4035
|
+
getClassList
|
|
4036
|
+
} = renderer; // TODO [#2762]: this dot notation with add is probably problematic
|
|
4037
|
+
// probably we should have a renderer api for just the add operation
|
|
4038
|
+
|
|
4039
|
+
getClassList(elm).add(scopeToken);
|
|
4040
|
+
} // Set property element for synthetic shadow DOM style scoping.
|
|
4041
|
+
|
|
4042
|
+
|
|
4043
|
+
const {
|
|
4044
|
+
stylesheetToken: syntheticToken
|
|
4045
|
+
} = owner.context;
|
|
4046
|
+
|
|
4047
|
+
if (owner.shadowMode === 1
|
|
4048
|
+
/* ShadowMode.Synthetic */
|
|
4049
|
+
&& !isUndefined$1(syntheticToken)) {
|
|
4050
|
+
elm.$shadowToken$ = syntheticToken;
|
|
4051
|
+
}
|
|
3864
4052
|
}
|
|
4053
|
+
|
|
3865
4054
|
function applyDomManual(elm, vnode) {
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
4055
|
+
var _a;
|
|
4056
|
+
|
|
4057
|
+
const {
|
|
4058
|
+
owner,
|
|
4059
|
+
data: {
|
|
4060
|
+
context
|
|
3870
4061
|
}
|
|
4062
|
+
} = vnode;
|
|
4063
|
+
|
|
4064
|
+
if (owner.shadowMode === 1
|
|
4065
|
+
/* ShadowMode.Synthetic */
|
|
4066
|
+
&& ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
|
|
4067
|
+
/* LwcDomMode.Manual */
|
|
4068
|
+
) {
|
|
4069
|
+
elm.$domManual$ = true;
|
|
4070
|
+
}
|
|
3871
4071
|
}
|
|
4072
|
+
|
|
3872
4073
|
function applyElementRestrictions(elm, vnode) {
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
4074
|
+
var _a, _b;
|
|
4075
|
+
|
|
4076
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4077
|
+
const isPortal = vnode.type === 2
|
|
4078
|
+
/* VNodeType.Element */
|
|
4079
|
+
&& ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
|
|
4080
|
+
/* LwcDomMode.Manual */
|
|
4081
|
+
;
|
|
4082
|
+
const isLight = vnode.owner.renderMode === 0
|
|
4083
|
+
/* RenderMode.Light */
|
|
4084
|
+
;
|
|
4085
|
+
patchElementWithRestrictions(elm, {
|
|
4086
|
+
isPortal,
|
|
4087
|
+
isLight
|
|
4088
|
+
});
|
|
4089
|
+
}
|
|
3882
4090
|
}
|
|
4091
|
+
|
|
3883
4092
|
function allocateChildren(vnode, vm) {
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
4093
|
+
// A component with slots will re-render because:
|
|
4094
|
+
// 1- There is a change of the internal state.
|
|
4095
|
+
// 2- There is a change on the external api (ex: slots)
|
|
4096
|
+
//
|
|
4097
|
+
// In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
|
|
4098
|
+
// slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
|
|
4099
|
+
// in a reused VCustomElement, there won't be any slotted children.
|
|
4100
|
+
// For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
|
|
4101
|
+
//
|
|
4102
|
+
// In case #2, we will always get a fresh VCustomElement.
|
|
4103
|
+
const children = vnode.aChildren || vnode.children;
|
|
4104
|
+
vm.aChildren = children;
|
|
4105
|
+
const {
|
|
4106
|
+
renderMode,
|
|
4107
|
+
shadowMode
|
|
4108
|
+
} = vm;
|
|
4109
|
+
|
|
4110
|
+
if (shadowMode === 1
|
|
4111
|
+
/* ShadowMode.Synthetic */
|
|
4112
|
+
|| renderMode === 0
|
|
4113
|
+
/* RenderMode.Light */
|
|
4114
|
+
) {
|
|
4115
|
+
// slow path
|
|
4116
|
+
allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
|
|
4117
|
+
|
|
4118
|
+
vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4119
|
+
|
|
4120
|
+
vnode.children = EmptyArray;
|
|
4121
|
+
}
|
|
3905
4122
|
}
|
|
4123
|
+
|
|
3906
4124
|
function createViewModelHook(elm, vnode, renderer) {
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
return vm;
|
|
3913
|
-
}
|
|
3914
|
-
const { sel, mode, ctor, owner } = vnode;
|
|
3915
|
-
vm = createVM(elm, ctor, renderer, {
|
|
3916
|
-
mode,
|
|
3917
|
-
owner,
|
|
3918
|
-
tagName: sel,
|
|
3919
|
-
});
|
|
3920
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3921
|
-
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
3922
|
-
}
|
|
4125
|
+
let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
|
|
4126
|
+
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
4127
|
+
// called right after invoking `document.createElement`.
|
|
4128
|
+
|
|
4129
|
+
if (!isUndefined$1(vm)) {
|
|
3923
4130
|
return vm;
|
|
4131
|
+
}
|
|
4132
|
+
|
|
4133
|
+
const {
|
|
4134
|
+
sel,
|
|
4135
|
+
mode,
|
|
4136
|
+
ctor,
|
|
4137
|
+
owner
|
|
4138
|
+
} = vnode;
|
|
4139
|
+
vm = createVM(elm, ctor, renderer, {
|
|
4140
|
+
mode,
|
|
4141
|
+
owner,
|
|
4142
|
+
tagName: sel
|
|
4143
|
+
});
|
|
4144
|
+
|
|
4145
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4146
|
+
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
return vm;
|
|
3924
4150
|
}
|
|
4151
|
+
|
|
3925
4152
|
function allocateInSlot(vm, children) {
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
4153
|
+
var _a;
|
|
4154
|
+
|
|
4155
|
+
const {
|
|
4156
|
+
cmpSlots: oldSlots
|
|
4157
|
+
} = vm;
|
|
4158
|
+
const cmpSlots = vm.cmpSlots = create(null);
|
|
4159
|
+
|
|
4160
|
+
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4161
|
+
const vnode = children[i];
|
|
4162
|
+
|
|
4163
|
+
if (isNull(vnode)) {
|
|
4164
|
+
continue;
|
|
4165
|
+
}
|
|
4166
|
+
|
|
4167
|
+
let slotName = '';
|
|
4168
|
+
|
|
4169
|
+
if (isVBaseElement(vnode)) {
|
|
4170
|
+
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
|
|
4171
|
+
}
|
|
4172
|
+
|
|
4173
|
+
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
|
|
4174
|
+
ArrayPush$1.call(vnodes, vnode);
|
|
4175
|
+
}
|
|
4176
|
+
|
|
4177
|
+
if (isFalse(vm.isDirty)) {
|
|
4178
|
+
// We need to determine if the old allocation is really different from the new one
|
|
4179
|
+
// and mark the vm as dirty
|
|
4180
|
+
const oldKeys = keys(oldSlots);
|
|
4181
|
+
|
|
4182
|
+
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
4183
|
+
markComponentAsDirty(vm);
|
|
4184
|
+
return;
|
|
4185
|
+
}
|
|
4186
|
+
|
|
4187
|
+
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4188
|
+
const key = oldKeys[i];
|
|
4189
|
+
|
|
4190
|
+
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
4191
|
+
markComponentAsDirty(vm);
|
|
4192
|
+
return;
|
|
4193
|
+
}
|
|
4194
|
+
|
|
4195
|
+
const oldVNodes = oldSlots[key];
|
|
4196
|
+
const vnodes = cmpSlots[key];
|
|
4197
|
+
|
|
4198
|
+
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
4199
|
+
if (oldVNodes[j] !== vnodes[j]) {
|
|
4200
|
+
markComponentAsDirty(vm);
|
|
4201
|
+
return;
|
|
3963
4202
|
}
|
|
4203
|
+
}
|
|
3964
4204
|
}
|
|
3965
|
-
}
|
|
3966
|
-
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
3967
|
-
|
|
3968
|
-
|
|
4205
|
+
}
|
|
4206
|
+
} // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4207
|
+
|
|
4208
|
+
|
|
4209
|
+
const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
|
|
3969
4210
|
// in a template, and will require a more complex diffing algo.
|
|
4211
|
+
|
|
3970
4212
|
function markAsDynamicChildren(children) {
|
|
3971
|
-
|
|
4213
|
+
FromIteration.set(children, 1);
|
|
3972
4214
|
}
|
|
4215
|
+
|
|
3973
4216
|
function hasDynamicChildren(children) {
|
|
3974
|
-
|
|
4217
|
+
return FromIteration.has(children);
|
|
3975
4218
|
}
|
|
4219
|
+
|
|
3976
4220
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
4221
|
+
const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
4222
|
+
|
|
4223
|
+
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
4224
|
+
const ch = children[j];
|
|
4225
|
+
|
|
4226
|
+
if (isVNode(ch)) {
|
|
4227
|
+
const {
|
|
4228
|
+
key
|
|
4229
|
+
} = ch;
|
|
4230
|
+
|
|
4231
|
+
if (key !== undefined) {
|
|
4232
|
+
map[key] = j;
|
|
4233
|
+
}
|
|
3987
4234
|
}
|
|
3988
|
-
|
|
4235
|
+
}
|
|
4236
|
+
|
|
4237
|
+
return map;
|
|
3989
4238
|
}
|
|
4239
|
+
|
|
3990
4240
|
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
}
|
|
4070
|
-
// We've already cloned at least once, so it's no longer read-only
|
|
4071
|
-
oldCh[idxInOld] = undefined;
|
|
4072
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4073
|
-
}
|
|
4074
|
-
}
|
|
4075
|
-
newStartVnode = newCh[++newStartIdx];
|
|
4076
|
-
}
|
|
4241
|
+
let oldStartIdx = 0;
|
|
4242
|
+
let newStartIdx = 0;
|
|
4243
|
+
let oldEndIdx = oldCh.length - 1;
|
|
4244
|
+
let oldStartVnode = oldCh[0];
|
|
4245
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
4246
|
+
const newChEnd = newCh.length - 1;
|
|
4247
|
+
let newEndIdx = newChEnd;
|
|
4248
|
+
let newStartVnode = newCh[0];
|
|
4249
|
+
let newEndVnode = newCh[newEndIdx];
|
|
4250
|
+
let oldKeyToIdx;
|
|
4251
|
+
let idxInOld;
|
|
4252
|
+
let elmToMove;
|
|
4253
|
+
let before;
|
|
4254
|
+
let clonedOldCh = false;
|
|
4255
|
+
|
|
4256
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
4257
|
+
if (!isVNode(oldStartVnode)) {
|
|
4258
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
4259
|
+
} else if (!isVNode(oldEndVnode)) {
|
|
4260
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4261
|
+
} else if (!isVNode(newStartVnode)) {
|
|
4262
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4263
|
+
} else if (!isVNode(newEndVnode)) {
|
|
4264
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4265
|
+
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
4266
|
+
patch(oldStartVnode, newStartVnode, parent, renderer);
|
|
4267
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4268
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4269
|
+
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
4270
|
+
patch(oldEndVnode, newEndVnode, parent, renderer);
|
|
4271
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4272
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4273
|
+
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
4274
|
+
// Vnode moved right
|
|
4275
|
+
patch(oldStartVnode, newEndVnode, parent, renderer);
|
|
4276
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
4277
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4278
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4279
|
+
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
4280
|
+
// Vnode moved left
|
|
4281
|
+
patch(oldEndVnode, newStartVnode, parent, renderer);
|
|
4282
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
4283
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4284
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4285
|
+
} else {
|
|
4286
|
+
if (oldKeyToIdx === undefined) {
|
|
4287
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
4288
|
+
}
|
|
4289
|
+
|
|
4290
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
4291
|
+
|
|
4292
|
+
if (isUndefined$1(idxInOld)) {
|
|
4293
|
+
// New element
|
|
4294
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4295
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4296
|
+
} else {
|
|
4297
|
+
elmToMove = oldCh[idxInOld];
|
|
4298
|
+
|
|
4299
|
+
if (isVNode(elmToMove)) {
|
|
4300
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4301
|
+
// New element
|
|
4302
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4303
|
+
} else {
|
|
4304
|
+
patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
|
|
4305
|
+
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4306
|
+
// so we only care about the `oldCh` object inside this function.
|
|
4307
|
+
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4308
|
+
// and only clone once.
|
|
4309
|
+
|
|
4310
|
+
if (!clonedOldCh) {
|
|
4311
|
+
clonedOldCh = true;
|
|
4312
|
+
oldCh = [...oldCh];
|
|
4313
|
+
} // We've already cloned at least once, so it's no longer read-only
|
|
4314
|
+
|
|
4315
|
+
|
|
4316
|
+
oldCh[idxInOld] = undefined;
|
|
4317
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4318
|
+
}
|
|
4077
4319
|
}
|
|
4320
|
+
|
|
4321
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4322
|
+
}
|
|
4078
4323
|
}
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4324
|
+
}
|
|
4325
|
+
|
|
4326
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
4327
|
+
if (oldStartIdx > oldEndIdx) {
|
|
4328
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
4329
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
4330
|
+
let i = newEndIdx;
|
|
4331
|
+
let n;
|
|
4332
|
+
|
|
4333
|
+
do {
|
|
4334
|
+
n = newCh[++i];
|
|
4335
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
4336
|
+
|
|
4337
|
+
before = isVNode(n) ? n.elm : null;
|
|
4338
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
4339
|
+
} else {
|
|
4340
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
4094
4341
|
}
|
|
4342
|
+
}
|
|
4095
4343
|
}
|
|
4344
|
+
|
|
4096
4345
|
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
anchor = n2.elm;
|
|
4131
|
-
}
|
|
4346
|
+
const c1Length = c1.length;
|
|
4347
|
+
const c2Length = c2.length;
|
|
4348
|
+
|
|
4349
|
+
if (c1Length === 0) {
|
|
4350
|
+
// the old list is empty, we can directly insert anything new
|
|
4351
|
+
mountVNodes(c2, parent, renderer, null);
|
|
4352
|
+
return;
|
|
4353
|
+
}
|
|
4354
|
+
|
|
4355
|
+
if (c2Length === 0) {
|
|
4356
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4357
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4358
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
4359
|
+
return;
|
|
4360
|
+
} // if the old list is not empty, the new list MUST have the same
|
|
4361
|
+
// amount of nodes, that's why we call this static children
|
|
4362
|
+
|
|
4363
|
+
|
|
4364
|
+
let anchor = null;
|
|
4365
|
+
|
|
4366
|
+
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
4367
|
+
const n1 = c1[i];
|
|
4368
|
+
const n2 = c2[i];
|
|
4369
|
+
|
|
4370
|
+
if (n2 !== n1) {
|
|
4371
|
+
if (isVNode(n1)) {
|
|
4372
|
+
if (isVNode(n2)) {
|
|
4373
|
+
// both vnodes are equivalent, and we just need to patch them
|
|
4374
|
+
patch(n1, n2, parent, renderer);
|
|
4375
|
+
anchor = n2.elm;
|
|
4376
|
+
} else {
|
|
4377
|
+
// removing the old vnode since the new one is null
|
|
4378
|
+
unmount(n1, parent, renderer, true);
|
|
4132
4379
|
}
|
|
4380
|
+
} else if (isVNode(n2)) {
|
|
4381
|
+
mount(n2, parent, renderer, anchor);
|
|
4382
|
+
anchor = n2.elm;
|
|
4383
|
+
}
|
|
4133
4384
|
}
|
|
4385
|
+
}
|
|
4134
4386
|
}
|
|
4135
4387
|
|
|
4136
4388
|
/*
|
|
@@ -4451,13 +4703,6 @@ function fid(url) {
|
|
|
4451
4703
|
}
|
|
4452
4704
|
return url;
|
|
4453
4705
|
}
|
|
4454
|
-
/**
|
|
4455
|
-
* Map to store an index value assigned to any dynamic component reference ingested
|
|
4456
|
-
* by dc() api. This allows us to generate a unique unique per template per dynamic
|
|
4457
|
-
* component reference to avoid diffing algo mismatches.
|
|
4458
|
-
*/
|
|
4459
|
-
const DynamicImportedComponentMap = new Map();
|
|
4460
|
-
let dynamicImportedComponentCounter = 0;
|
|
4461
4706
|
/**
|
|
4462
4707
|
* create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
4463
4708
|
*/
|
|
@@ -4474,18 +4719,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
|
|
|
4474
4719
|
if (!isComponentConstructor(Ctor)) {
|
|
4475
4720
|
throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
|
|
4476
4721
|
}
|
|
4477
|
-
|
|
4478
|
-
if (isUndefined$1(idx)) {
|
|
4479
|
-
idx = dynamicImportedComponentCounter++;
|
|
4480
|
-
DynamicImportedComponentMap.set(Ctor, idx);
|
|
4481
|
-
}
|
|
4482
|
-
// the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
|
|
4483
|
-
// to identify different constructors as vnodes with different keys to avoid reusing the
|
|
4484
|
-
// element used for previous constructors.
|
|
4485
|
-
// Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
|
|
4486
|
-
// hoisting optimization.
|
|
4487
|
-
const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
|
|
4488
|
-
return c(sel, Ctor, newData, children);
|
|
4722
|
+
return c(sel, Ctor, data, children);
|
|
4489
4723
|
}
|
|
4490
4724
|
/**
|
|
4491
4725
|
* slow children collection marking mechanism. this API allows the compiler to signal
|
|
@@ -5166,7 +5400,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5166
5400
|
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
5167
5401
|
};
|
|
5168
5402
|
|
|
5169
|
-
if (
|
|
5403
|
+
if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5170
5404
|
vm.shadowMode = 0
|
|
5171
5405
|
/* ShadowMode.Native */
|
|
5172
5406
|
;
|
|
@@ -5205,7 +5439,7 @@ function computeShadowMode(vm, renderer) {
|
|
|
5205
5439
|
} else if (isNativeShadowDefined) {
|
|
5206
5440
|
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
5207
5441
|
// the if-condition.
|
|
5208
|
-
if (
|
|
5442
|
+
if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
5209
5443
|
if (def.shadowSupportMode === "any"
|
|
5210
5444
|
/* ShadowSupportMode.Any */
|
|
5211
5445
|
) {
|
|
@@ -5321,46 +5555,7 @@ function patchShadowRoot(vm, newCh) {
|
|
|
5321
5555
|
|
|
5322
5556
|
if (vm.state === 1
|
|
5323
5557
|
/* VMState.connected */
|
|
5324
|
-
)
|
|
5325
|
-
// If the element is connected, that means connectedCallback was already issued, and
|
|
5326
|
-
// any successive rendering should finish with the call to renderedCallback, otherwise
|
|
5327
|
-
// the connectedCallback will take care of calling it in the right order at the end of
|
|
5328
|
-
// the current rehydration process.
|
|
5329
|
-
runRenderedCallback(vm);
|
|
5330
|
-
}
|
|
5331
|
-
}
|
|
5332
|
-
|
|
5333
|
-
function runRenderedCallback(vm) {
|
|
5334
|
-
const {
|
|
5335
|
-
def: {
|
|
5336
|
-
renderedCallback
|
|
5337
|
-
},
|
|
5338
|
-
renderer: {
|
|
5339
|
-
ssr
|
|
5340
|
-
}
|
|
5341
|
-
} = vm;
|
|
5342
|
-
|
|
5343
|
-
if (isTrue(ssr)) {
|
|
5344
|
-
return;
|
|
5345
|
-
}
|
|
5346
|
-
|
|
5347
|
-
const {
|
|
5348
|
-
rendered
|
|
5349
|
-
} = Services;
|
|
5350
|
-
|
|
5351
|
-
if (rendered) {
|
|
5352
|
-
invokeServiceHook(vm, rendered);
|
|
5353
|
-
}
|
|
5354
|
-
|
|
5355
|
-
if (!isUndefined$1(renderedCallback)) {
|
|
5356
|
-
logOperationStart(4
|
|
5357
|
-
/* OperationId.RenderedCallback */
|
|
5358
|
-
, vm);
|
|
5359
|
-
invokeComponentCallback(vm, renderedCallback);
|
|
5360
|
-
logOperationEnd(4
|
|
5361
|
-
/* OperationId.RenderedCallback */
|
|
5362
|
-
, vm);
|
|
5363
|
-
}
|
|
5558
|
+
) ;
|
|
5364
5559
|
}
|
|
5365
5560
|
|
|
5366
5561
|
function runConnectedCallback(vm) {
|
|
@@ -5627,14 +5822,8 @@ class WireContextRegistrationEvent extends CustomEvent {
|
|
|
5627
5822
|
}
|
|
5628
5823
|
|
|
5629
5824
|
function createFieldDataCallback(vm, name) {
|
|
5630
|
-
const {
|
|
5631
|
-
cmpFields
|
|
5632
|
-
} = vm;
|
|
5633
5825
|
return value => {
|
|
5634
|
-
|
|
5635
|
-
// storing the value in the underlying storage
|
|
5636
|
-
cmpFields[name] = value;
|
|
5637
|
-
}
|
|
5826
|
+
updateComponentValue(vm, name, value);
|
|
5638
5827
|
};
|
|
5639
5828
|
}
|
|
5640
5829
|
|
|
@@ -5839,7 +6028,7 @@ function installWireAdapters(vm) {
|
|
|
5839
6028
|
ArrayPush$1.call(wiredConnecting, () => {
|
|
5840
6029
|
connector.connect();
|
|
5841
6030
|
|
|
5842
|
-
if (!
|
|
6031
|
+
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
5843
6032
|
if (hasDynamicParams) {
|
|
5844
6033
|
Promise.resolve().then(computeConfigAndUpdate);
|
|
5845
6034
|
return;
|
|
@@ -6048,7 +6237,7 @@ function freezeTemplate(tmpl) {
|
|
|
6048
6237
|
});
|
|
6049
6238
|
}
|
|
6050
6239
|
}
|
|
6051
|
-
/* version: 2.
|
|
6240
|
+
/* version: 2.23.2 */
|
|
6052
6241
|
|
|
6053
6242
|
/*
|
|
6054
6243
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -6131,10 +6320,6 @@ class HTMLElementImpl {
|
|
|
6131
6320
|
return createElement(tagName);
|
|
6132
6321
|
}
|
|
6133
6322
|
}
|
|
6134
|
-
const ssr = true;
|
|
6135
|
-
function isHydrating() {
|
|
6136
|
-
return false;
|
|
6137
|
-
}
|
|
6138
6323
|
const isNativeShadowDefined = false;
|
|
6139
6324
|
const isSyntheticShadowDefined = false;
|
|
6140
6325
|
function insert(node, parent, anchor) {
|
|
@@ -6373,11 +6558,9 @@ const HTMLElementExported = HTMLElementImpl;
|
|
|
6373
6558
|
/* noop */
|
|
6374
6559
|
const assertInstanceOfHTMLElement = noop;
|
|
6375
6560
|
const renderer = {
|
|
6376
|
-
ssr,
|
|
6377
6561
|
isNativeShadowDefined,
|
|
6378
6562
|
isSyntheticShadowDefined,
|
|
6379
6563
|
HTMLElementExported,
|
|
6380
|
-
isHydrating,
|
|
6381
6564
|
insert,
|
|
6382
6565
|
remove,
|
|
6383
6566
|
cloneNode,
|
|
@@ -6524,6 +6707,6 @@ function renderComponent(tagName, Ctor, props = {}) {
|
|
|
6524
6707
|
*/
|
|
6525
6708
|
freeze(LightningElement);
|
|
6526
6709
|
seal(LightningElement.prototype);
|
|
6527
|
-
/* version: 2.
|
|
6710
|
+
/* version: 2.23.2 */
|
|
6528
6711
|
|
|
6529
6712
|
export { LightningElement, api$1 as api, createContextProvider, freezeTemplate, getComponentDef, isComponentConstructor, parseFragment, parseFragment as parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderComponent, renderer, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, track, unwrap, wire };
|