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