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
|
@@ -305,9 +305,13 @@
|
|
|
305
305
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
306
306
|
*/
|
|
307
307
|
// Increment whenever the LWC template compiler changes
|
|
308
|
-
const LWC_VERSION = "2.
|
|
308
|
+
const LWC_VERSION = "2.23.2";
|
|
309
309
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
310
|
-
/** version: 2.
|
|
310
|
+
/** version: 2.23.2 */
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Copyright (C) 2018 salesforce.com, inc.
|
|
314
|
+
*/
|
|
311
315
|
|
|
312
316
|
/*
|
|
313
317
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -316,7 +320,7 @@
|
|
|
316
320
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
317
321
|
*/
|
|
318
322
|
function detect(propName) {
|
|
319
|
-
return
|
|
323
|
+
return getOwnPropertyDescriptor$1(Element.prototype, propName) === undefined;
|
|
320
324
|
}
|
|
321
325
|
|
|
322
326
|
/*
|
|
@@ -385,6 +389,7 @@
|
|
|
385
389
|
patch$1(propName);
|
|
386
390
|
}
|
|
387
391
|
}
|
|
392
|
+
/** version: 2.23.2 */
|
|
388
393
|
|
|
389
394
|
/**
|
|
390
395
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -404,6 +409,7 @@
|
|
|
404
409
|
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
405
410
|
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
406
411
|
ENABLE_MIXED_SHADOW_MODE: null,
|
|
412
|
+
ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
|
|
407
413
|
ENABLE_NODE_LIST_PATCH: null,
|
|
408
414
|
ENABLE_NODE_PATCH: null,
|
|
409
415
|
ENABLE_REACTIVE_SETTER: null,
|
|
@@ -412,7 +418,7 @@
|
|
|
412
418
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
413
419
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
414
420
|
}
|
|
415
|
-
const
|
|
421
|
+
const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
|
|
416
422
|
/**
|
|
417
423
|
* Set the value at runtime of a given feature flag. This method only be invoked once per feature
|
|
418
424
|
* flag. It is meant to be used during the app initialization.
|
|
@@ -439,17 +445,17 @@
|
|
|
439
445
|
}
|
|
440
446
|
if (process.env.NODE_ENV !== 'production') {
|
|
441
447
|
// Allow the same flag to be set more than once outside of production to enable testing
|
|
442
|
-
|
|
448
|
+
lwcRuntimeFlags[name] = value;
|
|
443
449
|
}
|
|
444
450
|
else {
|
|
445
451
|
// Disallow the same flag to be set more than once in production
|
|
446
|
-
const runtimeValue =
|
|
452
|
+
const runtimeValue = lwcRuntimeFlags[name];
|
|
447
453
|
if (!isUndefined$1(runtimeValue)) {
|
|
448
454
|
// eslint-disable-next-line no-console
|
|
449
455
|
console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
|
|
450
456
|
return;
|
|
451
457
|
}
|
|
452
|
-
defineProperty(
|
|
458
|
+
defineProperty(lwcRuntimeFlags, name, { value });
|
|
453
459
|
}
|
|
454
460
|
}
|
|
455
461
|
/**
|
|
@@ -461,7 +467,7 @@
|
|
|
461
467
|
setFeatureFlag(name, value);
|
|
462
468
|
}
|
|
463
469
|
}
|
|
464
|
-
/** version: 2.
|
|
470
|
+
/** version: 2.23.2 */
|
|
465
471
|
|
|
466
472
|
/*
|
|
467
473
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -475,7 +481,7 @@
|
|
|
475
481
|
window.addEventListener('test-dummy-flag', () => {
|
|
476
482
|
let hasFlag = false;
|
|
477
483
|
|
|
478
|
-
if (
|
|
484
|
+
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
479
485
|
hasFlag = true;
|
|
480
486
|
}
|
|
481
487
|
|
|
@@ -502,7 +508,7 @@
|
|
|
502
508
|
window.addEventListener('test-dummy-flag', () => {
|
|
503
509
|
let hasFlag = false;
|
|
504
510
|
|
|
505
|
-
if (
|
|
511
|
+
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
506
512
|
hasFlag = true;
|
|
507
513
|
}
|
|
508
514
|
|
|
@@ -810,8 +816,8 @@
|
|
|
810
816
|
*/
|
|
811
817
|
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
812
818
|
// to inject at runtime.
|
|
813
|
-
const HTMLElementConstructor
|
|
814
|
-
const HTMLElementPrototype = HTMLElementConstructor
|
|
819
|
+
const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () { };
|
|
820
|
+
const HTMLElementPrototype = HTMLElementConstructor.prototype;
|
|
815
821
|
|
|
816
822
|
/*
|
|
817
823
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1266,6 +1272,14 @@
|
|
|
1266
1272
|
defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
1267
1273
|
}
|
|
1268
1274
|
|
|
1275
|
+
function updateComponentValue(vm, key, newValue) {
|
|
1276
|
+
const { cmpFields } = vm;
|
|
1277
|
+
if (newValue !== cmpFields[key]) {
|
|
1278
|
+
cmpFields[key] = newValue;
|
|
1279
|
+
componentValueMutated(vm, key);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1269
1283
|
/**
|
|
1270
1284
|
* Copyright (C) 2017 salesforce.com, inc.
|
|
1271
1285
|
*/
|
|
@@ -1898,10 +1912,7 @@
|
|
|
1898
1912
|
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1899
1913
|
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1900
1914
|
}
|
|
1901
|
-
|
|
1902
|
-
vm.cmpProps[propName] = newValue;
|
|
1903
|
-
componentValueMutated(vm, propName);
|
|
1904
|
-
}
|
|
1915
|
+
updateComponentValue(vm, propName, newValue);
|
|
1905
1916
|
return set.call(vm.elm, newValue);
|
|
1906
1917
|
},
|
|
1907
1918
|
};
|
|
@@ -2196,10 +2207,7 @@
|
|
|
2196
2207
|
},
|
|
2197
2208
|
set(newValue) {
|
|
2198
2209
|
const vm = getAssociatedVM(this);
|
|
2199
|
-
|
|
2200
|
-
vm.cmpFields[key] = newValue;
|
|
2201
|
-
componentValueMutated(vm, key);
|
|
2202
|
-
}
|
|
2210
|
+
updateComponentValue(vm, key, newValue);
|
|
2203
2211
|
},
|
|
2204
2212
|
enumerable: true,
|
|
2205
2213
|
configurable: true,
|
|
@@ -2328,7 +2336,7 @@
|
|
|
2328
2336
|
}
|
|
2329
2337
|
|
|
2330
2338
|
if (set) {
|
|
2331
|
-
if (
|
|
2339
|
+
if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
|
|
2332
2340
|
let ro = vm.oar[key];
|
|
2333
2341
|
|
|
2334
2342
|
if (isUndefined$1(ro)) {
|
|
@@ -2386,10 +2394,7 @@
|
|
|
2386
2394
|
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2387
2395
|
}
|
|
2388
2396
|
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
2389
|
-
|
|
2390
|
-
vm.cmpFields[key] = reactiveOrAnyValue;
|
|
2391
|
-
componentValueMutated(vm, key);
|
|
2392
|
-
}
|
|
2397
|
+
updateComponentValue(vm, key, reactiveOrAnyValue);
|
|
2393
2398
|
},
|
|
2394
2399
|
enumerable: true,
|
|
2395
2400
|
configurable: true,
|
|
@@ -2428,10 +2433,7 @@
|
|
|
2428
2433
|
* letting the author to do the wrong thing, but it will keep our
|
|
2429
2434
|
* system to be backward compatible.
|
|
2430
2435
|
*/
|
|
2431
|
-
|
|
2432
|
-
vm.cmpFields[key] = value;
|
|
2433
|
-
componentValueMutated(vm, key);
|
|
2434
|
-
}
|
|
2436
|
+
updateComponentValue(vm, key, value);
|
|
2435
2437
|
},
|
|
2436
2438
|
enumerable: true,
|
|
2437
2439
|
configurable: true,
|
|
@@ -2892,7 +2894,7 @@
|
|
|
2892
2894
|
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
2893
2895
|
return HTMLBridgeElement;
|
|
2894
2896
|
}
|
|
2895
|
-
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor
|
|
2897
|
+
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
|
|
2896
2898
|
freeze(BaseBridgeElement);
|
|
2897
2899
|
seal(BaseBridgeElement.prototype);
|
|
2898
2900
|
|
|
@@ -2986,7 +2988,7 @@
|
|
|
2986
2988
|
throw new ReferenceError();
|
|
2987
2989
|
}
|
|
2988
2990
|
|
|
2989
|
-
if (
|
|
2991
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2990
2992
|
const visited = new Set();
|
|
2991
2993
|
|
|
2992
2994
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
@@ -3003,7 +3005,7 @@
|
|
|
3003
3005
|
throw new ReferenceError();
|
|
3004
3006
|
}
|
|
3005
3007
|
|
|
3006
|
-
if (
|
|
3008
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3007
3009
|
const visited = new Set();
|
|
3008
3010
|
|
|
3009
3011
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
@@ -3020,7 +3022,7 @@
|
|
|
3020
3022
|
throw new ReferenceError();
|
|
3021
3023
|
}
|
|
3022
3024
|
|
|
3023
|
-
if (
|
|
3025
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3024
3026
|
const visited = new Set();
|
|
3025
3027
|
|
|
3026
3028
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
@@ -3037,7 +3039,7 @@
|
|
|
3037
3039
|
throw new ReferenceError();
|
|
3038
3040
|
}
|
|
3039
3041
|
|
|
3040
|
-
if (
|
|
3042
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3041
3043
|
// tracking active component
|
|
3042
3044
|
const Ctor = vm.def.ctor;
|
|
3043
3045
|
let componentVMs = activeComponents.get(Ctor);
|
|
@@ -3094,7 +3096,7 @@
|
|
|
3094
3096
|
throw new ReferenceError();
|
|
3095
3097
|
}
|
|
3096
3098
|
|
|
3097
|
-
if (
|
|
3099
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3098
3100
|
// tracking inactive component
|
|
3099
3101
|
const Ctor = vm.def.ctor;
|
|
3100
3102
|
let list = activeComponents.get(Ctor);
|
|
@@ -3141,7 +3143,7 @@
|
|
|
3141
3143
|
}
|
|
3142
3144
|
}
|
|
3143
3145
|
|
|
3144
|
-
if (!
|
|
3146
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3145
3147
|
throw new Error('HMR is not enabled');
|
|
3146
3148
|
}
|
|
3147
3149
|
|
|
@@ -3157,7 +3159,7 @@
|
|
|
3157
3159
|
}
|
|
3158
3160
|
}
|
|
3159
3161
|
|
|
3160
|
-
if (!
|
|
3162
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3161
3163
|
throw new Error('HMR is not enabled');
|
|
3162
3164
|
}
|
|
3163
3165
|
|
|
@@ -3171,7 +3173,7 @@
|
|
|
3171
3173
|
return rehydrateHotStyle(oldStyle);
|
|
3172
3174
|
}
|
|
3173
3175
|
|
|
3174
|
-
if (!
|
|
3176
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3175
3177
|
throw new Error('HMR is not enabled');
|
|
3176
3178
|
}
|
|
3177
3179
|
|
|
@@ -3520,13 +3522,13 @@
|
|
|
3520
3522
|
return owner;
|
|
3521
3523
|
}
|
|
3522
3524
|
function createStylesheet(vm, stylesheets) {
|
|
3523
|
-
const { renderMode, shadowMode, renderer: {
|
|
3525
|
+
const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
|
|
3524
3526
|
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3525
3527
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3526
3528
|
insertStylesheet(stylesheets[i]);
|
|
3527
3529
|
}
|
|
3528
3530
|
}
|
|
3529
|
-
else if (
|
|
3531
|
+
else if (vm.hydrated) {
|
|
3530
3532
|
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3531
3533
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3532
3534
|
// the first time the VM renders.
|
|
@@ -3551,30 +3553,67 @@
|
|
|
3551
3553
|
* SPDX-License-Identifier: MIT
|
|
3552
3554
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3553
3555
|
*/
|
|
3556
|
+
|
|
3557
|
+
function checkHasVM(elm) {
|
|
3558
|
+
const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
3559
|
+
|
|
3560
|
+
if (process.env.NODE_ENV !== 'production' && !hasVM) {
|
|
3561
|
+
// Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
|
|
3562
|
+
// we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
|
|
3563
|
+
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.`);
|
|
3564
|
+
}
|
|
3565
|
+
|
|
3566
|
+
return hasVM;
|
|
3567
|
+
}
|
|
3568
|
+
|
|
3554
3569
|
function getUpgradableConstructor(tagName, renderer) {
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3570
|
+
const {
|
|
3571
|
+
getCustomElement,
|
|
3572
|
+
HTMLElementExported: RendererHTMLElement,
|
|
3573
|
+
defineCustomElement
|
|
3574
|
+
} = renderer; // Should never get a tag with upper case letter at this point, the compiler should
|
|
3575
|
+
// produce only tags with lowercase letters
|
|
3576
|
+
// But, for backwards compatibility, we will lower case the tagName
|
|
3577
|
+
|
|
3578
|
+
tagName = tagName.toLowerCase();
|
|
3579
|
+
let CE = getCustomElement(tagName);
|
|
3580
|
+
|
|
3581
|
+
if (!isUndefined$1(CE)) {
|
|
3582
|
+
return CE;
|
|
3583
|
+
}
|
|
3584
|
+
/**
|
|
3585
|
+
* LWC Upgradable Element reference to an element that was created
|
|
3586
|
+
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3587
|
+
*/
|
|
3588
|
+
|
|
3589
|
+
|
|
3590
|
+
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3591
|
+
constructor(upgradeCallback) {
|
|
3592
|
+
super();
|
|
3593
|
+
|
|
3594
|
+
if (isFunction$1(upgradeCallback)) {
|
|
3595
|
+
upgradeCallback(this); // nothing to do with the result for now
|
|
3596
|
+
}
|
|
3563
3597
|
}
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
CE =
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
upgradeCallback(this); // nothing to do with the result for now
|
|
3573
|
-
}
|
|
3574
|
-
}
|
|
3598
|
+
|
|
3599
|
+
};
|
|
3600
|
+
|
|
3601
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3602
|
+
CE.prototype.connectedCallback = function () {
|
|
3603
|
+
if (checkHasVM(this)) {
|
|
3604
|
+
connectRootElement(this);
|
|
3605
|
+
}
|
|
3575
3606
|
};
|
|
3576
|
-
|
|
3577
|
-
|
|
3607
|
+
|
|
3608
|
+
CE.prototype.disconnectedCallback = function () {
|
|
3609
|
+
if (checkHasVM(this)) {
|
|
3610
|
+
disconnectRootElement(this);
|
|
3611
|
+
}
|
|
3612
|
+
};
|
|
3613
|
+
}
|
|
3614
|
+
|
|
3615
|
+
defineCustomElement(tagName, CE);
|
|
3616
|
+
return CE;
|
|
3578
3617
|
}
|
|
3579
3618
|
|
|
3580
3619
|
/*
|
|
@@ -3662,6 +3701,14 @@
|
|
|
3662
3701
|
// different than the one previously set.
|
|
3663
3702
|
if (isFirstPatch ||
|
|
3664
3703
|
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
|
|
3704
|
+
// Additional verification if properties are supported by the element
|
|
3705
|
+
// Validation relies on html properties and public properties being defined on the element,
|
|
3706
|
+
// SSR has its own custom validation.
|
|
3707
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3708
|
+
if (!(key in elm)) {
|
|
3709
|
+
logWarn(`Unknown public property "${key}" of element <${elm.tagName.toLowerCase()}>. This is either a typo on the corresponding attribute "${htmlPropertyToAttribute(key)}", or the attribute does not exist in this browser or DOM implementation.`);
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3665
3712
|
setProperty(elm, key, cur);
|
|
3666
3713
|
}
|
|
3667
3714
|
}
|
|
@@ -3820,569 +3867,798 @@
|
|
|
3820
3867
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3821
3868
|
*/
|
|
3822
3869
|
function patchChildren(c1, c2, parent, renderer) {
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
}
|
|
3870
|
+
if (hasDynamicChildren(c2)) {
|
|
3871
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
3872
|
+
} else {
|
|
3873
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
3874
|
+
}
|
|
3829
3875
|
}
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
break;
|
|
3848
|
-
case 1 /* VNodeType.Comment */:
|
|
3849
|
-
// VComment has no special capability, fallback to the owner's renderer
|
|
3850
|
-
patchComment(n1, n2, renderer);
|
|
3851
|
-
break;
|
|
3852
|
-
case 4 /* VNodeType.Static */:
|
|
3853
|
-
n2.elm = n1.elm;
|
|
3854
|
-
break;
|
|
3855
|
-
case 2 /* VNodeType.Element */:
|
|
3856
|
-
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3857
|
-
break;
|
|
3858
|
-
case 3 /* VNodeType.CustomElement */:
|
|
3859
|
-
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3860
|
-
break;
|
|
3876
|
+
|
|
3877
|
+
function patch(n1, n2, parent, renderer) {
|
|
3878
|
+
var _a, _b;
|
|
3879
|
+
|
|
3880
|
+
if (n1 === n2) {
|
|
3881
|
+
return;
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3884
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3885
|
+
if (!isSameVnode(n1, n2)) {
|
|
3886
|
+
throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
|
|
3887
|
+
sel: n1.sel,
|
|
3888
|
+
key: n1.key
|
|
3889
|
+
}) + ', ' + JSON.stringify({
|
|
3890
|
+
sel: n2.sel,
|
|
3891
|
+
key: n2.key
|
|
3892
|
+
}));
|
|
3861
3893
|
}
|
|
3894
|
+
}
|
|
3895
|
+
|
|
3896
|
+
switch (n2.type) {
|
|
3897
|
+
case 0
|
|
3898
|
+
/* VNodeType.Text */
|
|
3899
|
+
:
|
|
3900
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3901
|
+
patchText(n1, n2, renderer);
|
|
3902
|
+
break;
|
|
3903
|
+
|
|
3904
|
+
case 1
|
|
3905
|
+
/* VNodeType.Comment */
|
|
3906
|
+
:
|
|
3907
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3908
|
+
patchComment(n1, n2, renderer);
|
|
3909
|
+
break;
|
|
3910
|
+
|
|
3911
|
+
case 4
|
|
3912
|
+
/* VNodeType.Static */
|
|
3913
|
+
:
|
|
3914
|
+
n2.elm = n1.elm;
|
|
3915
|
+
break;
|
|
3916
|
+
|
|
3917
|
+
case 2
|
|
3918
|
+
/* VNodeType.Element */
|
|
3919
|
+
:
|
|
3920
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3921
|
+
break;
|
|
3922
|
+
|
|
3923
|
+
case 3
|
|
3924
|
+
/* VNodeType.CustomElement */
|
|
3925
|
+
:
|
|
3926
|
+
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3927
|
+
break;
|
|
3928
|
+
}
|
|
3862
3929
|
}
|
|
3930
|
+
|
|
3863
3931
|
function mount(node, parent, renderer, anchor) {
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3932
|
+
var _a, _b;
|
|
3933
|
+
|
|
3934
|
+
switch (node.type) {
|
|
3935
|
+
case 0
|
|
3936
|
+
/* VNodeType.Text */
|
|
3937
|
+
:
|
|
3938
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3939
|
+
mountText(node, parent, anchor, renderer);
|
|
3940
|
+
break;
|
|
3941
|
+
|
|
3942
|
+
case 1
|
|
3943
|
+
/* VNodeType.Comment */
|
|
3944
|
+
:
|
|
3945
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3946
|
+
mountComment(node, parent, anchor, renderer);
|
|
3947
|
+
break;
|
|
3948
|
+
|
|
3949
|
+
case 4
|
|
3950
|
+
/* VNodeType.Static */
|
|
3951
|
+
:
|
|
3952
|
+
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
3953
|
+
mountStatic(node, parent, anchor, renderer);
|
|
3954
|
+
break;
|
|
3955
|
+
|
|
3956
|
+
case 2
|
|
3957
|
+
/* VNodeType.Element */
|
|
3958
|
+
:
|
|
3959
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3960
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3961
|
+
break;
|
|
3962
|
+
|
|
3963
|
+
case 3
|
|
3964
|
+
/* VNodeType.CustomElement */
|
|
3965
|
+
:
|
|
3966
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3967
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3968
|
+
break;
|
|
3969
|
+
}
|
|
3887
3970
|
}
|
|
3971
|
+
|
|
3888
3972
|
function patchText(n1, n2, renderer) {
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3973
|
+
n2.elm = n1.elm;
|
|
3974
|
+
|
|
3975
|
+
if (n2.text !== n1.text) {
|
|
3976
|
+
updateTextContent(n2, renderer);
|
|
3977
|
+
}
|
|
3893
3978
|
}
|
|
3979
|
+
|
|
3894
3980
|
function mountText(vnode, parent, anchor, renderer) {
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3981
|
+
const {
|
|
3982
|
+
owner
|
|
3983
|
+
} = vnode;
|
|
3984
|
+
const {
|
|
3985
|
+
createText
|
|
3986
|
+
} = renderer;
|
|
3987
|
+
const textNode = vnode.elm = createText(vnode.text);
|
|
3988
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
3989
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
3900
3990
|
}
|
|
3991
|
+
|
|
3901
3992
|
function patchComment(n1, n2, renderer) {
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3993
|
+
n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3994
|
+
// it is the case today.
|
|
3995
|
+
|
|
3996
|
+
if (n2.text !== n1.text) {
|
|
3997
|
+
updateTextContent(n2, renderer);
|
|
3998
|
+
}
|
|
3908
3999
|
}
|
|
4000
|
+
|
|
3909
4001
|
function mountComment(vnode, parent, anchor, renderer) {
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
4002
|
+
const {
|
|
4003
|
+
owner
|
|
4004
|
+
} = vnode;
|
|
4005
|
+
const {
|
|
4006
|
+
createComment
|
|
4007
|
+
} = renderer;
|
|
4008
|
+
const commentNode = vnode.elm = createComment(vnode.text);
|
|
4009
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
4010
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
3915
4011
|
}
|
|
4012
|
+
|
|
3916
4013
|
function mountElement(vnode, parent, anchor, renderer) {
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
4014
|
+
const {
|
|
4015
|
+
sel,
|
|
4016
|
+
owner,
|
|
4017
|
+
data: {
|
|
4018
|
+
svg
|
|
4019
|
+
}
|
|
4020
|
+
} = vnode;
|
|
4021
|
+
const {
|
|
4022
|
+
createElement
|
|
4023
|
+
} = renderer;
|
|
4024
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
4025
|
+
const elm = vnode.elm = createElement(sel, namespace);
|
|
4026
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
4027
|
+
applyStyleScoping(elm, owner, renderer);
|
|
4028
|
+
applyDomManual(elm, vnode);
|
|
4029
|
+
applyElementRestrictions(elm, vnode);
|
|
4030
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
4031
|
+
insertNode(elm, parent, anchor, renderer);
|
|
4032
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3928
4033
|
}
|
|
4034
|
+
|
|
3929
4035
|
function patchElement(n1, n2, renderer) {
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
4036
|
+
const elm = n2.elm = n1.elm;
|
|
4037
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
4038
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3933
4039
|
}
|
|
4040
|
+
|
|
3934
4041
|
function mountStatic(vnode, parent, anchor, renderer) {
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
4042
|
+
const {
|
|
4043
|
+
owner
|
|
4044
|
+
} = vnode;
|
|
4045
|
+
const {
|
|
4046
|
+
cloneNode,
|
|
4047
|
+
isSyntheticShadowDefined
|
|
4048
|
+
} = renderer;
|
|
4049
|
+
const elm = vnode.elm = cloneNode(vnode.fragment, true);
|
|
4050
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
4051
|
+
applyElementRestrictions(elm, vnode); // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
4052
|
+
|
|
4053
|
+
const {
|
|
4054
|
+
renderMode,
|
|
4055
|
+
shadowMode
|
|
4056
|
+
} = owner;
|
|
4057
|
+
|
|
4058
|
+
if (isSyntheticShadowDefined) {
|
|
4059
|
+
if (shadowMode === 1
|
|
4060
|
+
/* ShadowMode.Synthetic */
|
|
4061
|
+
|| renderMode === 0
|
|
4062
|
+
/* RenderMode.Light */
|
|
4063
|
+
) {
|
|
4064
|
+
elm[KEY__SHADOW_STATIC] = true;
|
|
3946
4065
|
}
|
|
3947
|
-
|
|
4066
|
+
}
|
|
4067
|
+
|
|
4068
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3948
4069
|
}
|
|
4070
|
+
|
|
3949
4071
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
4072
|
+
const {
|
|
4073
|
+
sel,
|
|
4074
|
+
owner
|
|
4075
|
+
} = vnode;
|
|
4076
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
4077
|
+
/**
|
|
4078
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4079
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
4080
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
4081
|
+
* an upgradable custom element.
|
|
4082
|
+
*/
|
|
4083
|
+
|
|
4084
|
+
let vm;
|
|
4085
|
+
const elm = new UpgradableConstructor(elm => {
|
|
4086
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
4087
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
4088
|
+
});
|
|
4089
|
+
vnode.elm = elm;
|
|
4090
|
+
vnode.vm = vm;
|
|
4091
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
4092
|
+
applyStyleScoping(elm, owner, renderer);
|
|
4093
|
+
|
|
4094
|
+
if (vm) {
|
|
4095
|
+
allocateChildren(vnode, vm);
|
|
4096
|
+
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
4097
|
+
throw new TypeError(`Incorrect Component Constructor`);
|
|
4098
|
+
}
|
|
4099
|
+
|
|
4100
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
4101
|
+
insertNode(elm, parent, anchor, renderer);
|
|
4102
|
+
|
|
4103
|
+
if (vm) {
|
|
4104
|
+
{
|
|
4105
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3976
4106
|
if (process.env.NODE_ENV !== 'production') {
|
|
3977
|
-
|
|
4107
|
+
// With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
|
|
4108
|
+
// noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
|
|
4109
|
+
assert.isTrue(vm.state === 0
|
|
4110
|
+
/* VMState.created */
|
|
4111
|
+
, `${vm} cannot be recycled.`);
|
|
3978
4112
|
}
|
|
4113
|
+
|
|
3979
4114
|
runConnectedCallback(vm);
|
|
4115
|
+
}
|
|
3980
4116
|
}
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
4117
|
+
}
|
|
4118
|
+
|
|
4119
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
4120
|
+
|
|
4121
|
+
if (vm) {
|
|
4122
|
+
appendVM(vm);
|
|
4123
|
+
}
|
|
3985
4124
|
}
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
4125
|
+
|
|
4126
|
+
function patchCustomElement(n1, n2, parent, renderer) {
|
|
4127
|
+
if (n1.ctor !== n2.ctor) {
|
|
4128
|
+
// If the constructor, unmount the current component and mount a new one using the new
|
|
4129
|
+
// constructor.
|
|
4130
|
+
const anchor = renderer.nextSibling(n1.elm);
|
|
4131
|
+
unmount(n1, parent, renderer, true);
|
|
4132
|
+
mountCustomElement(n2, parent, anchor, renderer);
|
|
4133
|
+
} else {
|
|
4134
|
+
// Otherwise patch the existing component with new props/attrs/etc.
|
|
4135
|
+
const elm = n2.elm = n1.elm;
|
|
4136
|
+
const vm = n2.vm = n1.vm;
|
|
3989
4137
|
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
4138
|
+
|
|
3990
4139
|
if (!isUndefined$1(vm)) {
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
}
|
|
3995
|
-
// in fallback mode, the children will be always empty, so, nothing
|
|
4140
|
+
// in fallback mode, the allocation will always set children to
|
|
4141
|
+
// empty and delegate the real allocation to the slot elements
|
|
4142
|
+
allocateChildren(n2, vm);
|
|
4143
|
+
} // in fallback mode, the children will be always empty, so, nothing
|
|
3996
4144
|
// will happen, but in native, it does allocate the light dom
|
|
4145
|
+
|
|
4146
|
+
|
|
3997
4147
|
patchChildren(n1.children, n2.children, elm, renderer);
|
|
4148
|
+
|
|
3998
4149
|
if (!isUndefined$1(vm)) {
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4150
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
4151
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
4152
|
+
rerenderVM(vm);
|
|
4002
4153
|
}
|
|
4154
|
+
}
|
|
4003
4155
|
}
|
|
4156
|
+
|
|
4004
4157
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4158
|
+
for (; start < end; ++start) {
|
|
4159
|
+
const vnode = vnodes[start];
|
|
4160
|
+
|
|
4161
|
+
if (isVNode(vnode)) {
|
|
4162
|
+
mount(vnode, parent, renderer, anchor);
|
|
4010
4163
|
}
|
|
4164
|
+
}
|
|
4011
4165
|
}
|
|
4166
|
+
|
|
4012
4167
|
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4168
|
+
const {
|
|
4169
|
+
type,
|
|
4170
|
+
elm,
|
|
4171
|
+
sel
|
|
4172
|
+
} = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
4173
|
+
// subtree root, is the only element worth unmounting from the subtree.
|
|
4174
|
+
|
|
4175
|
+
if (doRemove) {
|
|
4176
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
4177
|
+
// but the removal used here is from the owner instead.
|
|
4178
|
+
removeNode(elm, parent, renderer);
|
|
4179
|
+
}
|
|
4180
|
+
|
|
4181
|
+
switch (type) {
|
|
4182
|
+
case 2
|
|
4183
|
+
/* VNodeType.Element */
|
|
4184
|
+
:
|
|
4185
|
+
{
|
|
4186
|
+
// Slot content is removed to trigger slotchange event when removing slot.
|
|
4187
|
+
// Only required for synthetic shadow.
|
|
4188
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
|
|
4189
|
+
/* ShadowMode.Synthetic */
|
|
4190
|
+
;
|
|
4191
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
4192
|
+
break;
|
|
4193
|
+
}
|
|
4194
|
+
|
|
4195
|
+
case 3
|
|
4196
|
+
/* VNodeType.CustomElement */
|
|
4197
|
+
:
|
|
4198
|
+
{
|
|
4199
|
+
const {
|
|
4200
|
+
vm
|
|
4201
|
+
} = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
|
|
4202
|
+
// children.
|
|
4203
|
+
|
|
4204
|
+
if (!isUndefined$1(vm)) {
|
|
4205
|
+
removeVM(vm);
|
|
4036
4206
|
}
|
|
4037
|
-
|
|
4207
|
+
}
|
|
4208
|
+
}
|
|
4038
4209
|
}
|
|
4210
|
+
|
|
4039
4211
|
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4212
|
+
for (; start < end; ++start) {
|
|
4213
|
+
const ch = vnodes[start];
|
|
4214
|
+
|
|
4215
|
+
if (isVNode(ch)) {
|
|
4216
|
+
unmount(ch, parent, renderer, doRemove);
|
|
4045
4217
|
}
|
|
4218
|
+
}
|
|
4046
4219
|
}
|
|
4220
|
+
|
|
4047
4221
|
function isVNode(vnode) {
|
|
4048
|
-
|
|
4222
|
+
return vnode != null;
|
|
4049
4223
|
}
|
|
4224
|
+
|
|
4050
4225
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4226
|
+
const {
|
|
4227
|
+
renderRoot,
|
|
4228
|
+
renderMode,
|
|
4229
|
+
shadowMode
|
|
4230
|
+
} = owner;
|
|
4231
|
+
const {
|
|
4232
|
+
isSyntheticShadowDefined
|
|
4233
|
+
} = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
|
|
4234
|
+
|
|
4235
|
+
if (isSyntheticShadowDefined) {
|
|
4236
|
+
if (shadowMode === 1
|
|
4237
|
+
/* ShadowMode.Synthetic */
|
|
4238
|
+
|| renderMode === 0
|
|
4239
|
+
/* RenderMode.Light */
|
|
4240
|
+
) {
|
|
4241
|
+
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
4058
4242
|
}
|
|
4243
|
+
}
|
|
4059
4244
|
}
|
|
4245
|
+
|
|
4060
4246
|
function updateTextContent(vnode, renderer) {
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
setText
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4247
|
+
const {
|
|
4248
|
+
elm,
|
|
4249
|
+
text
|
|
4250
|
+
} = vnode;
|
|
4251
|
+
const {
|
|
4252
|
+
setText
|
|
4253
|
+
} = renderer;
|
|
4254
|
+
|
|
4255
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4256
|
+
unlockDomMutation();
|
|
4257
|
+
}
|
|
4258
|
+
|
|
4259
|
+
setText(elm, text);
|
|
4260
|
+
|
|
4261
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4262
|
+
lockDomMutation();
|
|
4263
|
+
}
|
|
4070
4264
|
}
|
|
4265
|
+
|
|
4071
4266
|
function insertNode(node, parent, anchor, renderer) {
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4267
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4268
|
+
unlockDomMutation();
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4271
|
+
renderer.insert(node, parent, anchor);
|
|
4272
|
+
|
|
4273
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4274
|
+
lockDomMutation();
|
|
4275
|
+
}
|
|
4079
4276
|
}
|
|
4277
|
+
|
|
4080
4278
|
function removeNode(node, parent, renderer) {
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4279
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4280
|
+
unlockDomMutation();
|
|
4281
|
+
}
|
|
4282
|
+
|
|
4283
|
+
renderer.remove(node, parent);
|
|
4284
|
+
|
|
4285
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4286
|
+
lockDomMutation();
|
|
4287
|
+
}
|
|
4088
4288
|
}
|
|
4289
|
+
|
|
4089
4290
|
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4291
|
+
if (isNull(oldVnode)) {
|
|
4292
|
+
applyEventListeners(vnode, renderer);
|
|
4293
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
4294
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
4295
|
+
} // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
4296
|
+
// value is set before type=radio.
|
|
4297
|
+
|
|
4298
|
+
|
|
4299
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
4300
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
4301
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
4302
|
+
patchProps(oldVnode, vnode, renderer);
|
|
4101
4303
|
}
|
|
4304
|
+
|
|
4102
4305
|
function applyStyleScoping(elm, owner, renderer) {
|
|
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
|
-
|
|
4306
|
+
// Set the class name for `*.scoped.css` style scoping.
|
|
4307
|
+
const scopeToken = getScopeTokenClass(owner);
|
|
4308
|
+
|
|
4309
|
+
if (!isNull(scopeToken)) {
|
|
4310
|
+
const {
|
|
4311
|
+
getClassList
|
|
4312
|
+
} = renderer; // TODO [#2762]: this dot notation with add is probably problematic
|
|
4313
|
+
// probably we should have a renderer api for just the add operation
|
|
4314
|
+
|
|
4315
|
+
getClassList(elm).add(scopeToken);
|
|
4316
|
+
} // Set property element for synthetic shadow DOM style scoping.
|
|
4317
|
+
|
|
4318
|
+
|
|
4319
|
+
const {
|
|
4320
|
+
stylesheetToken: syntheticToken
|
|
4321
|
+
} = owner.context;
|
|
4322
|
+
|
|
4323
|
+
if (owner.shadowMode === 1
|
|
4324
|
+
/* ShadowMode.Synthetic */
|
|
4325
|
+
&& !isUndefined$1(syntheticToken)) {
|
|
4326
|
+
elm.$shadowToken$ = syntheticToken;
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4329
|
+
|
|
4330
|
+
function applyDomManual(elm, vnode) {
|
|
4331
|
+
var _a;
|
|
4332
|
+
|
|
4333
|
+
const {
|
|
4334
|
+
owner,
|
|
4335
|
+
data: {
|
|
4336
|
+
context
|
|
4133
4337
|
}
|
|
4338
|
+
} = vnode;
|
|
4339
|
+
|
|
4340
|
+
if (owner.shadowMode === 1
|
|
4341
|
+
/* ShadowMode.Synthetic */
|
|
4342
|
+
&& ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
|
|
4343
|
+
/* LwcDomMode.Manual */
|
|
4344
|
+
) {
|
|
4345
|
+
elm.$domManual$ = true;
|
|
4346
|
+
}
|
|
4134
4347
|
}
|
|
4348
|
+
|
|
4349
|
+
function applyElementRestrictions(elm, vnode) {
|
|
4350
|
+
var _a, _b;
|
|
4351
|
+
|
|
4352
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4353
|
+
const isPortal = vnode.type === 2
|
|
4354
|
+
/* VNodeType.Element */
|
|
4355
|
+
&& ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
|
|
4356
|
+
/* LwcDomMode.Manual */
|
|
4357
|
+
;
|
|
4358
|
+
const isLight = vnode.owner.renderMode === 0
|
|
4359
|
+
/* RenderMode.Light */
|
|
4360
|
+
;
|
|
4361
|
+
patchElementWithRestrictions(elm, {
|
|
4362
|
+
isPortal,
|
|
4363
|
+
isLight
|
|
4364
|
+
});
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
|
|
4135
4368
|
function allocateChildren(vnode, vm) {
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4369
|
+
// A component with slots will re-render because:
|
|
4370
|
+
// 1- There is a change of the internal state.
|
|
4371
|
+
// 2- There is a change on the external api (ex: slots)
|
|
4372
|
+
//
|
|
4373
|
+
// In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
|
|
4374
|
+
// slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
|
|
4375
|
+
// in a reused VCustomElement, there won't be any slotted children.
|
|
4376
|
+
// For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
|
|
4377
|
+
//
|
|
4378
|
+
// In case #2, we will always get a fresh VCustomElement.
|
|
4379
|
+
const children = vnode.aChildren || vnode.children;
|
|
4380
|
+
vm.aChildren = children;
|
|
4381
|
+
const {
|
|
4382
|
+
renderMode,
|
|
4383
|
+
shadowMode
|
|
4384
|
+
} = vm;
|
|
4385
|
+
|
|
4386
|
+
if (shadowMode === 1
|
|
4387
|
+
/* ShadowMode.Synthetic */
|
|
4388
|
+
|| renderMode === 0
|
|
4389
|
+
/* RenderMode.Light */
|
|
4390
|
+
) {
|
|
4391
|
+
// slow path
|
|
4392
|
+
allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
|
|
4393
|
+
|
|
4394
|
+
vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4395
|
+
|
|
4396
|
+
vnode.children = EmptyArray;
|
|
4397
|
+
}
|
|
4157
4398
|
}
|
|
4399
|
+
|
|
4158
4400
|
function createViewModelHook(elm, vnode, renderer) {
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
return vm;
|
|
4165
|
-
}
|
|
4166
|
-
const { sel, mode, ctor, owner } = vnode;
|
|
4167
|
-
vm = createVM(elm, ctor, renderer, {
|
|
4168
|
-
mode,
|
|
4169
|
-
owner,
|
|
4170
|
-
tagName: sel,
|
|
4171
|
-
});
|
|
4172
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4173
|
-
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4174
|
-
}
|
|
4401
|
+
let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
|
|
4402
|
+
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
4403
|
+
// called right after invoking `document.createElement`.
|
|
4404
|
+
|
|
4405
|
+
if (!isUndefined$1(vm)) {
|
|
4175
4406
|
return vm;
|
|
4407
|
+
}
|
|
4408
|
+
|
|
4409
|
+
const {
|
|
4410
|
+
sel,
|
|
4411
|
+
mode,
|
|
4412
|
+
ctor,
|
|
4413
|
+
owner
|
|
4414
|
+
} = vnode;
|
|
4415
|
+
vm = createVM(elm, ctor, renderer, {
|
|
4416
|
+
mode,
|
|
4417
|
+
owner,
|
|
4418
|
+
tagName: sel
|
|
4419
|
+
});
|
|
4420
|
+
|
|
4421
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4422
|
+
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4423
|
+
}
|
|
4424
|
+
|
|
4425
|
+
return vm;
|
|
4176
4426
|
}
|
|
4427
|
+
|
|
4177
4428
|
function allocateInSlot(vm, children) {
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4429
|
+
var _a;
|
|
4430
|
+
|
|
4431
|
+
const {
|
|
4432
|
+
cmpSlots: oldSlots
|
|
4433
|
+
} = vm;
|
|
4434
|
+
const cmpSlots = vm.cmpSlots = create(null);
|
|
4435
|
+
|
|
4436
|
+
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4437
|
+
const vnode = children[i];
|
|
4438
|
+
|
|
4439
|
+
if (isNull(vnode)) {
|
|
4440
|
+
continue;
|
|
4441
|
+
}
|
|
4442
|
+
|
|
4443
|
+
let slotName = '';
|
|
4444
|
+
|
|
4445
|
+
if (isVBaseElement(vnode)) {
|
|
4446
|
+
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
|
|
4447
|
+
}
|
|
4448
|
+
|
|
4449
|
+
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
|
|
4450
|
+
ArrayPush$1.call(vnodes, vnode);
|
|
4451
|
+
}
|
|
4452
|
+
|
|
4453
|
+
if (isFalse(vm.isDirty)) {
|
|
4454
|
+
// We need to determine if the old allocation is really different from the new one
|
|
4455
|
+
// and mark the vm as dirty
|
|
4456
|
+
const oldKeys = keys(oldSlots);
|
|
4457
|
+
|
|
4458
|
+
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
4459
|
+
markComponentAsDirty(vm);
|
|
4460
|
+
return;
|
|
4461
|
+
}
|
|
4462
|
+
|
|
4463
|
+
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4464
|
+
const key = oldKeys[i];
|
|
4465
|
+
|
|
4466
|
+
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
4467
|
+
markComponentAsDirty(vm);
|
|
4468
|
+
return;
|
|
4469
|
+
}
|
|
4470
|
+
|
|
4471
|
+
const oldVNodes = oldSlots[key];
|
|
4472
|
+
const vnodes = cmpSlots[key];
|
|
4473
|
+
|
|
4474
|
+
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
4475
|
+
if (oldVNodes[j] !== vnodes[j]) {
|
|
4476
|
+
markComponentAsDirty(vm);
|
|
4477
|
+
return;
|
|
4215
4478
|
}
|
|
4479
|
+
}
|
|
4216
4480
|
}
|
|
4217
|
-
|
|
4218
|
-
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4219
|
-
|
|
4220
|
-
|
|
4481
|
+
}
|
|
4482
|
+
} // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4483
|
+
|
|
4484
|
+
|
|
4485
|
+
const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
|
|
4221
4486
|
// in a template, and will require a more complex diffing algo.
|
|
4487
|
+
|
|
4222
4488
|
function markAsDynamicChildren(children) {
|
|
4223
|
-
|
|
4489
|
+
FromIteration.set(children, 1);
|
|
4224
4490
|
}
|
|
4491
|
+
|
|
4225
4492
|
function hasDynamicChildren(children) {
|
|
4226
|
-
|
|
4493
|
+
return FromIteration.has(children);
|
|
4227
4494
|
}
|
|
4495
|
+
|
|
4228
4496
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4497
|
+
const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
4498
|
+
|
|
4499
|
+
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
4500
|
+
const ch = children[j];
|
|
4501
|
+
|
|
4502
|
+
if (isVNode(ch)) {
|
|
4503
|
+
const {
|
|
4504
|
+
key
|
|
4505
|
+
} = ch;
|
|
4506
|
+
|
|
4507
|
+
if (key !== undefined) {
|
|
4508
|
+
map[key] = j;
|
|
4509
|
+
}
|
|
4239
4510
|
}
|
|
4240
|
-
|
|
4511
|
+
}
|
|
4512
|
+
|
|
4513
|
+
return map;
|
|
4241
4514
|
}
|
|
4515
|
+
|
|
4242
4516
|
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
}
|
|
4322
|
-
// We've already cloned at least once, so it's no longer read-only
|
|
4323
|
-
oldCh[idxInOld] = undefined;
|
|
4324
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4325
|
-
}
|
|
4326
|
-
}
|
|
4327
|
-
newStartVnode = newCh[++newStartIdx];
|
|
4328
|
-
}
|
|
4517
|
+
let oldStartIdx = 0;
|
|
4518
|
+
let newStartIdx = 0;
|
|
4519
|
+
let oldEndIdx = oldCh.length - 1;
|
|
4520
|
+
let oldStartVnode = oldCh[0];
|
|
4521
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
4522
|
+
const newChEnd = newCh.length - 1;
|
|
4523
|
+
let newEndIdx = newChEnd;
|
|
4524
|
+
let newStartVnode = newCh[0];
|
|
4525
|
+
let newEndVnode = newCh[newEndIdx];
|
|
4526
|
+
let oldKeyToIdx;
|
|
4527
|
+
let idxInOld;
|
|
4528
|
+
let elmToMove;
|
|
4529
|
+
let before;
|
|
4530
|
+
let clonedOldCh = false;
|
|
4531
|
+
|
|
4532
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
4533
|
+
if (!isVNode(oldStartVnode)) {
|
|
4534
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
4535
|
+
} else if (!isVNode(oldEndVnode)) {
|
|
4536
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4537
|
+
} else if (!isVNode(newStartVnode)) {
|
|
4538
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4539
|
+
} else if (!isVNode(newEndVnode)) {
|
|
4540
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4541
|
+
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
4542
|
+
patch(oldStartVnode, newStartVnode, parent, renderer);
|
|
4543
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4544
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4545
|
+
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
4546
|
+
patch(oldEndVnode, newEndVnode, parent, renderer);
|
|
4547
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4548
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4549
|
+
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
4550
|
+
// Vnode moved right
|
|
4551
|
+
patch(oldStartVnode, newEndVnode, parent, renderer);
|
|
4552
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
4553
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4554
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4555
|
+
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
4556
|
+
// Vnode moved left
|
|
4557
|
+
patch(oldEndVnode, newStartVnode, parent, renderer);
|
|
4558
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
4559
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4560
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4561
|
+
} else {
|
|
4562
|
+
if (oldKeyToIdx === undefined) {
|
|
4563
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
4564
|
+
}
|
|
4565
|
+
|
|
4566
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
4567
|
+
|
|
4568
|
+
if (isUndefined$1(idxInOld)) {
|
|
4569
|
+
// New element
|
|
4570
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4571
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4572
|
+
} else {
|
|
4573
|
+
elmToMove = oldCh[idxInOld];
|
|
4574
|
+
|
|
4575
|
+
if (isVNode(elmToMove)) {
|
|
4576
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4577
|
+
// New element
|
|
4578
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4579
|
+
} else {
|
|
4580
|
+
patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
|
|
4581
|
+
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4582
|
+
// so we only care about the `oldCh` object inside this function.
|
|
4583
|
+
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4584
|
+
// and only clone once.
|
|
4585
|
+
|
|
4586
|
+
if (!clonedOldCh) {
|
|
4587
|
+
clonedOldCh = true;
|
|
4588
|
+
oldCh = [...oldCh];
|
|
4589
|
+
} // We've already cloned at least once, so it's no longer read-only
|
|
4590
|
+
|
|
4591
|
+
|
|
4592
|
+
oldCh[idxInOld] = undefined;
|
|
4593
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4594
|
+
}
|
|
4329
4595
|
}
|
|
4596
|
+
|
|
4597
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4598
|
+
}
|
|
4330
4599
|
}
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4600
|
+
}
|
|
4601
|
+
|
|
4602
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
4603
|
+
if (oldStartIdx > oldEndIdx) {
|
|
4604
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
4605
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
4606
|
+
let i = newEndIdx;
|
|
4607
|
+
let n;
|
|
4608
|
+
|
|
4609
|
+
do {
|
|
4610
|
+
n = newCh[++i];
|
|
4611
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
4612
|
+
|
|
4613
|
+
before = isVNode(n) ? n.elm : null;
|
|
4614
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
4615
|
+
} else {
|
|
4616
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
4346
4617
|
}
|
|
4618
|
+
}
|
|
4347
4619
|
}
|
|
4620
|
+
|
|
4348
4621
|
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
anchor = n2.elm;
|
|
4383
|
-
}
|
|
4622
|
+
const c1Length = c1.length;
|
|
4623
|
+
const c2Length = c2.length;
|
|
4624
|
+
|
|
4625
|
+
if (c1Length === 0) {
|
|
4626
|
+
// the old list is empty, we can directly insert anything new
|
|
4627
|
+
mountVNodes(c2, parent, renderer, null);
|
|
4628
|
+
return;
|
|
4629
|
+
}
|
|
4630
|
+
|
|
4631
|
+
if (c2Length === 0) {
|
|
4632
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4633
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4634
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
4635
|
+
return;
|
|
4636
|
+
} // if the old list is not empty, the new list MUST have the same
|
|
4637
|
+
// amount of nodes, that's why we call this static children
|
|
4638
|
+
|
|
4639
|
+
|
|
4640
|
+
let anchor = null;
|
|
4641
|
+
|
|
4642
|
+
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
4643
|
+
const n1 = c1[i];
|
|
4644
|
+
const n2 = c2[i];
|
|
4645
|
+
|
|
4646
|
+
if (n2 !== n1) {
|
|
4647
|
+
if (isVNode(n1)) {
|
|
4648
|
+
if (isVNode(n2)) {
|
|
4649
|
+
// both vnodes are equivalent, and we just need to patch them
|
|
4650
|
+
patch(n1, n2, parent, renderer);
|
|
4651
|
+
anchor = n2.elm;
|
|
4652
|
+
} else {
|
|
4653
|
+
// removing the old vnode since the new one is null
|
|
4654
|
+
unmount(n1, parent, renderer, true);
|
|
4384
4655
|
}
|
|
4656
|
+
} else if (isVNode(n2)) {
|
|
4657
|
+
mount(n2, parent, renderer, anchor);
|
|
4658
|
+
anchor = n2.elm;
|
|
4659
|
+
}
|
|
4385
4660
|
}
|
|
4661
|
+
}
|
|
4386
4662
|
}
|
|
4387
4663
|
|
|
4388
4664
|
/*
|
|
@@ -4703,13 +4979,6 @@
|
|
|
4703
4979
|
}
|
|
4704
4980
|
return url;
|
|
4705
4981
|
}
|
|
4706
|
-
/**
|
|
4707
|
-
* Map to store an index value assigned to any dynamic component reference ingested
|
|
4708
|
-
* by dc() api. This allows us to generate a unique unique per template per dynamic
|
|
4709
|
-
* component reference to avoid diffing algo mismatches.
|
|
4710
|
-
*/
|
|
4711
|
-
const DynamicImportedComponentMap = new Map();
|
|
4712
|
-
let dynamicImportedComponentCounter = 0;
|
|
4713
4982
|
/**
|
|
4714
4983
|
* create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
4715
4984
|
*/
|
|
@@ -4726,18 +4995,7 @@
|
|
|
4726
4995
|
if (!isComponentConstructor(Ctor)) {
|
|
4727
4996
|
throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
|
|
4728
4997
|
}
|
|
4729
|
-
|
|
4730
|
-
if (isUndefined$1(idx)) {
|
|
4731
|
-
idx = dynamicImportedComponentCounter++;
|
|
4732
|
-
DynamicImportedComponentMap.set(Ctor, idx);
|
|
4733
|
-
}
|
|
4734
|
-
// the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
|
|
4735
|
-
// to identify different constructors as vnodes with different keys to avoid reusing the
|
|
4736
|
-
// element used for previous constructors.
|
|
4737
|
-
// Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
|
|
4738
|
-
// hoisting optimization.
|
|
4739
|
-
const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
|
|
4740
|
-
return c(sel, Ctor, newData, children);
|
|
4998
|
+
return c(sel, Ctor, data, children);
|
|
4741
4999
|
}
|
|
4742
5000
|
/**
|
|
4743
5001
|
* slow children collection marking mechanism. this API allows the compiler to signal
|
|
@@ -5463,7 +5721,7 @@
|
|
|
5463
5721
|
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
5464
5722
|
};
|
|
5465
5723
|
|
|
5466
|
-
if (
|
|
5724
|
+
if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5467
5725
|
vm.shadowMode = 0
|
|
5468
5726
|
/* ShadowMode.Native */
|
|
5469
5727
|
;
|
|
@@ -5502,7 +5760,7 @@
|
|
|
5502
5760
|
} else if (isNativeShadowDefined) {
|
|
5503
5761
|
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
5504
5762
|
// the if-condition.
|
|
5505
|
-
if (
|
|
5763
|
+
if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
5506
5764
|
if (def.shadowSupportMode === "any"
|
|
5507
5765
|
/* ShadowSupportMode.Any */
|
|
5508
5766
|
) {
|
|
@@ -5631,16 +5889,9 @@
|
|
|
5631
5889
|
const {
|
|
5632
5890
|
def: {
|
|
5633
5891
|
renderedCallback
|
|
5634
|
-
},
|
|
5635
|
-
renderer: {
|
|
5636
|
-
ssr
|
|
5637
5892
|
}
|
|
5638
5893
|
} = vm;
|
|
5639
5894
|
|
|
5640
|
-
if (isTrue(ssr)) {
|
|
5641
|
-
return;
|
|
5642
|
-
}
|
|
5643
|
-
|
|
5644
5895
|
const {
|
|
5645
5896
|
rendered
|
|
5646
5897
|
} = Services;
|
|
@@ -5890,13 +6141,7 @@
|
|
|
5890
6141
|
vm.velements = EmptyArray;
|
|
5891
6142
|
}
|
|
5892
6143
|
function scheduleRehydration(vm) {
|
|
5893
|
-
|
|
5894
|
-
renderer: {
|
|
5895
|
-
ssr
|
|
5896
|
-
}
|
|
5897
|
-
} = vm;
|
|
5898
|
-
|
|
5899
|
-
if (isTrue(ssr) || isTrue(vm.isScheduled)) {
|
|
6144
|
+
if (isTrue(vm.isScheduled)) {
|
|
5900
6145
|
return;
|
|
5901
6146
|
}
|
|
5902
6147
|
|
|
@@ -6003,15 +6248,8 @@
|
|
|
6003
6248
|
}
|
|
6004
6249
|
|
|
6005
6250
|
function createFieldDataCallback(vm, name) {
|
|
6006
|
-
const {
|
|
6007
|
-
cmpFields
|
|
6008
|
-
} = vm;
|
|
6009
6251
|
return value => {
|
|
6010
|
-
|
|
6011
|
-
// storing the value in the underlying storage
|
|
6012
|
-
cmpFields[name] = value;
|
|
6013
|
-
componentValueMutated(vm, name);
|
|
6014
|
-
}
|
|
6252
|
+
updateComponentValue(vm, name, value);
|
|
6015
6253
|
};
|
|
6016
6254
|
}
|
|
6017
6255
|
|
|
@@ -6229,7 +6467,7 @@
|
|
|
6229
6467
|
ArrayPush$1.call(wiredConnecting, () => {
|
|
6230
6468
|
connector.connect();
|
|
6231
6469
|
|
|
6232
|
-
if (!
|
|
6470
|
+
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
6233
6471
|
if (hasDynamicParams) {
|
|
6234
6472
|
Promise.resolve().then(computeConfigAndUpdate);
|
|
6235
6473
|
return;
|
|
@@ -6375,6 +6613,7 @@
|
|
|
6375
6613
|
}
|
|
6376
6614
|
return renderer.nextSibling(hydratedNode);
|
|
6377
6615
|
}
|
|
6616
|
+
const NODE_VALUE_PROP = 'nodeValue';
|
|
6378
6617
|
function hydrateText(node, vnode, renderer) {
|
|
6379
6618
|
var _a;
|
|
6380
6619
|
if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
@@ -6382,7 +6621,7 @@
|
|
|
6382
6621
|
}
|
|
6383
6622
|
if (process.env.NODE_ENV !== 'production') {
|
|
6384
6623
|
const { getProperty } = renderer;
|
|
6385
|
-
const nodeValue = getProperty(node,
|
|
6624
|
+
const nodeValue = getProperty(node, NODE_VALUE_PROP);
|
|
6386
6625
|
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
6387
6626
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
6388
6627
|
}
|
|
@@ -6399,13 +6638,13 @@
|
|
|
6399
6638
|
}
|
|
6400
6639
|
if (process.env.NODE_ENV !== 'production') {
|
|
6401
6640
|
const { getProperty } = renderer;
|
|
6402
|
-
const nodeValue = getProperty(node,
|
|
6641
|
+
const nodeValue = getProperty(node, NODE_VALUE_PROP);
|
|
6403
6642
|
if (nodeValue !== vnode.text) {
|
|
6404
6643
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
6405
6644
|
}
|
|
6406
6645
|
}
|
|
6407
6646
|
const { setProperty } = renderer;
|
|
6408
|
-
setProperty(node,
|
|
6647
|
+
setProperty(node, NODE_VALUE_PROP, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
6409
6648
|
vnode.elm = node;
|
|
6410
6649
|
return node;
|
|
6411
6650
|
}
|
|
@@ -6673,13 +6912,13 @@
|
|
|
6673
6912
|
if (!hasCorrectNodeType(vnode, ssr, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
6674
6913
|
return false;
|
|
6675
6914
|
}
|
|
6676
|
-
return getProperty(client,
|
|
6915
|
+
return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
|
|
6677
6916
|
}
|
|
6678
6917
|
if (getProperty(client, 'nodeType') === 8 /* EnvNodeTypes.COMMENT */) {
|
|
6679
6918
|
if (!hasCorrectNodeType(vnode, ssr, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
|
|
6680
6919
|
return false;
|
|
6681
6920
|
}
|
|
6682
|
-
return getProperty(client,
|
|
6921
|
+
return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
|
|
6683
6922
|
}
|
|
6684
6923
|
if (!hasCorrectNodeType(vnode, ssr, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
|
|
6685
6924
|
return false;
|
|
@@ -6835,7 +7074,7 @@
|
|
|
6835
7074
|
}
|
|
6836
7075
|
return ctor;
|
|
6837
7076
|
}
|
|
6838
|
-
/* version: 2.
|
|
7077
|
+
/* version: 2.23.2 */
|
|
6839
7078
|
|
|
6840
7079
|
/*
|
|
6841
7080
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6985,61 +7224,303 @@
|
|
|
6985
7224
|
* SPDX-License-Identifier: MIT
|
|
6986
7225
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6987
7226
|
*/
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
//
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
html = `<${wrapperTag}>${html}</${wrapperTag}>`;
|
|
7227
|
+
/**
|
|
7228
|
+
* A factory function that produces a renderer.
|
|
7229
|
+
* Renderer encapsulates operations that are required to render an LWC component into the underlying
|
|
7230
|
+
* runtime environment. In the case of @lwc/enigne-dom, it is meant to be used in a DOM environment.
|
|
7231
|
+
* Example usage:
|
|
7232
|
+
* import { renderer, rendererFactory } from 'lwc';
|
|
7233
|
+
* const customRenderer = rendererFactory(renderer);
|
|
7234
|
+
*
|
|
7235
|
+
* @param baseRenderer Either null or the base renderer imported from 'lwc'.
|
|
7236
|
+
*/
|
|
7237
|
+
function rendererFactory(baseRenderer) {
|
|
7238
|
+
// Util functions
|
|
7239
|
+
function assertInvariant(value, msg) {
|
|
7240
|
+
if (!value) {
|
|
7241
|
+
throw new Error(`Invariant Violation: ${msg}`);
|
|
7242
|
+
}
|
|
7243
|
+
}
|
|
7244
|
+
function isNull(obj) {
|
|
7245
|
+
return obj === null;
|
|
7246
|
+
}
|
|
7247
|
+
function isUndefined(obj) {
|
|
7248
|
+
return obj === undefined;
|
|
7249
|
+
}
|
|
7250
|
+
let getCustomElement;
|
|
7251
|
+
let defineCustomElement;
|
|
7252
|
+
let HTMLElementConstructor;
|
|
7253
|
+
function isCustomElementRegistryAvailable() {
|
|
7254
|
+
if (typeof customElements === 'undefined') {
|
|
7255
|
+
return false;
|
|
7256
|
+
}
|
|
7257
|
+
try {
|
|
7258
|
+
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
7259
|
+
// _wrapNativeSuper()
|
|
7260
|
+
// This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
|
|
7261
|
+
// get wrapped by babel.
|
|
7262
|
+
const HTMLElementAlias = HTMLElement;
|
|
7263
|
+
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
7264
|
+
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
7265
|
+
// which are not equipped to be initialized that way.
|
|
7266
|
+
class clazz extends HTMLElementAlias {
|
|
7029
7267
|
}
|
|
7268
|
+
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
7269
|
+
new clazz();
|
|
7270
|
+
return true;
|
|
7271
|
+
}
|
|
7272
|
+
catch (_a) {
|
|
7273
|
+
return false;
|
|
7030
7274
|
}
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7275
|
+
}
|
|
7276
|
+
if (isCustomElementRegistryAvailable()) {
|
|
7277
|
+
getCustomElement = customElements.get.bind(customElements);
|
|
7278
|
+
defineCustomElement = customElements.define.bind(customElements);
|
|
7279
|
+
HTMLElementConstructor = HTMLElement;
|
|
7280
|
+
}
|
|
7281
|
+
else {
|
|
7282
|
+
const registry = Object.create(null);
|
|
7283
|
+
const reverseRegistry = new WeakMap();
|
|
7284
|
+
defineCustomElement = function define(name, ctor) {
|
|
7285
|
+
if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
|
|
7286
|
+
throw new TypeError(`Invalid Registration`);
|
|
7287
|
+
}
|
|
7288
|
+
registry[name] = ctor;
|
|
7289
|
+
reverseRegistry.set(ctor, name);
|
|
7290
|
+
};
|
|
7291
|
+
getCustomElement = function get(name) {
|
|
7292
|
+
return registry[name];
|
|
7293
|
+
};
|
|
7294
|
+
HTMLElementConstructor = function HTMLElement() {
|
|
7295
|
+
if (!(this instanceof HTMLElement)) {
|
|
7296
|
+
throw new TypeError(`Invalid Invocation`);
|
|
7297
|
+
}
|
|
7298
|
+
const { constructor } = this;
|
|
7299
|
+
const name = reverseRegistry.get(constructor);
|
|
7300
|
+
if (!name) {
|
|
7301
|
+
throw new TypeError(`Invalid Construction`);
|
|
7302
|
+
}
|
|
7303
|
+
const elm = document.createElement(name);
|
|
7304
|
+
Object.setPrototypeOf(elm, constructor.prototype);
|
|
7305
|
+
return elm;
|
|
7306
|
+
};
|
|
7307
|
+
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
7308
|
+
}
|
|
7309
|
+
function cloneNode(node, deep) {
|
|
7310
|
+
return node.cloneNode(deep);
|
|
7311
|
+
}
|
|
7312
|
+
function createElement(tagName, namespace) {
|
|
7313
|
+
return isUndefined(namespace)
|
|
7314
|
+
? document.createElement(tagName)
|
|
7315
|
+
: document.createElementNS(namespace, tagName);
|
|
7316
|
+
}
|
|
7317
|
+
function createText(content) {
|
|
7318
|
+
return document.createTextNode(content);
|
|
7319
|
+
}
|
|
7320
|
+
function createComment(content) {
|
|
7321
|
+
return document.createComment(content);
|
|
7322
|
+
}
|
|
7323
|
+
let createFragment;
|
|
7324
|
+
// IE11 lacks support for this feature
|
|
7325
|
+
const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
|
|
7326
|
+
if (SUPPORTS_TEMPLATE) {
|
|
7327
|
+
// Parse the fragment HTML string into DOM
|
|
7328
|
+
createFragment = function (html) {
|
|
7329
|
+
const template = document.createElement('template');
|
|
7330
|
+
template.innerHTML = html;
|
|
7331
|
+
return template.content.firstChild;
|
|
7332
|
+
};
|
|
7333
|
+
}
|
|
7334
|
+
else {
|
|
7335
|
+
// In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
|
|
7336
|
+
// <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
|
|
7337
|
+
// Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
|
|
7338
|
+
// With other elements added from:
|
|
7339
|
+
// https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
|
|
7340
|
+
// Using the test:
|
|
7341
|
+
// document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
|
|
7342
|
+
// And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
|
|
7343
|
+
const topLevelWrappingMap = {
|
|
7344
|
+
caption: ['table'],
|
|
7345
|
+
col: ['colgroup', 'table'],
|
|
7346
|
+
colgroup: ['table'],
|
|
7347
|
+
option: ['select'],
|
|
7348
|
+
tbody: ['table'],
|
|
7349
|
+
td: ['tr', 'tbody', 'table'],
|
|
7350
|
+
th: ['tr', 'tbody', 'table'],
|
|
7351
|
+
thead: ['table'],
|
|
7352
|
+
tfoot: ['table'],
|
|
7353
|
+
tr: ['tbody', 'table'],
|
|
7354
|
+
};
|
|
7355
|
+
// Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
|
|
7356
|
+
const getTagName = function (text) {
|
|
7357
|
+
return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
|
|
7358
|
+
};
|
|
7359
|
+
// Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
|
|
7360
|
+
createFragment = function (html) {
|
|
7361
|
+
const wrapperTags = topLevelWrappingMap[getTagName(html)];
|
|
7362
|
+
if (!isUndefined(wrapperTags)) {
|
|
7363
|
+
for (const wrapperTag of wrapperTags) {
|
|
7364
|
+
html = `<${wrapperTag}>${html}</${wrapperTag}>`;
|
|
7365
|
+
}
|
|
7039
7366
|
}
|
|
7367
|
+
// For IE11, the document title must not be undefined, but it can be an empty string
|
|
7368
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
|
|
7369
|
+
const doc = document.implementation.createHTMLDocument('');
|
|
7370
|
+
doc.body.innerHTML = html;
|
|
7371
|
+
let content = doc.body;
|
|
7372
|
+
if (!isUndefined(wrapperTags)) {
|
|
7373
|
+
for (let i = 0; i < wrapperTags.length; i++) {
|
|
7374
|
+
content = content.firstChild;
|
|
7375
|
+
}
|
|
7376
|
+
}
|
|
7377
|
+
return content.firstChild;
|
|
7378
|
+
};
|
|
7379
|
+
}
|
|
7380
|
+
function insert(node, parent, anchor) {
|
|
7381
|
+
parent.insertBefore(node, anchor);
|
|
7382
|
+
}
|
|
7383
|
+
function remove(node, parent) {
|
|
7384
|
+
parent.removeChild(node);
|
|
7385
|
+
}
|
|
7386
|
+
function nextSibling(node) {
|
|
7387
|
+
return node.nextSibling;
|
|
7388
|
+
}
|
|
7389
|
+
function attachShadow(element, options) {
|
|
7390
|
+
// `shadowRoot` will be non-null in two cases:
|
|
7391
|
+
// 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
|
|
7392
|
+
// 2. when a webapp author places <c-app> in their static HTML and mounts their
|
|
7393
|
+
// root component with customElement.define('c-app', Ctor)
|
|
7394
|
+
if (!isNull(element.shadowRoot)) {
|
|
7395
|
+
return element.shadowRoot;
|
|
7396
|
+
}
|
|
7397
|
+
return element.attachShadow(options);
|
|
7398
|
+
}
|
|
7399
|
+
function setText(node, content) {
|
|
7400
|
+
node.nodeValue = content;
|
|
7401
|
+
}
|
|
7402
|
+
function getProperty(node, key) {
|
|
7403
|
+
return node[key];
|
|
7404
|
+
}
|
|
7405
|
+
function setProperty(node, key, value) {
|
|
7406
|
+
node[key] = value;
|
|
7407
|
+
}
|
|
7408
|
+
function getAttribute(element, name, namespace) {
|
|
7409
|
+
return isUndefined(namespace)
|
|
7410
|
+
? element.getAttribute(name)
|
|
7411
|
+
: element.getAttributeNS(namespace, name);
|
|
7412
|
+
}
|
|
7413
|
+
function setAttribute(element, name, value, namespace) {
|
|
7414
|
+
return isUndefined(namespace)
|
|
7415
|
+
? element.setAttribute(name, value)
|
|
7416
|
+
: element.setAttributeNS(namespace, name, value);
|
|
7417
|
+
}
|
|
7418
|
+
function removeAttribute(element, name, namespace) {
|
|
7419
|
+
if (isUndefined(namespace)) {
|
|
7420
|
+
element.removeAttribute(name);
|
|
7040
7421
|
}
|
|
7041
|
-
|
|
7422
|
+
else {
|
|
7423
|
+
element.removeAttributeNS(namespace, name);
|
|
7424
|
+
}
|
|
7425
|
+
}
|
|
7426
|
+
function addEventListener(target, type, callback, options) {
|
|
7427
|
+
target.addEventListener(type, callback, options);
|
|
7428
|
+
}
|
|
7429
|
+
function removeEventListener(target, type, callback, options) {
|
|
7430
|
+
target.removeEventListener(type, callback, options);
|
|
7431
|
+
}
|
|
7432
|
+
function dispatchEvent(target, event) {
|
|
7433
|
+
return target.dispatchEvent(event);
|
|
7434
|
+
}
|
|
7435
|
+
function getClassList(element) {
|
|
7436
|
+
return element.classList;
|
|
7437
|
+
}
|
|
7438
|
+
function setCSSStyleProperty(element, name, value, important) {
|
|
7439
|
+
// TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
|
|
7440
|
+
// represent elements in the engine?
|
|
7441
|
+
element.style.setProperty(name, value, important ? 'important' : '');
|
|
7442
|
+
}
|
|
7443
|
+
function getBoundingClientRect(element) {
|
|
7444
|
+
return element.getBoundingClientRect();
|
|
7445
|
+
}
|
|
7446
|
+
function querySelector(element, selectors) {
|
|
7447
|
+
return element.querySelector(selectors);
|
|
7448
|
+
}
|
|
7449
|
+
function querySelectorAll(element, selectors) {
|
|
7450
|
+
return element.querySelectorAll(selectors);
|
|
7451
|
+
}
|
|
7452
|
+
function getElementsByTagName(element, tagNameOrWildCard) {
|
|
7453
|
+
return element.getElementsByTagName(tagNameOrWildCard);
|
|
7454
|
+
}
|
|
7455
|
+
function getElementsByClassName(element, names) {
|
|
7456
|
+
return element.getElementsByClassName(names);
|
|
7457
|
+
}
|
|
7458
|
+
function getChildren(element) {
|
|
7459
|
+
return element.children;
|
|
7460
|
+
}
|
|
7461
|
+
function getChildNodes(element) {
|
|
7462
|
+
return element.childNodes;
|
|
7463
|
+
}
|
|
7464
|
+
function getFirstChild(element) {
|
|
7465
|
+
return element.firstChild;
|
|
7466
|
+
}
|
|
7467
|
+
function getFirstElementChild(element) {
|
|
7468
|
+
return element.firstElementChild;
|
|
7469
|
+
}
|
|
7470
|
+
function getLastChild(element) {
|
|
7471
|
+
return element.lastChild;
|
|
7472
|
+
}
|
|
7473
|
+
function getLastElementChild(element) {
|
|
7474
|
+
return element.lastElementChild;
|
|
7475
|
+
}
|
|
7476
|
+
function isConnected(node) {
|
|
7477
|
+
return node.isConnected;
|
|
7478
|
+
}
|
|
7479
|
+
function assertInstanceOfHTMLElement(elm, msg) {
|
|
7480
|
+
assertInvariant(elm instanceof HTMLElement, msg);
|
|
7481
|
+
}
|
|
7482
|
+
const HTMLElementExported = HTMLElementConstructor;
|
|
7483
|
+
const renderer = {
|
|
7484
|
+
HTMLElementExported,
|
|
7485
|
+
insert,
|
|
7486
|
+
remove,
|
|
7487
|
+
cloneNode,
|
|
7488
|
+
createFragment,
|
|
7489
|
+
createElement,
|
|
7490
|
+
createText,
|
|
7491
|
+
createComment,
|
|
7492
|
+
nextSibling,
|
|
7493
|
+
attachShadow,
|
|
7494
|
+
getProperty,
|
|
7495
|
+
setProperty,
|
|
7496
|
+
setText,
|
|
7497
|
+
getAttribute,
|
|
7498
|
+
setAttribute,
|
|
7499
|
+
removeAttribute,
|
|
7500
|
+
addEventListener,
|
|
7501
|
+
removeEventListener,
|
|
7502
|
+
dispatchEvent,
|
|
7503
|
+
getClassList,
|
|
7504
|
+
setCSSStyleProperty,
|
|
7505
|
+
getBoundingClientRect,
|
|
7506
|
+
querySelector,
|
|
7507
|
+
querySelectorAll,
|
|
7508
|
+
getElementsByTagName,
|
|
7509
|
+
getElementsByClassName,
|
|
7510
|
+
getChildren,
|
|
7511
|
+
getChildNodes,
|
|
7512
|
+
getFirstChild,
|
|
7513
|
+
getFirstElementChild,
|
|
7514
|
+
getLastChild,
|
|
7515
|
+
getLastElementChild,
|
|
7516
|
+
isConnected,
|
|
7517
|
+
assertInstanceOfHTMLElement,
|
|
7518
|
+
defineCustomElement,
|
|
7519
|
+
getCustomElement,
|
|
7042
7520
|
};
|
|
7521
|
+
// Meant to inherit any properties passed via the base renderer as the argument to the factory.
|
|
7522
|
+
Object.setPrototypeOf(renderer, baseRenderer);
|
|
7523
|
+
return renderer;
|
|
7043
7524
|
}
|
|
7044
7525
|
|
|
7045
7526
|
/*
|
|
@@ -7048,245 +7529,21 @@
|
|
|
7048
7529
|
* SPDX-License-Identifier: MIT
|
|
7049
7530
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7050
7531
|
*/
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
// get wrapped by babel.
|
|
7063
|
-
const HTMLElementAlias = HTMLElement;
|
|
7064
|
-
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
7065
|
-
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
7066
|
-
// which are not equipped to be initialized that way.
|
|
7067
|
-
class clazz extends HTMLElementAlias {
|
|
7068
|
-
}
|
|
7069
|
-
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
7070
|
-
new clazz();
|
|
7071
|
-
return true;
|
|
7072
|
-
}
|
|
7073
|
-
catch (_a) {
|
|
7074
|
-
return false;
|
|
7075
|
-
}
|
|
7076
|
-
}
|
|
7077
|
-
if (isCustomElementRegistryAvailable()) {
|
|
7078
|
-
getCustomElement = customElements.get.bind(customElements);
|
|
7079
|
-
defineCustomElement = customElements.define.bind(customElements);
|
|
7080
|
-
HTMLElementConstructor = HTMLElement;
|
|
7081
|
-
}
|
|
7082
|
-
else {
|
|
7083
|
-
const registry = create(null);
|
|
7084
|
-
const reverseRegistry = new WeakMap();
|
|
7085
|
-
defineCustomElement = function define(name, ctor) {
|
|
7086
|
-
if (name !== StringToLowerCase.call(name) || registry[name]) {
|
|
7087
|
-
throw new TypeError(`Invalid Registration`);
|
|
7088
|
-
}
|
|
7089
|
-
registry[name] = ctor;
|
|
7090
|
-
reverseRegistry.set(ctor, name);
|
|
7091
|
-
};
|
|
7092
|
-
getCustomElement = function get(name) {
|
|
7093
|
-
return registry[name];
|
|
7094
|
-
};
|
|
7095
|
-
HTMLElementConstructor = function HTMLElement() {
|
|
7096
|
-
if (!(this instanceof HTMLElement)) {
|
|
7097
|
-
throw new TypeError(`Invalid Invocation`);
|
|
7098
|
-
}
|
|
7099
|
-
const { constructor } = this;
|
|
7100
|
-
const name = reverseRegistry.get(constructor);
|
|
7101
|
-
if (!name) {
|
|
7102
|
-
throw new TypeError(`Invalid Construction`);
|
|
7103
|
-
}
|
|
7104
|
-
const elm = document.createElement(name);
|
|
7105
|
-
setPrototypeOf(elm, constructor.prototype);
|
|
7106
|
-
return elm;
|
|
7107
|
-
};
|
|
7108
|
-
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
7109
|
-
}
|
|
7110
|
-
let hydrating = false;
|
|
7111
|
-
function setIsHydrating(value) {
|
|
7112
|
-
hydrating = value;
|
|
7113
|
-
}
|
|
7114
|
-
const ssr = false;
|
|
7115
|
-
function isHydrating() {
|
|
7116
|
-
return hydrating;
|
|
7117
|
-
}
|
|
7118
|
-
const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
|
|
7119
|
-
const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
|
|
7120
|
-
function cloneNode(node, deep) {
|
|
7121
|
-
return node.cloneNode(deep);
|
|
7122
|
-
}
|
|
7123
|
-
function createElement$1(tagName, namespace) {
|
|
7124
|
-
return isUndefined$1(namespace)
|
|
7125
|
-
? document.createElement(tagName)
|
|
7126
|
-
: document.createElementNS(namespace, tagName);
|
|
7127
|
-
}
|
|
7128
|
-
function createText(content) {
|
|
7129
|
-
return document.createTextNode(content);
|
|
7130
|
-
}
|
|
7131
|
-
function createComment(content) {
|
|
7132
|
-
return document.createComment(content);
|
|
7133
|
-
}
|
|
7134
|
-
function insert(node, parent, anchor) {
|
|
7135
|
-
parent.insertBefore(node, anchor);
|
|
7136
|
-
}
|
|
7137
|
-
function remove(node, parent) {
|
|
7138
|
-
parent.removeChild(node);
|
|
7139
|
-
}
|
|
7140
|
-
function nextSibling(node) {
|
|
7141
|
-
return node.nextSibling;
|
|
7142
|
-
}
|
|
7143
|
-
function attachShadow(element, options) {
|
|
7144
|
-
// `hydrating` will be true in two cases:
|
|
7145
|
-
// 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
|
|
7146
|
-
// 2. when a webapp author places <c-app> in their static HTML and mounts their
|
|
7147
|
-
// root component with customeElement.define('c-app', Ctor)
|
|
7148
|
-
//
|
|
7149
|
-
// The second case can be treated as a failed hydration with nominal impact
|
|
7150
|
-
// to performance. However, because <c-app> won't have a <template shadowroot>
|
|
7151
|
-
// declarative child, `element.shadowRoot` is `null`.
|
|
7152
|
-
if (hydrating && element.shadowRoot) {
|
|
7153
|
-
return element.shadowRoot;
|
|
7154
|
-
}
|
|
7155
|
-
return element.attachShadow(options);
|
|
7156
|
-
}
|
|
7157
|
-
function setText(node, content) {
|
|
7158
|
-
node.nodeValue = content;
|
|
7159
|
-
}
|
|
7160
|
-
function getProperty(node, key) {
|
|
7161
|
-
return node[key];
|
|
7162
|
-
}
|
|
7163
|
-
function setProperty(node, key, value) {
|
|
7164
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
7165
|
-
if (node instanceof Element && !(key in node)) {
|
|
7166
|
-
// TODO [#1297]: Move this validation to the compiler
|
|
7167
|
-
assert.fail(`Unknown public property "${key}" of element <${node.tagName}>. This is likely a typo on the corresponding attribute "${htmlPropertyToAttribute(key)}".`);
|
|
7168
|
-
}
|
|
7169
|
-
}
|
|
7170
|
-
node[key] = value;
|
|
7171
|
-
}
|
|
7172
|
-
function getAttribute(element, name, namespace) {
|
|
7173
|
-
return isUndefined$1(namespace)
|
|
7174
|
-
? element.getAttribute(name)
|
|
7175
|
-
: element.getAttributeNS(namespace, name);
|
|
7176
|
-
}
|
|
7177
|
-
function setAttribute(element, name, value, namespace) {
|
|
7178
|
-
return isUndefined$1(namespace)
|
|
7179
|
-
? element.setAttribute(name, value)
|
|
7180
|
-
: element.setAttributeNS(namespace, name, value);
|
|
7181
|
-
}
|
|
7182
|
-
function removeAttribute(element, name, namespace) {
|
|
7183
|
-
if (isUndefined$1(namespace)) {
|
|
7184
|
-
element.removeAttribute(name);
|
|
7185
|
-
}
|
|
7186
|
-
else {
|
|
7187
|
-
element.removeAttributeNS(namespace, name);
|
|
7188
|
-
}
|
|
7189
|
-
}
|
|
7190
|
-
function addEventListener(target, type, callback, options) {
|
|
7191
|
-
target.addEventListener(type, callback, options);
|
|
7192
|
-
}
|
|
7193
|
-
function removeEventListener(target, type, callback, options) {
|
|
7194
|
-
target.removeEventListener(type, callback, options);
|
|
7195
|
-
}
|
|
7196
|
-
function dispatchEvent(target, event) {
|
|
7197
|
-
return target.dispatchEvent(event);
|
|
7198
|
-
}
|
|
7199
|
-
function getClassList(element) {
|
|
7200
|
-
return element.classList;
|
|
7201
|
-
}
|
|
7202
|
-
function setCSSStyleProperty(element, name, value, important) {
|
|
7203
|
-
// TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
|
|
7204
|
-
// represent elements in the engine?
|
|
7205
|
-
element.style.setProperty(name, value, important ? 'important' : '');
|
|
7206
|
-
}
|
|
7207
|
-
function getBoundingClientRect(element) {
|
|
7208
|
-
return element.getBoundingClientRect();
|
|
7209
|
-
}
|
|
7210
|
-
function querySelector(element, selectors) {
|
|
7211
|
-
return element.querySelector(selectors);
|
|
7212
|
-
}
|
|
7213
|
-
function querySelectorAll(element, selectors) {
|
|
7214
|
-
return element.querySelectorAll(selectors);
|
|
7215
|
-
}
|
|
7216
|
-
function getElementsByTagName(element, tagNameOrWildCard) {
|
|
7217
|
-
return element.getElementsByTagName(tagNameOrWildCard);
|
|
7218
|
-
}
|
|
7219
|
-
function getElementsByClassName(element, names) {
|
|
7220
|
-
return element.getElementsByClassName(names);
|
|
7221
|
-
}
|
|
7222
|
-
function getChildren(element) {
|
|
7223
|
-
return element.children;
|
|
7224
|
-
}
|
|
7225
|
-
function getChildNodes(element) {
|
|
7226
|
-
return element.childNodes;
|
|
7227
|
-
}
|
|
7228
|
-
function getFirstChild(element) {
|
|
7229
|
-
return element.firstChild;
|
|
7230
|
-
}
|
|
7231
|
-
function getFirstElementChild(element) {
|
|
7232
|
-
return element.firstElementChild;
|
|
7233
|
-
}
|
|
7234
|
-
function getLastChild(element) {
|
|
7235
|
-
return element.lastChild;
|
|
7236
|
-
}
|
|
7237
|
-
function getLastElementChild(element) {
|
|
7238
|
-
return element.lastElementChild;
|
|
7239
|
-
}
|
|
7240
|
-
function isConnected(node) {
|
|
7241
|
-
return node.isConnected;
|
|
7242
|
-
}
|
|
7243
|
-
function assertInstanceOfHTMLElement(elm, msg) {
|
|
7244
|
-
assert.invariant(elm instanceof HTMLElement, msg);
|
|
7245
|
-
}
|
|
7246
|
-
const HTMLElementExported = HTMLElementConstructor;
|
|
7247
|
-
const renderer = {
|
|
7248
|
-
ssr,
|
|
7249
|
-
isNativeShadowDefined,
|
|
7250
|
-
isSyntheticShadowDefined,
|
|
7251
|
-
HTMLElementExported,
|
|
7252
|
-
isHydrating,
|
|
7253
|
-
insert,
|
|
7254
|
-
remove,
|
|
7255
|
-
cloneNode,
|
|
7256
|
-
createFragment,
|
|
7257
|
-
createElement: createElement$1,
|
|
7258
|
-
createText,
|
|
7259
|
-
createComment,
|
|
7260
|
-
nextSibling,
|
|
7261
|
-
attachShadow,
|
|
7262
|
-
getProperty,
|
|
7263
|
-
setProperty,
|
|
7264
|
-
setText,
|
|
7265
|
-
getAttribute,
|
|
7266
|
-
setAttribute,
|
|
7267
|
-
removeAttribute,
|
|
7268
|
-
addEventListener,
|
|
7269
|
-
removeEventListener,
|
|
7270
|
-
dispatchEvent,
|
|
7271
|
-
getClassList,
|
|
7272
|
-
setCSSStyleProperty,
|
|
7273
|
-
getBoundingClientRect,
|
|
7274
|
-
querySelector,
|
|
7275
|
-
querySelectorAll,
|
|
7276
|
-
getElementsByTagName,
|
|
7277
|
-
getElementsByClassName,
|
|
7278
|
-
getChildren,
|
|
7279
|
-
getChildNodes,
|
|
7280
|
-
getFirstChild,
|
|
7281
|
-
getFirstElementChild,
|
|
7282
|
-
getLastChild,
|
|
7283
|
-
getLastElementChild,
|
|
7284
|
-
isConnected,
|
|
7532
|
+
/**
|
|
7533
|
+
* The base renderer that will be used by engine-core.
|
|
7534
|
+
* This will be used for DOM operations when lwc is running in a browser environment.
|
|
7535
|
+
*/
|
|
7536
|
+
const renderer = assign(
|
|
7537
|
+
// The base renderer will invoke the factory with null and assign additional properties that are
|
|
7538
|
+
// shared across renderers
|
|
7539
|
+
rendererFactory(null),
|
|
7540
|
+
// Properties that are either not required to be sandboxed or rely on a globally shared information
|
|
7541
|
+
{
|
|
7542
|
+
// insertStyleSheet implementation shares a global cache of stylesheet data
|
|
7285
7543
|
insertStylesheet,
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
};
|
|
7544
|
+
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
7545
|
+
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
|
|
7546
|
+
});
|
|
7290
7547
|
|
|
7291
7548
|
/*
|
|
7292
7549
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7335,13 +7592,8 @@
|
|
|
7335
7592
|
return;
|
|
7336
7593
|
}
|
|
7337
7594
|
try {
|
|
7338
|
-
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
7339
|
-
// and uses the same algo to create the stylesheets as in SSR.
|
|
7340
|
-
setIsHydrating(true);
|
|
7341
7595
|
const vm = createVMWithProps(element, Ctor, props);
|
|
7342
7596
|
hydrateRoot(vm);
|
|
7343
|
-
// set it back since now we finished hydration.
|
|
7344
|
-
setIsHydrating(false);
|
|
7345
7597
|
}
|
|
7346
7598
|
catch (e) {
|
|
7347
7599
|
// Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
|
|
@@ -7352,13 +7604,8 @@
|
|
|
7352
7604
|
resetShadowRootAndLightDom(element, Ctor);
|
|
7353
7605
|
// we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
|
|
7354
7606
|
createVMWithProps(element, Ctor, props);
|
|
7355
|
-
setIsHydrating(false);
|
|
7356
7607
|
connectRootElement(element);
|
|
7357
7608
|
}
|
|
7358
|
-
finally {
|
|
7359
|
-
// in case there's an error during recovery
|
|
7360
|
-
setIsHydrating(false);
|
|
7361
|
-
}
|
|
7362
7609
|
}
|
|
7363
7610
|
|
|
7364
7611
|
/*
|
|
@@ -7432,44 +7679,60 @@
|
|
|
7432
7679
|
* SPDX-License-Identifier: MIT
|
|
7433
7680
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7434
7681
|
*/
|
|
7435
|
-
// TODO [#2472]: Remove this workaround when appropriate.
|
|
7436
7682
|
// eslint-disable-next-line @lwc/lwc-internal/no-global-node
|
|
7683
|
+
|
|
7437
7684
|
const _Node$1 = Node;
|
|
7438
7685
|
const ConnectingSlot = new WeakMap();
|
|
7439
7686
|
const DisconnectingSlot = new WeakMap();
|
|
7687
|
+
|
|
7440
7688
|
function callNodeSlot(node, slot) {
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7689
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7690
|
+
assert.isTrue(node, `callNodeSlot() should not be called for a non-object`);
|
|
7691
|
+
}
|
|
7692
|
+
|
|
7693
|
+
const fn = slot.get(node);
|
|
7694
|
+
|
|
7695
|
+
if (!isUndefined$1(fn)) {
|
|
7696
|
+
fn(node);
|
|
7697
|
+
}
|
|
7698
|
+
|
|
7699
|
+
return node; // for convenience
|
|
7449
7700
|
}
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7701
|
+
|
|
7702
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
7703
|
+
// Monkey patching Node methods to be able to detect the insertions and removal of root elements
|
|
7704
|
+
// created via createElement.
|
|
7705
|
+
const {
|
|
7706
|
+
appendChild,
|
|
7707
|
+
insertBefore,
|
|
7708
|
+
removeChild,
|
|
7709
|
+
replaceChild
|
|
7710
|
+
} = _Node$1.prototype;
|
|
7711
|
+
assign(_Node$1.prototype, {
|
|
7454
7712
|
appendChild(newChild) {
|
|
7455
|
-
|
|
7456
|
-
|
|
7713
|
+
const appendedNode = appendChild.call(this, newChild);
|
|
7714
|
+
return callNodeSlot(appendedNode, ConnectingSlot);
|
|
7457
7715
|
},
|
|
7716
|
+
|
|
7458
7717
|
insertBefore(newChild, referenceNode) {
|
|
7459
|
-
|
|
7460
|
-
|
|
7718
|
+
const insertedNode = insertBefore.call(this, newChild, referenceNode);
|
|
7719
|
+
return callNodeSlot(insertedNode, ConnectingSlot);
|
|
7461
7720
|
},
|
|
7721
|
+
|
|
7462
7722
|
removeChild(oldChild) {
|
|
7463
|
-
|
|
7464
|
-
|
|
7723
|
+
const removedNode = removeChild.call(this, oldChild);
|
|
7724
|
+
return callNodeSlot(removedNode, DisconnectingSlot);
|
|
7465
7725
|
},
|
|
7726
|
+
|
|
7466
7727
|
replaceChild(newChild, oldChild) {
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
}
|
|
7472
|
-
|
|
7728
|
+
const replacedNode = replaceChild.call(this, newChild, oldChild);
|
|
7729
|
+
callNodeSlot(replacedNode, DisconnectingSlot);
|
|
7730
|
+
callNodeSlot(newChild, ConnectingSlot);
|
|
7731
|
+
return replacedNode;
|
|
7732
|
+
}
|
|
7733
|
+
|
|
7734
|
+
});
|
|
7735
|
+
}
|
|
7473
7736
|
/**
|
|
7474
7737
|
* EXPERIMENTAL: This function is almost identical to document.createElement with the slightly
|
|
7475
7738
|
* difference that in the options, you can pass the `is` property set to a Constructor instead of
|
|
@@ -7481,38 +7744,50 @@
|
|
|
7481
7744
|
* const el = createElement('x-foo', { is: FooCtor });
|
|
7482
7745
|
* ```
|
|
7483
7746
|
*/
|
|
7747
|
+
|
|
7748
|
+
|
|
7484
7749
|
function createElement(sel, options) {
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7750
|
+
if (!isObject(options) || isNull(options)) {
|
|
7751
|
+
throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
|
|
7752
|
+
}
|
|
7753
|
+
|
|
7754
|
+
const Ctor = options.is;
|
|
7755
|
+
|
|
7756
|
+
if (!isFunction$1(Ctor)) {
|
|
7757
|
+
throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
|
|
7758
|
+
}
|
|
7759
|
+
|
|
7760
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
7761
|
+
let wasComponentUpgraded = false; // the custom element from the registry is expecting an upgrade callback
|
|
7762
|
+
|
|
7763
|
+
/**
|
|
7764
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
7765
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
7766
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
7767
|
+
* an upgradable custom element.
|
|
7768
|
+
*/
|
|
7769
|
+
|
|
7770
|
+
const element = new UpgradableConstructor(elm => {
|
|
7771
|
+
createVM(elm, Ctor, renderer, {
|
|
7772
|
+
tagName: sel,
|
|
7773
|
+
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
7774
|
+
owner: null
|
|
7510
7775
|
});
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7776
|
+
|
|
7777
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
7778
|
+
ConnectingSlot.set(elm, connectRootElement);
|
|
7779
|
+
DisconnectingSlot.set(elm, disconnectRootElement);
|
|
7514
7780
|
}
|
|
7515
|
-
|
|
7781
|
+
|
|
7782
|
+
wasComponentUpgraded = true;
|
|
7783
|
+
});
|
|
7784
|
+
|
|
7785
|
+
if (!wasComponentUpgraded) {
|
|
7786
|
+
/* eslint-disable-next-line no-console */
|
|
7787
|
+
console.error(`Unexpected tag name "${sel}". This name is a registered custom element, preventing LWC to upgrade the element.`);
|
|
7788
|
+
}
|
|
7789
|
+
|
|
7790
|
+
return element;
|
|
7516
7791
|
}
|
|
7517
7792
|
|
|
7518
7793
|
/*
|
|
@@ -7546,7 +7821,7 @@
|
|
|
7546
7821
|
}
|
|
7547
7822
|
// TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
|
|
7548
7823
|
// inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
|
|
7549
|
-
return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
|
|
7824
|
+
return renderer.isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
|
|
7550
7825
|
}
|
|
7551
7826
|
|
|
7552
7827
|
/*
|
|
@@ -7583,7 +7858,7 @@
|
|
|
7583
7858
|
});
|
|
7584
7859
|
freeze(LightningElement);
|
|
7585
7860
|
seal(LightningElement.prototype);
|
|
7586
|
-
/* version: 2.
|
|
7861
|
+
/* version: 2.23.2 */
|
|
7587
7862
|
|
|
7588
7863
|
exports.LightningElement = LightningElement;
|
|
7589
7864
|
exports.__unstable__ProfilerControl = profilerControl;
|
|
@@ -7605,6 +7880,7 @@
|
|
|
7605
7880
|
exports.registerDecorators = registerDecorators;
|
|
7606
7881
|
exports.registerTemplate = registerTemplate;
|
|
7607
7882
|
exports.renderer = renderer;
|
|
7883
|
+
exports.rendererFactory = rendererFactory;
|
|
7608
7884
|
exports.sanitizeAttribute = sanitizeAttribute;
|
|
7609
7885
|
exports.setFeatureFlag = setFeatureFlag;
|
|
7610
7886
|
exports.setFeatureFlagForTest = setFeatureFlagForTest;
|