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
|
@@ -299,9 +299,13 @@ function htmlPropertyToAttribute(propName) {
|
|
|
299
299
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
300
300
|
*/
|
|
301
301
|
// Increment whenever the LWC template compiler changes
|
|
302
|
-
const LWC_VERSION = "2.
|
|
302
|
+
const LWC_VERSION = "2.23.2";
|
|
303
303
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
304
|
-
/** version: 2.
|
|
304
|
+
/** version: 2.23.2 */
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Copyright (C) 2018 salesforce.com, inc.
|
|
308
|
+
*/
|
|
305
309
|
|
|
306
310
|
/*
|
|
307
311
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -310,7 +314,7 @@ const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
|
310
314
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
311
315
|
*/
|
|
312
316
|
function detect(propName) {
|
|
313
|
-
return
|
|
317
|
+
return getOwnPropertyDescriptor$1(Element.prototype, propName) === undefined;
|
|
314
318
|
}
|
|
315
319
|
|
|
316
320
|
/*
|
|
@@ -379,6 +383,7 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
|
|
|
379
383
|
patch$1(propName);
|
|
380
384
|
}
|
|
381
385
|
}
|
|
386
|
+
/** version: 2.23.2 */
|
|
382
387
|
|
|
383
388
|
/**
|
|
384
389
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -398,6 +403,7 @@ const features = {
|
|
|
398
403
|
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
399
404
|
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
400
405
|
ENABLE_MIXED_SHADOW_MODE: null,
|
|
406
|
+
ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
|
|
401
407
|
ENABLE_NODE_LIST_PATCH: null,
|
|
402
408
|
ENABLE_NODE_PATCH: null,
|
|
403
409
|
ENABLE_REACTIVE_SETTER: null,
|
|
@@ -406,7 +412,7 @@ const features = {
|
|
|
406
412
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
407
413
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
408
414
|
}
|
|
409
|
-
const
|
|
415
|
+
const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
|
|
410
416
|
/**
|
|
411
417
|
* Set the value at runtime of a given feature flag. This method only be invoked once per feature
|
|
412
418
|
* flag. It is meant to be used during the app initialization.
|
|
@@ -433,17 +439,17 @@ function setFeatureFlag(name, value) {
|
|
|
433
439
|
}
|
|
434
440
|
if (process.env.NODE_ENV !== 'production') {
|
|
435
441
|
// Allow the same flag to be set more than once outside of production to enable testing
|
|
436
|
-
|
|
442
|
+
lwcRuntimeFlags[name] = value;
|
|
437
443
|
}
|
|
438
444
|
else {
|
|
439
445
|
// Disallow the same flag to be set more than once in production
|
|
440
|
-
const runtimeValue =
|
|
446
|
+
const runtimeValue = lwcRuntimeFlags[name];
|
|
441
447
|
if (!isUndefined$1(runtimeValue)) {
|
|
442
448
|
// eslint-disable-next-line no-console
|
|
443
449
|
console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
|
|
444
450
|
return;
|
|
445
451
|
}
|
|
446
|
-
defineProperty(
|
|
452
|
+
defineProperty(lwcRuntimeFlags, name, { value });
|
|
447
453
|
}
|
|
448
454
|
}
|
|
449
455
|
/**
|
|
@@ -455,7 +461,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
455
461
|
setFeatureFlag(name, value);
|
|
456
462
|
}
|
|
457
463
|
}
|
|
458
|
-
/** version: 2.
|
|
464
|
+
/** version: 2.23.2 */
|
|
459
465
|
|
|
460
466
|
/*
|
|
461
467
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -469,7 +475,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
|
469
475
|
window.addEventListener('test-dummy-flag', () => {
|
|
470
476
|
let hasFlag = false;
|
|
471
477
|
|
|
472
|
-
if (
|
|
478
|
+
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
473
479
|
hasFlag = true;
|
|
474
480
|
}
|
|
475
481
|
|
|
@@ -496,7 +502,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
|
496
502
|
window.addEventListener('test-dummy-flag', () => {
|
|
497
503
|
let hasFlag = false;
|
|
498
504
|
|
|
499
|
-
if (
|
|
505
|
+
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
500
506
|
hasFlag = true;
|
|
501
507
|
}
|
|
502
508
|
|
|
@@ -804,8 +810,8 @@ function isCircularModuleDependency(obj) {
|
|
|
804
810
|
*/
|
|
805
811
|
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having
|
|
806
812
|
// to inject at runtime.
|
|
807
|
-
const HTMLElementConstructor
|
|
808
|
-
const HTMLElementPrototype = HTMLElementConstructor
|
|
813
|
+
const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () { };
|
|
814
|
+
const HTMLElementPrototype = HTMLElementConstructor.prototype;
|
|
809
815
|
|
|
810
816
|
/*
|
|
811
817
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1260,6 +1266,14 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
|
|
|
1260
1266
|
defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
|
1261
1267
|
}
|
|
1262
1268
|
|
|
1269
|
+
function updateComponentValue(vm, key, newValue) {
|
|
1270
|
+
const { cmpFields } = vm;
|
|
1271
|
+
if (newValue !== cmpFields[key]) {
|
|
1272
|
+
cmpFields[key] = newValue;
|
|
1273
|
+
componentValueMutated(vm, key);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1263
1277
|
/**
|
|
1264
1278
|
* Copyright (C) 2017 salesforce.com, inc.
|
|
1265
1279
|
*/
|
|
@@ -1892,10 +1906,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
|
|
|
1892
1906
|
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1893
1907
|
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1894
1908
|
}
|
|
1895
|
-
|
|
1896
|
-
vm.cmpProps[propName] = newValue;
|
|
1897
|
-
componentValueMutated(vm, propName);
|
|
1898
|
-
}
|
|
1909
|
+
updateComponentValue(vm, propName, newValue);
|
|
1899
1910
|
return set.call(vm.elm, newValue);
|
|
1900
1911
|
},
|
|
1901
1912
|
};
|
|
@@ -2190,10 +2201,7 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
2190
2201
|
},
|
|
2191
2202
|
set(newValue) {
|
|
2192
2203
|
const vm = getAssociatedVM(this);
|
|
2193
|
-
|
|
2194
|
-
vm.cmpFields[key] = newValue;
|
|
2195
|
-
componentValueMutated(vm, key);
|
|
2196
|
-
}
|
|
2204
|
+
updateComponentValue(vm, key, newValue);
|
|
2197
2205
|
},
|
|
2198
2206
|
enumerable: true,
|
|
2199
2207
|
configurable: true,
|
|
@@ -2322,7 +2330,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
2322
2330
|
}
|
|
2323
2331
|
|
|
2324
2332
|
if (set) {
|
|
2325
|
-
if (
|
|
2333
|
+
if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
|
|
2326
2334
|
let ro = vm.oar[key];
|
|
2327
2335
|
|
|
2328
2336
|
if (isUndefined$1(ro)) {
|
|
@@ -2380,10 +2388,7 @@ function internalTrackDecorator(key) {
|
|
|
2380
2388
|
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2381
2389
|
}
|
|
2382
2390
|
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
2383
|
-
|
|
2384
|
-
vm.cmpFields[key] = reactiveOrAnyValue;
|
|
2385
|
-
componentValueMutated(vm, key);
|
|
2386
|
-
}
|
|
2391
|
+
updateComponentValue(vm, key, reactiveOrAnyValue);
|
|
2387
2392
|
},
|
|
2388
2393
|
enumerable: true,
|
|
2389
2394
|
configurable: true,
|
|
@@ -2422,10 +2427,7 @@ function internalWireFieldDecorator(key) {
|
|
|
2422
2427
|
* letting the author to do the wrong thing, but it will keep our
|
|
2423
2428
|
* system to be backward compatible.
|
|
2424
2429
|
*/
|
|
2425
|
-
|
|
2426
|
-
vm.cmpFields[key] = value;
|
|
2427
|
-
componentValueMutated(vm, key);
|
|
2428
|
-
}
|
|
2430
|
+
updateComponentValue(vm, key, value);
|
|
2429
2431
|
},
|
|
2430
2432
|
enumerable: true,
|
|
2431
2433
|
configurable: true,
|
|
@@ -2886,7 +2888,7 @@ function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
|
2886
2888
|
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
2887
2889
|
return HTMLBridgeElement;
|
|
2888
2890
|
}
|
|
2889
|
-
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor
|
|
2891
|
+
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
|
|
2890
2892
|
freeze(BaseBridgeElement);
|
|
2891
2893
|
seal(BaseBridgeElement.prototype);
|
|
2892
2894
|
|
|
@@ -2980,7 +2982,7 @@ function getTemplateOrSwappedTemplate(tpl) {
|
|
|
2980
2982
|
throw new ReferenceError();
|
|
2981
2983
|
}
|
|
2982
2984
|
|
|
2983
|
-
if (
|
|
2985
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
2984
2986
|
const visited = new Set();
|
|
2985
2987
|
|
|
2986
2988
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
@@ -2997,7 +2999,7 @@ function getComponentOrSwappedComponent(Ctor) {
|
|
|
2997
2999
|
throw new ReferenceError();
|
|
2998
3000
|
}
|
|
2999
3001
|
|
|
3000
|
-
if (
|
|
3002
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3001
3003
|
const visited = new Set();
|
|
3002
3004
|
|
|
3003
3005
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
@@ -3014,7 +3016,7 @@ function getStyleOrSwappedStyle(style) {
|
|
|
3014
3016
|
throw new ReferenceError();
|
|
3015
3017
|
}
|
|
3016
3018
|
|
|
3017
|
-
if (
|
|
3019
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3018
3020
|
const visited = new Set();
|
|
3019
3021
|
|
|
3020
3022
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
@@ -3031,7 +3033,7 @@ function setActiveVM(vm) {
|
|
|
3031
3033
|
throw new ReferenceError();
|
|
3032
3034
|
}
|
|
3033
3035
|
|
|
3034
|
-
if (
|
|
3036
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3035
3037
|
// tracking active component
|
|
3036
3038
|
const Ctor = vm.def.ctor;
|
|
3037
3039
|
let componentVMs = activeComponents.get(Ctor);
|
|
@@ -3088,7 +3090,7 @@ function removeActiveVM(vm) {
|
|
|
3088
3090
|
throw new ReferenceError();
|
|
3089
3091
|
}
|
|
3090
3092
|
|
|
3091
|
-
if (
|
|
3093
|
+
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3092
3094
|
// tracking inactive component
|
|
3093
3095
|
const Ctor = vm.def.ctor;
|
|
3094
3096
|
let list = activeComponents.get(Ctor);
|
|
@@ -3135,7 +3137,7 @@ function swapTemplate(oldTpl, newTpl) {
|
|
|
3135
3137
|
}
|
|
3136
3138
|
}
|
|
3137
3139
|
|
|
3138
|
-
if (!
|
|
3140
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3139
3141
|
throw new Error('HMR is not enabled');
|
|
3140
3142
|
}
|
|
3141
3143
|
|
|
@@ -3151,7 +3153,7 @@ function swapComponent(oldComponent, newComponent) {
|
|
|
3151
3153
|
}
|
|
3152
3154
|
}
|
|
3153
3155
|
|
|
3154
|
-
if (!
|
|
3156
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3155
3157
|
throw new Error('HMR is not enabled');
|
|
3156
3158
|
}
|
|
3157
3159
|
|
|
@@ -3165,7 +3167,7 @@ function swapStyle(oldStyle, newStyle) {
|
|
|
3165
3167
|
return rehydrateHotStyle(oldStyle);
|
|
3166
3168
|
}
|
|
3167
3169
|
|
|
3168
|
-
if (!
|
|
3170
|
+
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3169
3171
|
throw new Error('HMR is not enabled');
|
|
3170
3172
|
}
|
|
3171
3173
|
|
|
@@ -3514,13 +3516,13 @@ function getNearestNativeShadowComponent(vm) {
|
|
|
3514
3516
|
return owner;
|
|
3515
3517
|
}
|
|
3516
3518
|
function createStylesheet(vm, stylesheets) {
|
|
3517
|
-
const { renderMode, shadowMode, renderer: {
|
|
3519
|
+
const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
|
|
3518
3520
|
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3519
3521
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3520
3522
|
insertStylesheet(stylesheets[i]);
|
|
3521
3523
|
}
|
|
3522
3524
|
}
|
|
3523
|
-
else if (
|
|
3525
|
+
else if (vm.hydrated) {
|
|
3524
3526
|
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3525
3527
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3526
3528
|
// the first time the VM renders.
|
|
@@ -3545,30 +3547,67 @@ function createStylesheet(vm, stylesheets) {
|
|
|
3545
3547
|
* SPDX-License-Identifier: MIT
|
|
3546
3548
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3547
3549
|
*/
|
|
3550
|
+
|
|
3551
|
+
function checkHasVM(elm) {
|
|
3552
|
+
const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
3553
|
+
|
|
3554
|
+
if (process.env.NODE_ENV !== 'production' && !hasVM) {
|
|
3555
|
+
// Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
|
|
3556
|
+
// we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
|
|
3557
|
+
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.`);
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3560
|
+
return hasVM;
|
|
3561
|
+
}
|
|
3562
|
+
|
|
3548
3563
|
function getUpgradableConstructor(tagName, renderer) {
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3564
|
+
const {
|
|
3565
|
+
getCustomElement,
|
|
3566
|
+
HTMLElementExported: RendererHTMLElement,
|
|
3567
|
+
defineCustomElement
|
|
3568
|
+
} = renderer; // Should never get a tag with upper case letter at this point, the compiler should
|
|
3569
|
+
// produce only tags with lowercase letters
|
|
3570
|
+
// But, for backwards compatibility, we will lower case the tagName
|
|
3571
|
+
|
|
3572
|
+
tagName = tagName.toLowerCase();
|
|
3573
|
+
let CE = getCustomElement(tagName);
|
|
3574
|
+
|
|
3575
|
+
if (!isUndefined$1(CE)) {
|
|
3576
|
+
return CE;
|
|
3577
|
+
}
|
|
3578
|
+
/**
|
|
3579
|
+
* LWC Upgradable Element reference to an element that was created
|
|
3580
|
+
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3581
|
+
*/
|
|
3582
|
+
|
|
3583
|
+
|
|
3584
|
+
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3585
|
+
constructor(upgradeCallback) {
|
|
3586
|
+
super();
|
|
3587
|
+
|
|
3588
|
+
if (isFunction$1(upgradeCallback)) {
|
|
3589
|
+
upgradeCallback(this); // nothing to do with the result for now
|
|
3590
|
+
}
|
|
3557
3591
|
}
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
CE =
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
upgradeCallback(this); // nothing to do with the result for now
|
|
3567
|
-
}
|
|
3568
|
-
}
|
|
3592
|
+
|
|
3593
|
+
};
|
|
3594
|
+
|
|
3595
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3596
|
+
CE.prototype.connectedCallback = function () {
|
|
3597
|
+
if (checkHasVM(this)) {
|
|
3598
|
+
connectRootElement(this);
|
|
3599
|
+
}
|
|
3569
3600
|
};
|
|
3570
|
-
|
|
3571
|
-
|
|
3601
|
+
|
|
3602
|
+
CE.prototype.disconnectedCallback = function () {
|
|
3603
|
+
if (checkHasVM(this)) {
|
|
3604
|
+
disconnectRootElement(this);
|
|
3605
|
+
}
|
|
3606
|
+
};
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3609
|
+
defineCustomElement(tagName, CE);
|
|
3610
|
+
return CE;
|
|
3572
3611
|
}
|
|
3573
3612
|
|
|
3574
3613
|
/*
|
|
@@ -3656,6 +3695,14 @@ function patchProps(oldVnode, vnode, renderer) {
|
|
|
3656
3695
|
// different than the one previously set.
|
|
3657
3696
|
if (isFirstPatch ||
|
|
3658
3697
|
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
|
|
3698
|
+
// Additional verification if properties are supported by the element
|
|
3699
|
+
// Validation relies on html properties and public properties being defined on the element,
|
|
3700
|
+
// SSR has its own custom validation.
|
|
3701
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3702
|
+
if (!(key in elm)) {
|
|
3703
|
+
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.`);
|
|
3704
|
+
}
|
|
3705
|
+
}
|
|
3659
3706
|
setProperty(elm, key, cur);
|
|
3660
3707
|
}
|
|
3661
3708
|
}
|
|
@@ -3814,569 +3861,798 @@ function applyStaticStyleAttribute(vnode, renderer) {
|
|
|
3814
3861
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3815
3862
|
*/
|
|
3816
3863
|
function patchChildren(c1, c2, parent, renderer) {
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
}
|
|
3864
|
+
if (hasDynamicChildren(c2)) {
|
|
3865
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
3866
|
+
} else {
|
|
3867
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
3868
|
+
}
|
|
3823
3869
|
}
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
break;
|
|
3842
|
-
case 1 /* VNodeType.Comment */:
|
|
3843
|
-
// VComment has no special capability, fallback to the owner's renderer
|
|
3844
|
-
patchComment(n1, n2, renderer);
|
|
3845
|
-
break;
|
|
3846
|
-
case 4 /* VNodeType.Static */:
|
|
3847
|
-
n2.elm = n1.elm;
|
|
3848
|
-
break;
|
|
3849
|
-
case 2 /* VNodeType.Element */:
|
|
3850
|
-
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3851
|
-
break;
|
|
3852
|
-
case 3 /* VNodeType.CustomElement */:
|
|
3853
|
-
patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3854
|
-
break;
|
|
3870
|
+
|
|
3871
|
+
function patch(n1, n2, parent, renderer) {
|
|
3872
|
+
var _a, _b;
|
|
3873
|
+
|
|
3874
|
+
if (n1 === n2) {
|
|
3875
|
+
return;
|
|
3876
|
+
}
|
|
3877
|
+
|
|
3878
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3879
|
+
if (!isSameVnode(n1, n2)) {
|
|
3880
|
+
throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
|
|
3881
|
+
sel: n1.sel,
|
|
3882
|
+
key: n1.key
|
|
3883
|
+
}) + ', ' + JSON.stringify({
|
|
3884
|
+
sel: n2.sel,
|
|
3885
|
+
key: n2.key
|
|
3886
|
+
}));
|
|
3855
3887
|
}
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
switch (n2.type) {
|
|
3891
|
+
case 0
|
|
3892
|
+
/* VNodeType.Text */
|
|
3893
|
+
:
|
|
3894
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3895
|
+
patchText(n1, n2, renderer);
|
|
3896
|
+
break;
|
|
3897
|
+
|
|
3898
|
+
case 1
|
|
3899
|
+
/* VNodeType.Comment */
|
|
3900
|
+
:
|
|
3901
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3902
|
+
patchComment(n1, n2, renderer);
|
|
3903
|
+
break;
|
|
3904
|
+
|
|
3905
|
+
case 4
|
|
3906
|
+
/* VNodeType.Static */
|
|
3907
|
+
:
|
|
3908
|
+
n2.elm = n1.elm;
|
|
3909
|
+
break;
|
|
3910
|
+
|
|
3911
|
+
case 2
|
|
3912
|
+
/* VNodeType.Element */
|
|
3913
|
+
:
|
|
3914
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3915
|
+
break;
|
|
3916
|
+
|
|
3917
|
+
case 3
|
|
3918
|
+
/* VNodeType.CustomElement */
|
|
3919
|
+
:
|
|
3920
|
+
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3921
|
+
break;
|
|
3922
|
+
}
|
|
3856
3923
|
}
|
|
3924
|
+
|
|
3857
3925
|
function mount(node, parent, renderer, anchor) {
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3926
|
+
var _a, _b;
|
|
3927
|
+
|
|
3928
|
+
switch (node.type) {
|
|
3929
|
+
case 0
|
|
3930
|
+
/* VNodeType.Text */
|
|
3931
|
+
:
|
|
3932
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3933
|
+
mountText(node, parent, anchor, renderer);
|
|
3934
|
+
break;
|
|
3935
|
+
|
|
3936
|
+
case 1
|
|
3937
|
+
/* VNodeType.Comment */
|
|
3938
|
+
:
|
|
3939
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3940
|
+
mountComment(node, parent, anchor, renderer);
|
|
3941
|
+
break;
|
|
3942
|
+
|
|
3943
|
+
case 4
|
|
3944
|
+
/* VNodeType.Static */
|
|
3945
|
+
:
|
|
3946
|
+
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
3947
|
+
mountStatic(node, parent, anchor, renderer);
|
|
3948
|
+
break;
|
|
3949
|
+
|
|
3950
|
+
case 2
|
|
3951
|
+
/* VNodeType.Element */
|
|
3952
|
+
:
|
|
3953
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3954
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3955
|
+
break;
|
|
3956
|
+
|
|
3957
|
+
case 3
|
|
3958
|
+
/* VNodeType.CustomElement */
|
|
3959
|
+
:
|
|
3960
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3961
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3962
|
+
break;
|
|
3963
|
+
}
|
|
3881
3964
|
}
|
|
3965
|
+
|
|
3882
3966
|
function patchText(n1, n2, renderer) {
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3967
|
+
n2.elm = n1.elm;
|
|
3968
|
+
|
|
3969
|
+
if (n2.text !== n1.text) {
|
|
3970
|
+
updateTextContent(n2, renderer);
|
|
3971
|
+
}
|
|
3887
3972
|
}
|
|
3973
|
+
|
|
3888
3974
|
function mountText(vnode, parent, anchor, renderer) {
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3975
|
+
const {
|
|
3976
|
+
owner
|
|
3977
|
+
} = vnode;
|
|
3978
|
+
const {
|
|
3979
|
+
createText
|
|
3980
|
+
} = renderer;
|
|
3981
|
+
const textNode = vnode.elm = createText(vnode.text);
|
|
3982
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
3983
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
3894
3984
|
}
|
|
3985
|
+
|
|
3895
3986
|
function patchComment(n1, n2, renderer) {
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3987
|
+
n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3988
|
+
// it is the case today.
|
|
3989
|
+
|
|
3990
|
+
if (n2.text !== n1.text) {
|
|
3991
|
+
updateTextContent(n2, renderer);
|
|
3992
|
+
}
|
|
3902
3993
|
}
|
|
3994
|
+
|
|
3903
3995
|
function mountComment(vnode, parent, anchor, renderer) {
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3996
|
+
const {
|
|
3997
|
+
owner
|
|
3998
|
+
} = vnode;
|
|
3999
|
+
const {
|
|
4000
|
+
createComment
|
|
4001
|
+
} = renderer;
|
|
4002
|
+
const commentNode = vnode.elm = createComment(vnode.text);
|
|
4003
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
4004
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
3909
4005
|
}
|
|
4006
|
+
|
|
3910
4007
|
function mountElement(vnode, parent, anchor, renderer) {
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
4008
|
+
const {
|
|
4009
|
+
sel,
|
|
4010
|
+
owner,
|
|
4011
|
+
data: {
|
|
4012
|
+
svg
|
|
4013
|
+
}
|
|
4014
|
+
} = vnode;
|
|
4015
|
+
const {
|
|
4016
|
+
createElement
|
|
4017
|
+
} = renderer;
|
|
4018
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
4019
|
+
const elm = vnode.elm = createElement(sel, namespace);
|
|
4020
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
4021
|
+
applyStyleScoping(elm, owner, renderer);
|
|
4022
|
+
applyDomManual(elm, vnode);
|
|
4023
|
+
applyElementRestrictions(elm, vnode);
|
|
4024
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
4025
|
+
insertNode(elm, parent, anchor, renderer);
|
|
4026
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3922
4027
|
}
|
|
4028
|
+
|
|
3923
4029
|
function patchElement(n1, n2, renderer) {
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
4030
|
+
const elm = n2.elm = n1.elm;
|
|
4031
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
4032
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3927
4033
|
}
|
|
4034
|
+
|
|
3928
4035
|
function mountStatic(vnode, parent, anchor, renderer) {
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
4036
|
+
const {
|
|
4037
|
+
owner
|
|
4038
|
+
} = vnode;
|
|
4039
|
+
const {
|
|
4040
|
+
cloneNode,
|
|
4041
|
+
isSyntheticShadowDefined
|
|
4042
|
+
} = renderer;
|
|
4043
|
+
const elm = vnode.elm = cloneNode(vnode.fragment, true);
|
|
4044
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
4045
|
+
applyElementRestrictions(elm, vnode); // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
4046
|
+
|
|
4047
|
+
const {
|
|
4048
|
+
renderMode,
|
|
4049
|
+
shadowMode
|
|
4050
|
+
} = owner;
|
|
4051
|
+
|
|
4052
|
+
if (isSyntheticShadowDefined) {
|
|
4053
|
+
if (shadowMode === 1
|
|
4054
|
+
/* ShadowMode.Synthetic */
|
|
4055
|
+
|| renderMode === 0
|
|
4056
|
+
/* RenderMode.Light */
|
|
4057
|
+
) {
|
|
4058
|
+
elm[KEY__SHADOW_STATIC] = true;
|
|
3940
4059
|
}
|
|
3941
|
-
|
|
4060
|
+
}
|
|
4061
|
+
|
|
4062
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3942
4063
|
}
|
|
4064
|
+
|
|
3943
4065
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
4066
|
+
const {
|
|
4067
|
+
sel,
|
|
4068
|
+
owner
|
|
4069
|
+
} = vnode;
|
|
4070
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
4071
|
+
/**
|
|
4072
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4073
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
4074
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
4075
|
+
* an upgradable custom element.
|
|
4076
|
+
*/
|
|
4077
|
+
|
|
4078
|
+
let vm;
|
|
4079
|
+
const elm = new UpgradableConstructor(elm => {
|
|
4080
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
4081
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
4082
|
+
});
|
|
4083
|
+
vnode.elm = elm;
|
|
4084
|
+
vnode.vm = vm;
|
|
4085
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
4086
|
+
applyStyleScoping(elm, owner, renderer);
|
|
4087
|
+
|
|
4088
|
+
if (vm) {
|
|
4089
|
+
allocateChildren(vnode, vm);
|
|
4090
|
+
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
4091
|
+
throw new TypeError(`Incorrect Component Constructor`);
|
|
4092
|
+
}
|
|
4093
|
+
|
|
4094
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
4095
|
+
insertNode(elm, parent, anchor, renderer);
|
|
4096
|
+
|
|
4097
|
+
if (vm) {
|
|
4098
|
+
{
|
|
4099
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3970
4100
|
if (process.env.NODE_ENV !== 'production') {
|
|
3971
|
-
|
|
4101
|
+
// With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
|
|
4102
|
+
// noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
|
|
4103
|
+
assert.isTrue(vm.state === 0
|
|
4104
|
+
/* VMState.created */
|
|
4105
|
+
, `${vm} cannot be recycled.`);
|
|
3972
4106
|
}
|
|
4107
|
+
|
|
3973
4108
|
runConnectedCallback(vm);
|
|
4109
|
+
}
|
|
3974
4110
|
}
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
4111
|
+
}
|
|
4112
|
+
|
|
4113
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
4114
|
+
|
|
4115
|
+
if (vm) {
|
|
4116
|
+
appendVM(vm);
|
|
4117
|
+
}
|
|
3979
4118
|
}
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
4119
|
+
|
|
4120
|
+
function patchCustomElement(n1, n2, parent, renderer) {
|
|
4121
|
+
if (n1.ctor !== n2.ctor) {
|
|
4122
|
+
// If the constructor, unmount the current component and mount a new one using the new
|
|
4123
|
+
// constructor.
|
|
4124
|
+
const anchor = renderer.nextSibling(n1.elm);
|
|
4125
|
+
unmount(n1, parent, renderer, true);
|
|
4126
|
+
mountCustomElement(n2, parent, anchor, renderer);
|
|
4127
|
+
} else {
|
|
4128
|
+
// Otherwise patch the existing component with new props/attrs/etc.
|
|
4129
|
+
const elm = n2.elm = n1.elm;
|
|
4130
|
+
const vm = n2.vm = n1.vm;
|
|
3983
4131
|
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
4132
|
+
|
|
3984
4133
|
if (!isUndefined$1(vm)) {
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
}
|
|
3989
|
-
// in fallback mode, the children will be always empty, so, nothing
|
|
4134
|
+
// in fallback mode, the allocation will always set children to
|
|
4135
|
+
// empty and delegate the real allocation to the slot elements
|
|
4136
|
+
allocateChildren(n2, vm);
|
|
4137
|
+
} // in fallback mode, the children will be always empty, so, nothing
|
|
3990
4138
|
// will happen, but in native, it does allocate the light dom
|
|
4139
|
+
|
|
4140
|
+
|
|
3991
4141
|
patchChildren(n1.children, n2.children, elm, renderer);
|
|
4142
|
+
|
|
3992
4143
|
if (!isUndefined$1(vm)) {
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
4144
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
4145
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
4146
|
+
rerenderVM(vm);
|
|
3996
4147
|
}
|
|
4148
|
+
}
|
|
3997
4149
|
}
|
|
4150
|
+
|
|
3998
4151
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4152
|
+
for (; start < end; ++start) {
|
|
4153
|
+
const vnode = vnodes[start];
|
|
4154
|
+
|
|
4155
|
+
if (isVNode(vnode)) {
|
|
4156
|
+
mount(vnode, parent, renderer, anchor);
|
|
4004
4157
|
}
|
|
4158
|
+
}
|
|
4005
4159
|
}
|
|
4160
|
+
|
|
4006
4161
|
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4162
|
+
const {
|
|
4163
|
+
type,
|
|
4164
|
+
elm,
|
|
4165
|
+
sel
|
|
4166
|
+
} = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
4167
|
+
// subtree root, is the only element worth unmounting from the subtree.
|
|
4168
|
+
|
|
4169
|
+
if (doRemove) {
|
|
4170
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
4171
|
+
// but the removal used here is from the owner instead.
|
|
4172
|
+
removeNode(elm, parent, renderer);
|
|
4173
|
+
}
|
|
4174
|
+
|
|
4175
|
+
switch (type) {
|
|
4176
|
+
case 2
|
|
4177
|
+
/* VNodeType.Element */
|
|
4178
|
+
:
|
|
4179
|
+
{
|
|
4180
|
+
// Slot content is removed to trigger slotchange event when removing slot.
|
|
4181
|
+
// Only required for synthetic shadow.
|
|
4182
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
|
|
4183
|
+
/* ShadowMode.Synthetic */
|
|
4184
|
+
;
|
|
4185
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
4186
|
+
break;
|
|
4187
|
+
}
|
|
4188
|
+
|
|
4189
|
+
case 3
|
|
4190
|
+
/* VNodeType.CustomElement */
|
|
4191
|
+
:
|
|
4192
|
+
{
|
|
4193
|
+
const {
|
|
4194
|
+
vm
|
|
4195
|
+
} = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
|
|
4196
|
+
// children.
|
|
4197
|
+
|
|
4198
|
+
if (!isUndefined$1(vm)) {
|
|
4199
|
+
removeVM(vm);
|
|
4030
4200
|
}
|
|
4031
|
-
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4032
4203
|
}
|
|
4204
|
+
|
|
4033
4205
|
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4206
|
+
for (; start < end; ++start) {
|
|
4207
|
+
const ch = vnodes[start];
|
|
4208
|
+
|
|
4209
|
+
if (isVNode(ch)) {
|
|
4210
|
+
unmount(ch, parent, renderer, doRemove);
|
|
4039
4211
|
}
|
|
4212
|
+
}
|
|
4040
4213
|
}
|
|
4214
|
+
|
|
4041
4215
|
function isVNode(vnode) {
|
|
4042
|
-
|
|
4216
|
+
return vnode != null;
|
|
4043
4217
|
}
|
|
4218
|
+
|
|
4044
4219
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4220
|
+
const {
|
|
4221
|
+
renderRoot,
|
|
4222
|
+
renderMode,
|
|
4223
|
+
shadowMode
|
|
4224
|
+
} = owner;
|
|
4225
|
+
const {
|
|
4226
|
+
isSyntheticShadowDefined
|
|
4227
|
+
} = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
|
|
4228
|
+
|
|
4229
|
+
if (isSyntheticShadowDefined) {
|
|
4230
|
+
if (shadowMode === 1
|
|
4231
|
+
/* ShadowMode.Synthetic */
|
|
4232
|
+
|| renderMode === 0
|
|
4233
|
+
/* RenderMode.Light */
|
|
4234
|
+
) {
|
|
4235
|
+
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
4052
4236
|
}
|
|
4237
|
+
}
|
|
4053
4238
|
}
|
|
4239
|
+
|
|
4054
4240
|
function updateTextContent(vnode, renderer) {
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
setText
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4241
|
+
const {
|
|
4242
|
+
elm,
|
|
4243
|
+
text
|
|
4244
|
+
} = vnode;
|
|
4245
|
+
const {
|
|
4246
|
+
setText
|
|
4247
|
+
} = renderer;
|
|
4248
|
+
|
|
4249
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4250
|
+
unlockDomMutation();
|
|
4251
|
+
}
|
|
4252
|
+
|
|
4253
|
+
setText(elm, text);
|
|
4254
|
+
|
|
4255
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4256
|
+
lockDomMutation();
|
|
4257
|
+
}
|
|
4064
4258
|
}
|
|
4259
|
+
|
|
4065
4260
|
function insertNode(node, parent, anchor, renderer) {
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4261
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4262
|
+
unlockDomMutation();
|
|
4263
|
+
}
|
|
4264
|
+
|
|
4265
|
+
renderer.insert(node, parent, anchor);
|
|
4266
|
+
|
|
4267
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4268
|
+
lockDomMutation();
|
|
4269
|
+
}
|
|
4073
4270
|
}
|
|
4271
|
+
|
|
4074
4272
|
function removeNode(node, parent, renderer) {
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4273
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4274
|
+
unlockDomMutation();
|
|
4275
|
+
}
|
|
4276
|
+
|
|
4277
|
+
renderer.remove(node, parent);
|
|
4278
|
+
|
|
4279
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4280
|
+
lockDomMutation();
|
|
4281
|
+
}
|
|
4082
4282
|
}
|
|
4283
|
+
|
|
4083
4284
|
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4285
|
+
if (isNull(oldVnode)) {
|
|
4286
|
+
applyEventListeners(vnode, renderer);
|
|
4287
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
4288
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
4289
|
+
} // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
4290
|
+
// value is set before type=radio.
|
|
4291
|
+
|
|
4292
|
+
|
|
4293
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
4294
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
4295
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
4296
|
+
patchProps(oldVnode, vnode, renderer);
|
|
4095
4297
|
}
|
|
4298
|
+
|
|
4096
4299
|
function applyStyleScoping(elm, owner, renderer) {
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4300
|
+
// Set the class name for `*.scoped.css` style scoping.
|
|
4301
|
+
const scopeToken = getScopeTokenClass(owner);
|
|
4302
|
+
|
|
4303
|
+
if (!isNull(scopeToken)) {
|
|
4304
|
+
const {
|
|
4305
|
+
getClassList
|
|
4306
|
+
} = renderer; // TODO [#2762]: this dot notation with add is probably problematic
|
|
4307
|
+
// probably we should have a renderer api for just the add operation
|
|
4308
|
+
|
|
4309
|
+
getClassList(elm).add(scopeToken);
|
|
4310
|
+
} // Set property element for synthetic shadow DOM style scoping.
|
|
4311
|
+
|
|
4312
|
+
|
|
4313
|
+
const {
|
|
4314
|
+
stylesheetToken: syntheticToken
|
|
4315
|
+
} = owner.context;
|
|
4316
|
+
|
|
4317
|
+
if (owner.shadowMode === 1
|
|
4318
|
+
/* ShadowMode.Synthetic */
|
|
4319
|
+
&& !isUndefined$1(syntheticToken)) {
|
|
4320
|
+
elm.$shadowToken$ = syntheticToken;
|
|
4321
|
+
}
|
|
4322
|
+
}
|
|
4323
|
+
|
|
4324
|
+
function applyDomManual(elm, vnode) {
|
|
4325
|
+
var _a;
|
|
4326
|
+
|
|
4327
|
+
const {
|
|
4328
|
+
owner,
|
|
4329
|
+
data: {
|
|
4330
|
+
context
|
|
4127
4331
|
}
|
|
4332
|
+
} = vnode;
|
|
4333
|
+
|
|
4334
|
+
if (owner.shadowMode === 1
|
|
4335
|
+
/* ShadowMode.Synthetic */
|
|
4336
|
+
&& ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
|
|
4337
|
+
/* LwcDomMode.Manual */
|
|
4338
|
+
) {
|
|
4339
|
+
elm.$domManual$ = true;
|
|
4340
|
+
}
|
|
4128
4341
|
}
|
|
4342
|
+
|
|
4343
|
+
function applyElementRestrictions(elm, vnode) {
|
|
4344
|
+
var _a, _b;
|
|
4345
|
+
|
|
4346
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4347
|
+
const isPortal = vnode.type === 2
|
|
4348
|
+
/* VNodeType.Element */
|
|
4349
|
+
&& ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
|
|
4350
|
+
/* LwcDomMode.Manual */
|
|
4351
|
+
;
|
|
4352
|
+
const isLight = vnode.owner.renderMode === 0
|
|
4353
|
+
/* RenderMode.Light */
|
|
4354
|
+
;
|
|
4355
|
+
patchElementWithRestrictions(elm, {
|
|
4356
|
+
isPortal,
|
|
4357
|
+
isLight
|
|
4358
|
+
});
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
|
|
4129
4362
|
function allocateChildren(vnode, vm) {
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4363
|
+
// A component with slots will re-render because:
|
|
4364
|
+
// 1- There is a change of the internal state.
|
|
4365
|
+
// 2- There is a change on the external api (ex: slots)
|
|
4366
|
+
//
|
|
4367
|
+
// In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
|
|
4368
|
+
// slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
|
|
4369
|
+
// in a reused VCustomElement, there won't be any slotted children.
|
|
4370
|
+
// For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
|
|
4371
|
+
//
|
|
4372
|
+
// In case #2, we will always get a fresh VCustomElement.
|
|
4373
|
+
const children = vnode.aChildren || vnode.children;
|
|
4374
|
+
vm.aChildren = children;
|
|
4375
|
+
const {
|
|
4376
|
+
renderMode,
|
|
4377
|
+
shadowMode
|
|
4378
|
+
} = vm;
|
|
4379
|
+
|
|
4380
|
+
if (shadowMode === 1
|
|
4381
|
+
/* ShadowMode.Synthetic */
|
|
4382
|
+
|| renderMode === 0
|
|
4383
|
+
/* RenderMode.Light */
|
|
4384
|
+
) {
|
|
4385
|
+
// slow path
|
|
4386
|
+
allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
|
|
4387
|
+
|
|
4388
|
+
vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4389
|
+
|
|
4390
|
+
vnode.children = EmptyArray;
|
|
4391
|
+
}
|
|
4151
4392
|
}
|
|
4393
|
+
|
|
4152
4394
|
function createViewModelHook(elm, vnode, renderer) {
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
return vm;
|
|
4159
|
-
}
|
|
4160
|
-
const { sel, mode, ctor, owner } = vnode;
|
|
4161
|
-
vm = createVM(elm, ctor, renderer, {
|
|
4162
|
-
mode,
|
|
4163
|
-
owner,
|
|
4164
|
-
tagName: sel,
|
|
4165
|
-
});
|
|
4166
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4167
|
-
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4168
|
-
}
|
|
4395
|
+
let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
|
|
4396
|
+
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
4397
|
+
// called right after invoking `document.createElement`.
|
|
4398
|
+
|
|
4399
|
+
if (!isUndefined$1(vm)) {
|
|
4169
4400
|
return vm;
|
|
4401
|
+
}
|
|
4402
|
+
|
|
4403
|
+
const {
|
|
4404
|
+
sel,
|
|
4405
|
+
mode,
|
|
4406
|
+
ctor,
|
|
4407
|
+
owner
|
|
4408
|
+
} = vnode;
|
|
4409
|
+
vm = createVM(elm, ctor, renderer, {
|
|
4410
|
+
mode,
|
|
4411
|
+
owner,
|
|
4412
|
+
tagName: sel
|
|
4413
|
+
});
|
|
4414
|
+
|
|
4415
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4416
|
+
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4417
|
+
}
|
|
4418
|
+
|
|
4419
|
+
return vm;
|
|
4170
4420
|
}
|
|
4421
|
+
|
|
4171
4422
|
function allocateInSlot(vm, children) {
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
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
|
-
|
|
4423
|
+
var _a;
|
|
4424
|
+
|
|
4425
|
+
const {
|
|
4426
|
+
cmpSlots: oldSlots
|
|
4427
|
+
} = vm;
|
|
4428
|
+
const cmpSlots = vm.cmpSlots = create(null);
|
|
4429
|
+
|
|
4430
|
+
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4431
|
+
const vnode = children[i];
|
|
4432
|
+
|
|
4433
|
+
if (isNull(vnode)) {
|
|
4434
|
+
continue;
|
|
4435
|
+
}
|
|
4436
|
+
|
|
4437
|
+
let slotName = '';
|
|
4438
|
+
|
|
4439
|
+
if (isVBaseElement(vnode)) {
|
|
4440
|
+
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
|
|
4441
|
+
}
|
|
4442
|
+
|
|
4443
|
+
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
|
|
4444
|
+
ArrayPush$1.call(vnodes, vnode);
|
|
4445
|
+
}
|
|
4446
|
+
|
|
4447
|
+
if (isFalse(vm.isDirty)) {
|
|
4448
|
+
// We need to determine if the old allocation is really different from the new one
|
|
4449
|
+
// and mark the vm as dirty
|
|
4450
|
+
const oldKeys = keys(oldSlots);
|
|
4451
|
+
|
|
4452
|
+
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
4453
|
+
markComponentAsDirty(vm);
|
|
4454
|
+
return;
|
|
4455
|
+
}
|
|
4456
|
+
|
|
4457
|
+
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4458
|
+
const key = oldKeys[i];
|
|
4459
|
+
|
|
4460
|
+
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
4461
|
+
markComponentAsDirty(vm);
|
|
4462
|
+
return;
|
|
4463
|
+
}
|
|
4464
|
+
|
|
4465
|
+
const oldVNodes = oldSlots[key];
|
|
4466
|
+
const vnodes = cmpSlots[key];
|
|
4467
|
+
|
|
4468
|
+
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
4469
|
+
if (oldVNodes[j] !== vnodes[j]) {
|
|
4470
|
+
markComponentAsDirty(vm);
|
|
4471
|
+
return;
|
|
4209
4472
|
}
|
|
4473
|
+
}
|
|
4210
4474
|
}
|
|
4211
|
-
}
|
|
4212
|
-
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4213
|
-
|
|
4214
|
-
|
|
4475
|
+
}
|
|
4476
|
+
} // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4477
|
+
|
|
4478
|
+
|
|
4479
|
+
const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
|
|
4215
4480
|
// in a template, and will require a more complex diffing algo.
|
|
4481
|
+
|
|
4216
4482
|
function markAsDynamicChildren(children) {
|
|
4217
|
-
|
|
4483
|
+
FromIteration.set(children, 1);
|
|
4218
4484
|
}
|
|
4485
|
+
|
|
4219
4486
|
function hasDynamicChildren(children) {
|
|
4220
|
-
|
|
4487
|
+
return FromIteration.has(children);
|
|
4221
4488
|
}
|
|
4489
|
+
|
|
4222
4490
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4491
|
+
const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
4492
|
+
|
|
4493
|
+
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
4494
|
+
const ch = children[j];
|
|
4495
|
+
|
|
4496
|
+
if (isVNode(ch)) {
|
|
4497
|
+
const {
|
|
4498
|
+
key
|
|
4499
|
+
} = ch;
|
|
4500
|
+
|
|
4501
|
+
if (key !== undefined) {
|
|
4502
|
+
map[key] = j;
|
|
4503
|
+
}
|
|
4233
4504
|
}
|
|
4234
|
-
|
|
4505
|
+
}
|
|
4506
|
+
|
|
4507
|
+
return map;
|
|
4235
4508
|
}
|
|
4509
|
+
|
|
4236
4510
|
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
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
|
-
// We've already cloned at least once, so it's no longer read-only
|
|
4317
|
-
oldCh[idxInOld] = undefined;
|
|
4318
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4319
|
-
}
|
|
4320
|
-
}
|
|
4321
|
-
newStartVnode = newCh[++newStartIdx];
|
|
4322
|
-
}
|
|
4511
|
+
let oldStartIdx = 0;
|
|
4512
|
+
let newStartIdx = 0;
|
|
4513
|
+
let oldEndIdx = oldCh.length - 1;
|
|
4514
|
+
let oldStartVnode = oldCh[0];
|
|
4515
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
4516
|
+
const newChEnd = newCh.length - 1;
|
|
4517
|
+
let newEndIdx = newChEnd;
|
|
4518
|
+
let newStartVnode = newCh[0];
|
|
4519
|
+
let newEndVnode = newCh[newEndIdx];
|
|
4520
|
+
let oldKeyToIdx;
|
|
4521
|
+
let idxInOld;
|
|
4522
|
+
let elmToMove;
|
|
4523
|
+
let before;
|
|
4524
|
+
let clonedOldCh = false;
|
|
4525
|
+
|
|
4526
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
4527
|
+
if (!isVNode(oldStartVnode)) {
|
|
4528
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
4529
|
+
} else if (!isVNode(oldEndVnode)) {
|
|
4530
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4531
|
+
} else if (!isVNode(newStartVnode)) {
|
|
4532
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4533
|
+
} else if (!isVNode(newEndVnode)) {
|
|
4534
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4535
|
+
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
4536
|
+
patch(oldStartVnode, newStartVnode, parent, renderer);
|
|
4537
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4538
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4539
|
+
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
4540
|
+
patch(oldEndVnode, newEndVnode, parent, renderer);
|
|
4541
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4542
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4543
|
+
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
4544
|
+
// Vnode moved right
|
|
4545
|
+
patch(oldStartVnode, newEndVnode, parent, renderer);
|
|
4546
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
4547
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4548
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4549
|
+
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
4550
|
+
// Vnode moved left
|
|
4551
|
+
patch(oldEndVnode, newStartVnode, parent, renderer);
|
|
4552
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
4553
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4554
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4555
|
+
} else {
|
|
4556
|
+
if (oldKeyToIdx === undefined) {
|
|
4557
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
4558
|
+
}
|
|
4559
|
+
|
|
4560
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
4561
|
+
|
|
4562
|
+
if (isUndefined$1(idxInOld)) {
|
|
4563
|
+
// New element
|
|
4564
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4565
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4566
|
+
} else {
|
|
4567
|
+
elmToMove = oldCh[idxInOld];
|
|
4568
|
+
|
|
4569
|
+
if (isVNode(elmToMove)) {
|
|
4570
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4571
|
+
// New element
|
|
4572
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4573
|
+
} else {
|
|
4574
|
+
patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
|
|
4575
|
+
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4576
|
+
// so we only care about the `oldCh` object inside this function.
|
|
4577
|
+
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4578
|
+
// and only clone once.
|
|
4579
|
+
|
|
4580
|
+
if (!clonedOldCh) {
|
|
4581
|
+
clonedOldCh = true;
|
|
4582
|
+
oldCh = [...oldCh];
|
|
4583
|
+
} // We've already cloned at least once, so it's no longer read-only
|
|
4584
|
+
|
|
4585
|
+
|
|
4586
|
+
oldCh[idxInOld] = undefined;
|
|
4587
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4588
|
+
}
|
|
4323
4589
|
}
|
|
4590
|
+
|
|
4591
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4592
|
+
}
|
|
4324
4593
|
}
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4594
|
+
}
|
|
4595
|
+
|
|
4596
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
4597
|
+
if (oldStartIdx > oldEndIdx) {
|
|
4598
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
4599
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
4600
|
+
let i = newEndIdx;
|
|
4601
|
+
let n;
|
|
4602
|
+
|
|
4603
|
+
do {
|
|
4604
|
+
n = newCh[++i];
|
|
4605
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
4606
|
+
|
|
4607
|
+
before = isVNode(n) ? n.elm : null;
|
|
4608
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
4609
|
+
} else {
|
|
4610
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
4340
4611
|
}
|
|
4612
|
+
}
|
|
4341
4613
|
}
|
|
4614
|
+
|
|
4342
4615
|
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
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
|
-
anchor = n2.elm;
|
|
4377
|
-
}
|
|
4616
|
+
const c1Length = c1.length;
|
|
4617
|
+
const c2Length = c2.length;
|
|
4618
|
+
|
|
4619
|
+
if (c1Length === 0) {
|
|
4620
|
+
// the old list is empty, we can directly insert anything new
|
|
4621
|
+
mountVNodes(c2, parent, renderer, null);
|
|
4622
|
+
return;
|
|
4623
|
+
}
|
|
4624
|
+
|
|
4625
|
+
if (c2Length === 0) {
|
|
4626
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4627
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4628
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
4629
|
+
return;
|
|
4630
|
+
} // if the old list is not empty, the new list MUST have the same
|
|
4631
|
+
// amount of nodes, that's why we call this static children
|
|
4632
|
+
|
|
4633
|
+
|
|
4634
|
+
let anchor = null;
|
|
4635
|
+
|
|
4636
|
+
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
4637
|
+
const n1 = c1[i];
|
|
4638
|
+
const n2 = c2[i];
|
|
4639
|
+
|
|
4640
|
+
if (n2 !== n1) {
|
|
4641
|
+
if (isVNode(n1)) {
|
|
4642
|
+
if (isVNode(n2)) {
|
|
4643
|
+
// both vnodes are equivalent, and we just need to patch them
|
|
4644
|
+
patch(n1, n2, parent, renderer);
|
|
4645
|
+
anchor = n2.elm;
|
|
4646
|
+
} else {
|
|
4647
|
+
// removing the old vnode since the new one is null
|
|
4648
|
+
unmount(n1, parent, renderer, true);
|
|
4378
4649
|
}
|
|
4650
|
+
} else if (isVNode(n2)) {
|
|
4651
|
+
mount(n2, parent, renderer, anchor);
|
|
4652
|
+
anchor = n2.elm;
|
|
4653
|
+
}
|
|
4379
4654
|
}
|
|
4655
|
+
}
|
|
4380
4656
|
}
|
|
4381
4657
|
|
|
4382
4658
|
/*
|
|
@@ -4697,13 +4973,6 @@ function fid(url) {
|
|
|
4697
4973
|
}
|
|
4698
4974
|
return url;
|
|
4699
4975
|
}
|
|
4700
|
-
/**
|
|
4701
|
-
* Map to store an index value assigned to any dynamic component reference ingested
|
|
4702
|
-
* by dc() api. This allows us to generate a unique unique per template per dynamic
|
|
4703
|
-
* component reference to avoid diffing algo mismatches.
|
|
4704
|
-
*/
|
|
4705
|
-
const DynamicImportedComponentMap = new Map();
|
|
4706
|
-
let dynamicImportedComponentCounter = 0;
|
|
4707
4976
|
/**
|
|
4708
4977
|
* create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
4709
4978
|
*/
|
|
@@ -4720,18 +4989,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
|
|
|
4720
4989
|
if (!isComponentConstructor(Ctor)) {
|
|
4721
4990
|
throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
|
|
4722
4991
|
}
|
|
4723
|
-
|
|
4724
|
-
if (isUndefined$1(idx)) {
|
|
4725
|
-
idx = dynamicImportedComponentCounter++;
|
|
4726
|
-
DynamicImportedComponentMap.set(Ctor, idx);
|
|
4727
|
-
}
|
|
4728
|
-
// the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
|
|
4729
|
-
// to identify different constructors as vnodes with different keys to avoid reusing the
|
|
4730
|
-
// element used for previous constructors.
|
|
4731
|
-
// Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
|
|
4732
|
-
// hoisting optimization.
|
|
4733
|
-
const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
|
|
4734
|
-
return c(sel, Ctor, newData, children);
|
|
4992
|
+
return c(sel, Ctor, data, children);
|
|
4735
4993
|
}
|
|
4736
4994
|
/**
|
|
4737
4995
|
* slow children collection marking mechanism. this API allows the compiler to signal
|
|
@@ -5457,7 +5715,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5457
5715
|
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
5458
5716
|
};
|
|
5459
5717
|
|
|
5460
|
-
if (
|
|
5718
|
+
if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5461
5719
|
vm.shadowMode = 0
|
|
5462
5720
|
/* ShadowMode.Native */
|
|
5463
5721
|
;
|
|
@@ -5496,7 +5754,7 @@ function computeShadowMode(vm, renderer) {
|
|
|
5496
5754
|
} else if (isNativeShadowDefined) {
|
|
5497
5755
|
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
5498
5756
|
// the if-condition.
|
|
5499
|
-
if (
|
|
5757
|
+
if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
5500
5758
|
if (def.shadowSupportMode === "any"
|
|
5501
5759
|
/* ShadowSupportMode.Any */
|
|
5502
5760
|
) {
|
|
@@ -5625,16 +5883,9 @@ function runRenderedCallback(vm) {
|
|
|
5625
5883
|
const {
|
|
5626
5884
|
def: {
|
|
5627
5885
|
renderedCallback
|
|
5628
|
-
},
|
|
5629
|
-
renderer: {
|
|
5630
|
-
ssr
|
|
5631
5886
|
}
|
|
5632
5887
|
} = vm;
|
|
5633
5888
|
|
|
5634
|
-
if (isTrue(ssr)) {
|
|
5635
|
-
return;
|
|
5636
|
-
}
|
|
5637
|
-
|
|
5638
5889
|
const {
|
|
5639
5890
|
rendered
|
|
5640
5891
|
} = Services;
|
|
@@ -5884,13 +6135,7 @@ function resetComponentRoot(vm) {
|
|
|
5884
6135
|
vm.velements = EmptyArray;
|
|
5885
6136
|
}
|
|
5886
6137
|
function scheduleRehydration(vm) {
|
|
5887
|
-
|
|
5888
|
-
renderer: {
|
|
5889
|
-
ssr
|
|
5890
|
-
}
|
|
5891
|
-
} = vm;
|
|
5892
|
-
|
|
5893
|
-
if (isTrue(ssr) || isTrue(vm.isScheduled)) {
|
|
6138
|
+
if (isTrue(vm.isScheduled)) {
|
|
5894
6139
|
return;
|
|
5895
6140
|
}
|
|
5896
6141
|
|
|
@@ -5997,15 +6242,8 @@ class WireContextRegistrationEvent extends CustomEvent {
|
|
|
5997
6242
|
}
|
|
5998
6243
|
|
|
5999
6244
|
function createFieldDataCallback(vm, name) {
|
|
6000
|
-
const {
|
|
6001
|
-
cmpFields
|
|
6002
|
-
} = vm;
|
|
6003
6245
|
return value => {
|
|
6004
|
-
|
|
6005
|
-
// storing the value in the underlying storage
|
|
6006
|
-
cmpFields[name] = value;
|
|
6007
|
-
componentValueMutated(vm, name);
|
|
6008
|
-
}
|
|
6246
|
+
updateComponentValue(vm, name, value);
|
|
6009
6247
|
};
|
|
6010
6248
|
}
|
|
6011
6249
|
|
|
@@ -6223,7 +6461,7 @@ function installWireAdapters(vm) {
|
|
|
6223
6461
|
ArrayPush$1.call(wiredConnecting, () => {
|
|
6224
6462
|
connector.connect();
|
|
6225
6463
|
|
|
6226
|
-
if (!
|
|
6464
|
+
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
6227
6465
|
if (hasDynamicParams) {
|
|
6228
6466
|
Promise.resolve().then(computeConfigAndUpdate);
|
|
6229
6467
|
return;
|
|
@@ -6369,6 +6607,7 @@ function hydrateNode(node, vnode, renderer) {
|
|
|
6369
6607
|
}
|
|
6370
6608
|
return renderer.nextSibling(hydratedNode);
|
|
6371
6609
|
}
|
|
6610
|
+
const NODE_VALUE_PROP = 'nodeValue';
|
|
6372
6611
|
function hydrateText(node, vnode, renderer) {
|
|
6373
6612
|
var _a;
|
|
6374
6613
|
if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
@@ -6376,7 +6615,7 @@ function hydrateText(node, vnode, renderer) {
|
|
|
6376
6615
|
}
|
|
6377
6616
|
if (process.env.NODE_ENV !== 'production') {
|
|
6378
6617
|
const { getProperty } = renderer;
|
|
6379
|
-
const nodeValue = getProperty(node,
|
|
6618
|
+
const nodeValue = getProperty(node, NODE_VALUE_PROP);
|
|
6380
6619
|
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
6381
6620
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
6382
6621
|
}
|
|
@@ -6393,13 +6632,13 @@ function hydrateComment(node, vnode, renderer) {
|
|
|
6393
6632
|
}
|
|
6394
6633
|
if (process.env.NODE_ENV !== 'production') {
|
|
6395
6634
|
const { getProperty } = renderer;
|
|
6396
|
-
const nodeValue = getProperty(node,
|
|
6635
|
+
const nodeValue = getProperty(node, NODE_VALUE_PROP);
|
|
6397
6636
|
if (nodeValue !== vnode.text) {
|
|
6398
6637
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
6399
6638
|
}
|
|
6400
6639
|
}
|
|
6401
6640
|
const { setProperty } = renderer;
|
|
6402
|
-
setProperty(node,
|
|
6641
|
+
setProperty(node, NODE_VALUE_PROP, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
6403
6642
|
vnode.elm = node;
|
|
6404
6643
|
return node;
|
|
6405
6644
|
}
|
|
@@ -6667,13 +6906,13 @@ function areCompatibleNodes(client, ssr, vnode, renderer) {
|
|
|
6667
6906
|
if (!hasCorrectNodeType(vnode, ssr, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
6668
6907
|
return false;
|
|
6669
6908
|
}
|
|
6670
|
-
return getProperty(client,
|
|
6909
|
+
return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
|
|
6671
6910
|
}
|
|
6672
6911
|
if (getProperty(client, 'nodeType') === 8 /* EnvNodeTypes.COMMENT */) {
|
|
6673
6912
|
if (!hasCorrectNodeType(vnode, ssr, 8 /* EnvNodeTypes.COMMENT */, 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 (!hasCorrectNodeType(vnode, ssr, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
|
|
6679
6918
|
return false;
|
|
@@ -6829,7 +7068,7 @@ function getComponentConstructor(elm) {
|
|
|
6829
7068
|
}
|
|
6830
7069
|
return ctor;
|
|
6831
7070
|
}
|
|
6832
|
-
/* version: 2.
|
|
7071
|
+
/* version: 2.23.2 */
|
|
6833
7072
|
|
|
6834
7073
|
/*
|
|
6835
7074
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6979,61 +7218,303 @@ function insertStylesheet(content, target) {
|
|
|
6979
7218
|
* SPDX-License-Identifier: MIT
|
|
6980
7219
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6981
7220
|
*/
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
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
|
-
html = `<${wrapperTag}>${html}</${wrapperTag}>`;
|
|
7221
|
+
/**
|
|
7222
|
+
* A factory function that produces a renderer.
|
|
7223
|
+
* Renderer encapsulates operations that are required to render an LWC component into the underlying
|
|
7224
|
+
* runtime environment. In the case of @lwc/enigne-dom, it is meant to be used in a DOM environment.
|
|
7225
|
+
* Example usage:
|
|
7226
|
+
* import { renderer, rendererFactory } from 'lwc';
|
|
7227
|
+
* const customRenderer = rendererFactory(renderer);
|
|
7228
|
+
*
|
|
7229
|
+
* @param baseRenderer Either null or the base renderer imported from 'lwc'.
|
|
7230
|
+
*/
|
|
7231
|
+
function rendererFactory(baseRenderer) {
|
|
7232
|
+
// Util functions
|
|
7233
|
+
function assertInvariant(value, msg) {
|
|
7234
|
+
if (!value) {
|
|
7235
|
+
throw new Error(`Invariant Violation: ${msg}`);
|
|
7236
|
+
}
|
|
7237
|
+
}
|
|
7238
|
+
function isNull(obj) {
|
|
7239
|
+
return obj === null;
|
|
7240
|
+
}
|
|
7241
|
+
function isUndefined(obj) {
|
|
7242
|
+
return obj === undefined;
|
|
7243
|
+
}
|
|
7244
|
+
let getCustomElement;
|
|
7245
|
+
let defineCustomElement;
|
|
7246
|
+
let HTMLElementConstructor;
|
|
7247
|
+
function isCustomElementRegistryAvailable() {
|
|
7248
|
+
if (typeof customElements === 'undefined') {
|
|
7249
|
+
return false;
|
|
7250
|
+
}
|
|
7251
|
+
try {
|
|
7252
|
+
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
7253
|
+
// _wrapNativeSuper()
|
|
7254
|
+
// This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
|
|
7255
|
+
// get wrapped by babel.
|
|
7256
|
+
const HTMLElementAlias = HTMLElement;
|
|
7257
|
+
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
7258
|
+
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
7259
|
+
// which are not equipped to be initialized that way.
|
|
7260
|
+
class clazz extends HTMLElementAlias {
|
|
7023
7261
|
}
|
|
7262
|
+
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
7263
|
+
new clazz();
|
|
7264
|
+
return true;
|
|
7265
|
+
}
|
|
7266
|
+
catch (_a) {
|
|
7267
|
+
return false;
|
|
7024
7268
|
}
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7269
|
+
}
|
|
7270
|
+
if (isCustomElementRegistryAvailable()) {
|
|
7271
|
+
getCustomElement = customElements.get.bind(customElements);
|
|
7272
|
+
defineCustomElement = customElements.define.bind(customElements);
|
|
7273
|
+
HTMLElementConstructor = HTMLElement;
|
|
7274
|
+
}
|
|
7275
|
+
else {
|
|
7276
|
+
const registry = Object.create(null);
|
|
7277
|
+
const reverseRegistry = new WeakMap();
|
|
7278
|
+
defineCustomElement = function define(name, ctor) {
|
|
7279
|
+
if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
|
|
7280
|
+
throw new TypeError(`Invalid Registration`);
|
|
7281
|
+
}
|
|
7282
|
+
registry[name] = ctor;
|
|
7283
|
+
reverseRegistry.set(ctor, name);
|
|
7284
|
+
};
|
|
7285
|
+
getCustomElement = function get(name) {
|
|
7286
|
+
return registry[name];
|
|
7287
|
+
};
|
|
7288
|
+
HTMLElementConstructor = function HTMLElement() {
|
|
7289
|
+
if (!(this instanceof HTMLElement)) {
|
|
7290
|
+
throw new TypeError(`Invalid Invocation`);
|
|
7291
|
+
}
|
|
7292
|
+
const { constructor } = this;
|
|
7293
|
+
const name = reverseRegistry.get(constructor);
|
|
7294
|
+
if (!name) {
|
|
7295
|
+
throw new TypeError(`Invalid Construction`);
|
|
7296
|
+
}
|
|
7297
|
+
const elm = document.createElement(name);
|
|
7298
|
+
Object.setPrototypeOf(elm, constructor.prototype);
|
|
7299
|
+
return elm;
|
|
7300
|
+
};
|
|
7301
|
+
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
7302
|
+
}
|
|
7303
|
+
function cloneNode(node, deep) {
|
|
7304
|
+
return node.cloneNode(deep);
|
|
7305
|
+
}
|
|
7306
|
+
function createElement(tagName, namespace) {
|
|
7307
|
+
return isUndefined(namespace)
|
|
7308
|
+
? document.createElement(tagName)
|
|
7309
|
+
: document.createElementNS(namespace, tagName);
|
|
7310
|
+
}
|
|
7311
|
+
function createText(content) {
|
|
7312
|
+
return document.createTextNode(content);
|
|
7313
|
+
}
|
|
7314
|
+
function createComment(content) {
|
|
7315
|
+
return document.createComment(content);
|
|
7316
|
+
}
|
|
7317
|
+
let createFragment;
|
|
7318
|
+
// IE11 lacks support for this feature
|
|
7319
|
+
const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
|
|
7320
|
+
if (SUPPORTS_TEMPLATE) {
|
|
7321
|
+
// Parse the fragment HTML string into DOM
|
|
7322
|
+
createFragment = function (html) {
|
|
7323
|
+
const template = document.createElement('template');
|
|
7324
|
+
template.innerHTML = html;
|
|
7325
|
+
return template.content.firstChild;
|
|
7326
|
+
};
|
|
7327
|
+
}
|
|
7328
|
+
else {
|
|
7329
|
+
// In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
|
|
7330
|
+
// <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
|
|
7331
|
+
// Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
|
|
7332
|
+
// With other elements added from:
|
|
7333
|
+
// https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
|
|
7334
|
+
// Using the test:
|
|
7335
|
+
// document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
|
|
7336
|
+
// And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
|
|
7337
|
+
const topLevelWrappingMap = {
|
|
7338
|
+
caption: ['table'],
|
|
7339
|
+
col: ['colgroup', 'table'],
|
|
7340
|
+
colgroup: ['table'],
|
|
7341
|
+
option: ['select'],
|
|
7342
|
+
tbody: ['table'],
|
|
7343
|
+
td: ['tr', 'tbody', 'table'],
|
|
7344
|
+
th: ['tr', 'tbody', 'table'],
|
|
7345
|
+
thead: ['table'],
|
|
7346
|
+
tfoot: ['table'],
|
|
7347
|
+
tr: ['tbody', 'table'],
|
|
7348
|
+
};
|
|
7349
|
+
// Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
|
|
7350
|
+
const getTagName = function (text) {
|
|
7351
|
+
return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
|
|
7352
|
+
};
|
|
7353
|
+
// Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
|
|
7354
|
+
createFragment = function (html) {
|
|
7355
|
+
const wrapperTags = topLevelWrappingMap[getTagName(html)];
|
|
7356
|
+
if (!isUndefined(wrapperTags)) {
|
|
7357
|
+
for (const wrapperTag of wrapperTags) {
|
|
7358
|
+
html = `<${wrapperTag}>${html}</${wrapperTag}>`;
|
|
7359
|
+
}
|
|
7033
7360
|
}
|
|
7361
|
+
// For IE11, the document title must not be undefined, but it can be an empty string
|
|
7362
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
|
|
7363
|
+
const doc = document.implementation.createHTMLDocument('');
|
|
7364
|
+
doc.body.innerHTML = html;
|
|
7365
|
+
let content = doc.body;
|
|
7366
|
+
if (!isUndefined(wrapperTags)) {
|
|
7367
|
+
for (let i = 0; i < wrapperTags.length; i++) {
|
|
7368
|
+
content = content.firstChild;
|
|
7369
|
+
}
|
|
7370
|
+
}
|
|
7371
|
+
return content.firstChild;
|
|
7372
|
+
};
|
|
7373
|
+
}
|
|
7374
|
+
function insert(node, parent, anchor) {
|
|
7375
|
+
parent.insertBefore(node, anchor);
|
|
7376
|
+
}
|
|
7377
|
+
function remove(node, parent) {
|
|
7378
|
+
parent.removeChild(node);
|
|
7379
|
+
}
|
|
7380
|
+
function nextSibling(node) {
|
|
7381
|
+
return node.nextSibling;
|
|
7382
|
+
}
|
|
7383
|
+
function attachShadow(element, options) {
|
|
7384
|
+
// `shadowRoot` will be non-null in two cases:
|
|
7385
|
+
// 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
|
|
7386
|
+
// 2. when a webapp author places <c-app> in their static HTML and mounts their
|
|
7387
|
+
// root component with customElement.define('c-app', Ctor)
|
|
7388
|
+
if (!isNull(element.shadowRoot)) {
|
|
7389
|
+
return element.shadowRoot;
|
|
7390
|
+
}
|
|
7391
|
+
return element.attachShadow(options);
|
|
7392
|
+
}
|
|
7393
|
+
function setText(node, content) {
|
|
7394
|
+
node.nodeValue = content;
|
|
7395
|
+
}
|
|
7396
|
+
function getProperty(node, key) {
|
|
7397
|
+
return node[key];
|
|
7398
|
+
}
|
|
7399
|
+
function setProperty(node, key, value) {
|
|
7400
|
+
node[key] = value;
|
|
7401
|
+
}
|
|
7402
|
+
function getAttribute(element, name, namespace) {
|
|
7403
|
+
return isUndefined(namespace)
|
|
7404
|
+
? element.getAttribute(name)
|
|
7405
|
+
: element.getAttributeNS(namespace, name);
|
|
7406
|
+
}
|
|
7407
|
+
function setAttribute(element, name, value, namespace) {
|
|
7408
|
+
return isUndefined(namespace)
|
|
7409
|
+
? element.setAttribute(name, value)
|
|
7410
|
+
: element.setAttributeNS(namespace, name, value);
|
|
7411
|
+
}
|
|
7412
|
+
function removeAttribute(element, name, namespace) {
|
|
7413
|
+
if (isUndefined(namespace)) {
|
|
7414
|
+
element.removeAttribute(name);
|
|
7034
7415
|
}
|
|
7035
|
-
|
|
7416
|
+
else {
|
|
7417
|
+
element.removeAttributeNS(namespace, name);
|
|
7418
|
+
}
|
|
7419
|
+
}
|
|
7420
|
+
function addEventListener(target, type, callback, options) {
|
|
7421
|
+
target.addEventListener(type, callback, options);
|
|
7422
|
+
}
|
|
7423
|
+
function removeEventListener(target, type, callback, options) {
|
|
7424
|
+
target.removeEventListener(type, callback, options);
|
|
7425
|
+
}
|
|
7426
|
+
function dispatchEvent(target, event) {
|
|
7427
|
+
return target.dispatchEvent(event);
|
|
7428
|
+
}
|
|
7429
|
+
function getClassList(element) {
|
|
7430
|
+
return element.classList;
|
|
7431
|
+
}
|
|
7432
|
+
function setCSSStyleProperty(element, name, value, important) {
|
|
7433
|
+
// TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
|
|
7434
|
+
// represent elements in the engine?
|
|
7435
|
+
element.style.setProperty(name, value, important ? 'important' : '');
|
|
7436
|
+
}
|
|
7437
|
+
function getBoundingClientRect(element) {
|
|
7438
|
+
return element.getBoundingClientRect();
|
|
7439
|
+
}
|
|
7440
|
+
function querySelector(element, selectors) {
|
|
7441
|
+
return element.querySelector(selectors);
|
|
7442
|
+
}
|
|
7443
|
+
function querySelectorAll(element, selectors) {
|
|
7444
|
+
return element.querySelectorAll(selectors);
|
|
7445
|
+
}
|
|
7446
|
+
function getElementsByTagName(element, tagNameOrWildCard) {
|
|
7447
|
+
return element.getElementsByTagName(tagNameOrWildCard);
|
|
7448
|
+
}
|
|
7449
|
+
function getElementsByClassName(element, names) {
|
|
7450
|
+
return element.getElementsByClassName(names);
|
|
7451
|
+
}
|
|
7452
|
+
function getChildren(element) {
|
|
7453
|
+
return element.children;
|
|
7454
|
+
}
|
|
7455
|
+
function getChildNodes(element) {
|
|
7456
|
+
return element.childNodes;
|
|
7457
|
+
}
|
|
7458
|
+
function getFirstChild(element) {
|
|
7459
|
+
return element.firstChild;
|
|
7460
|
+
}
|
|
7461
|
+
function getFirstElementChild(element) {
|
|
7462
|
+
return element.firstElementChild;
|
|
7463
|
+
}
|
|
7464
|
+
function getLastChild(element) {
|
|
7465
|
+
return element.lastChild;
|
|
7466
|
+
}
|
|
7467
|
+
function getLastElementChild(element) {
|
|
7468
|
+
return element.lastElementChild;
|
|
7469
|
+
}
|
|
7470
|
+
function isConnected(node) {
|
|
7471
|
+
return node.isConnected;
|
|
7472
|
+
}
|
|
7473
|
+
function assertInstanceOfHTMLElement(elm, msg) {
|
|
7474
|
+
assertInvariant(elm instanceof HTMLElement, msg);
|
|
7475
|
+
}
|
|
7476
|
+
const HTMLElementExported = HTMLElementConstructor;
|
|
7477
|
+
const renderer = {
|
|
7478
|
+
HTMLElementExported,
|
|
7479
|
+
insert,
|
|
7480
|
+
remove,
|
|
7481
|
+
cloneNode,
|
|
7482
|
+
createFragment,
|
|
7483
|
+
createElement,
|
|
7484
|
+
createText,
|
|
7485
|
+
createComment,
|
|
7486
|
+
nextSibling,
|
|
7487
|
+
attachShadow,
|
|
7488
|
+
getProperty,
|
|
7489
|
+
setProperty,
|
|
7490
|
+
setText,
|
|
7491
|
+
getAttribute,
|
|
7492
|
+
setAttribute,
|
|
7493
|
+
removeAttribute,
|
|
7494
|
+
addEventListener,
|
|
7495
|
+
removeEventListener,
|
|
7496
|
+
dispatchEvent,
|
|
7497
|
+
getClassList,
|
|
7498
|
+
setCSSStyleProperty,
|
|
7499
|
+
getBoundingClientRect,
|
|
7500
|
+
querySelector,
|
|
7501
|
+
querySelectorAll,
|
|
7502
|
+
getElementsByTagName,
|
|
7503
|
+
getElementsByClassName,
|
|
7504
|
+
getChildren,
|
|
7505
|
+
getChildNodes,
|
|
7506
|
+
getFirstChild,
|
|
7507
|
+
getFirstElementChild,
|
|
7508
|
+
getLastChild,
|
|
7509
|
+
getLastElementChild,
|
|
7510
|
+
isConnected,
|
|
7511
|
+
assertInstanceOfHTMLElement,
|
|
7512
|
+
defineCustomElement,
|
|
7513
|
+
getCustomElement,
|
|
7036
7514
|
};
|
|
7515
|
+
// Meant to inherit any properties passed via the base renderer as the argument to the factory.
|
|
7516
|
+
Object.setPrototypeOf(renderer, baseRenderer);
|
|
7517
|
+
return renderer;
|
|
7037
7518
|
}
|
|
7038
7519
|
|
|
7039
7520
|
/*
|
|
@@ -7042,245 +7523,21 @@ else {
|
|
|
7042
7523
|
* SPDX-License-Identifier: MIT
|
|
7043
7524
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7044
7525
|
*/
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
// get wrapped by babel.
|
|
7057
|
-
const HTMLElementAlias = HTMLElement;
|
|
7058
|
-
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
7059
|
-
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
7060
|
-
// which are not equipped to be initialized that way.
|
|
7061
|
-
class clazz extends HTMLElementAlias {
|
|
7062
|
-
}
|
|
7063
|
-
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
7064
|
-
new clazz();
|
|
7065
|
-
return true;
|
|
7066
|
-
}
|
|
7067
|
-
catch (_a) {
|
|
7068
|
-
return false;
|
|
7069
|
-
}
|
|
7070
|
-
}
|
|
7071
|
-
if (isCustomElementRegistryAvailable()) {
|
|
7072
|
-
getCustomElement = customElements.get.bind(customElements);
|
|
7073
|
-
defineCustomElement = customElements.define.bind(customElements);
|
|
7074
|
-
HTMLElementConstructor = HTMLElement;
|
|
7075
|
-
}
|
|
7076
|
-
else {
|
|
7077
|
-
const registry = create(null);
|
|
7078
|
-
const reverseRegistry = new WeakMap();
|
|
7079
|
-
defineCustomElement = function define(name, ctor) {
|
|
7080
|
-
if (name !== StringToLowerCase.call(name) || registry[name]) {
|
|
7081
|
-
throw new TypeError(`Invalid Registration`);
|
|
7082
|
-
}
|
|
7083
|
-
registry[name] = ctor;
|
|
7084
|
-
reverseRegistry.set(ctor, name);
|
|
7085
|
-
};
|
|
7086
|
-
getCustomElement = function get(name) {
|
|
7087
|
-
return registry[name];
|
|
7088
|
-
};
|
|
7089
|
-
HTMLElementConstructor = function HTMLElement() {
|
|
7090
|
-
if (!(this instanceof HTMLElement)) {
|
|
7091
|
-
throw new TypeError(`Invalid Invocation`);
|
|
7092
|
-
}
|
|
7093
|
-
const { constructor } = this;
|
|
7094
|
-
const name = reverseRegistry.get(constructor);
|
|
7095
|
-
if (!name) {
|
|
7096
|
-
throw new TypeError(`Invalid Construction`);
|
|
7097
|
-
}
|
|
7098
|
-
const elm = document.createElement(name);
|
|
7099
|
-
setPrototypeOf(elm, constructor.prototype);
|
|
7100
|
-
return elm;
|
|
7101
|
-
};
|
|
7102
|
-
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
7103
|
-
}
|
|
7104
|
-
let hydrating = false;
|
|
7105
|
-
function setIsHydrating(value) {
|
|
7106
|
-
hydrating = value;
|
|
7107
|
-
}
|
|
7108
|
-
const ssr = false;
|
|
7109
|
-
function isHydrating() {
|
|
7110
|
-
return hydrating;
|
|
7111
|
-
}
|
|
7112
|
-
const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
|
|
7113
|
-
const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
|
|
7114
|
-
function cloneNode(node, deep) {
|
|
7115
|
-
return node.cloneNode(deep);
|
|
7116
|
-
}
|
|
7117
|
-
function createElement$1(tagName, namespace) {
|
|
7118
|
-
return isUndefined$1(namespace)
|
|
7119
|
-
? document.createElement(tagName)
|
|
7120
|
-
: document.createElementNS(namespace, tagName);
|
|
7121
|
-
}
|
|
7122
|
-
function createText(content) {
|
|
7123
|
-
return document.createTextNode(content);
|
|
7124
|
-
}
|
|
7125
|
-
function createComment(content) {
|
|
7126
|
-
return document.createComment(content);
|
|
7127
|
-
}
|
|
7128
|
-
function insert(node, parent, anchor) {
|
|
7129
|
-
parent.insertBefore(node, anchor);
|
|
7130
|
-
}
|
|
7131
|
-
function remove(node, parent) {
|
|
7132
|
-
parent.removeChild(node);
|
|
7133
|
-
}
|
|
7134
|
-
function nextSibling(node) {
|
|
7135
|
-
return node.nextSibling;
|
|
7136
|
-
}
|
|
7137
|
-
function attachShadow(element, options) {
|
|
7138
|
-
// `hydrating` will be true in two cases:
|
|
7139
|
-
// 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
|
|
7140
|
-
// 2. when a webapp author places <c-app> in their static HTML and mounts their
|
|
7141
|
-
// root component with customeElement.define('c-app', Ctor)
|
|
7142
|
-
//
|
|
7143
|
-
// The second case can be treated as a failed hydration with nominal impact
|
|
7144
|
-
// to performance. However, because <c-app> won't have a <template shadowroot>
|
|
7145
|
-
// declarative child, `element.shadowRoot` is `null`.
|
|
7146
|
-
if (hydrating && element.shadowRoot) {
|
|
7147
|
-
return element.shadowRoot;
|
|
7148
|
-
}
|
|
7149
|
-
return element.attachShadow(options);
|
|
7150
|
-
}
|
|
7151
|
-
function setText(node, content) {
|
|
7152
|
-
node.nodeValue = content;
|
|
7153
|
-
}
|
|
7154
|
-
function getProperty(node, key) {
|
|
7155
|
-
return node[key];
|
|
7156
|
-
}
|
|
7157
|
-
function setProperty(node, key, value) {
|
|
7158
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
7159
|
-
if (node instanceof Element && !(key in node)) {
|
|
7160
|
-
// TODO [#1297]: Move this validation to the compiler
|
|
7161
|
-
assert.fail(`Unknown public property "${key}" of element <${node.tagName}>. This is likely a typo on the corresponding attribute "${htmlPropertyToAttribute(key)}".`);
|
|
7162
|
-
}
|
|
7163
|
-
}
|
|
7164
|
-
node[key] = value;
|
|
7165
|
-
}
|
|
7166
|
-
function getAttribute(element, name, namespace) {
|
|
7167
|
-
return isUndefined$1(namespace)
|
|
7168
|
-
? element.getAttribute(name)
|
|
7169
|
-
: element.getAttributeNS(namespace, name);
|
|
7170
|
-
}
|
|
7171
|
-
function setAttribute(element, name, value, namespace) {
|
|
7172
|
-
return isUndefined$1(namespace)
|
|
7173
|
-
? element.setAttribute(name, value)
|
|
7174
|
-
: element.setAttributeNS(namespace, name, value);
|
|
7175
|
-
}
|
|
7176
|
-
function removeAttribute(element, name, namespace) {
|
|
7177
|
-
if (isUndefined$1(namespace)) {
|
|
7178
|
-
element.removeAttribute(name);
|
|
7179
|
-
}
|
|
7180
|
-
else {
|
|
7181
|
-
element.removeAttributeNS(namespace, name);
|
|
7182
|
-
}
|
|
7183
|
-
}
|
|
7184
|
-
function addEventListener(target, type, callback, options) {
|
|
7185
|
-
target.addEventListener(type, callback, options);
|
|
7186
|
-
}
|
|
7187
|
-
function removeEventListener(target, type, callback, options) {
|
|
7188
|
-
target.removeEventListener(type, callback, options);
|
|
7189
|
-
}
|
|
7190
|
-
function dispatchEvent(target, event) {
|
|
7191
|
-
return target.dispatchEvent(event);
|
|
7192
|
-
}
|
|
7193
|
-
function getClassList(element) {
|
|
7194
|
-
return element.classList;
|
|
7195
|
-
}
|
|
7196
|
-
function setCSSStyleProperty(element, name, value, important) {
|
|
7197
|
-
// TODO [#0]: How to avoid this type casting? Shall we use a different type interface to
|
|
7198
|
-
// represent elements in the engine?
|
|
7199
|
-
element.style.setProperty(name, value, important ? 'important' : '');
|
|
7200
|
-
}
|
|
7201
|
-
function getBoundingClientRect(element) {
|
|
7202
|
-
return element.getBoundingClientRect();
|
|
7203
|
-
}
|
|
7204
|
-
function querySelector(element, selectors) {
|
|
7205
|
-
return element.querySelector(selectors);
|
|
7206
|
-
}
|
|
7207
|
-
function querySelectorAll(element, selectors) {
|
|
7208
|
-
return element.querySelectorAll(selectors);
|
|
7209
|
-
}
|
|
7210
|
-
function getElementsByTagName(element, tagNameOrWildCard) {
|
|
7211
|
-
return element.getElementsByTagName(tagNameOrWildCard);
|
|
7212
|
-
}
|
|
7213
|
-
function getElementsByClassName(element, names) {
|
|
7214
|
-
return element.getElementsByClassName(names);
|
|
7215
|
-
}
|
|
7216
|
-
function getChildren(element) {
|
|
7217
|
-
return element.children;
|
|
7218
|
-
}
|
|
7219
|
-
function getChildNodes(element) {
|
|
7220
|
-
return element.childNodes;
|
|
7221
|
-
}
|
|
7222
|
-
function getFirstChild(element) {
|
|
7223
|
-
return element.firstChild;
|
|
7224
|
-
}
|
|
7225
|
-
function getFirstElementChild(element) {
|
|
7226
|
-
return element.firstElementChild;
|
|
7227
|
-
}
|
|
7228
|
-
function getLastChild(element) {
|
|
7229
|
-
return element.lastChild;
|
|
7230
|
-
}
|
|
7231
|
-
function getLastElementChild(element) {
|
|
7232
|
-
return element.lastElementChild;
|
|
7233
|
-
}
|
|
7234
|
-
function isConnected(node) {
|
|
7235
|
-
return node.isConnected;
|
|
7236
|
-
}
|
|
7237
|
-
function assertInstanceOfHTMLElement(elm, msg) {
|
|
7238
|
-
assert.invariant(elm instanceof HTMLElement, msg);
|
|
7239
|
-
}
|
|
7240
|
-
const HTMLElementExported = HTMLElementConstructor;
|
|
7241
|
-
const renderer = {
|
|
7242
|
-
ssr,
|
|
7243
|
-
isNativeShadowDefined,
|
|
7244
|
-
isSyntheticShadowDefined,
|
|
7245
|
-
HTMLElementExported,
|
|
7246
|
-
isHydrating,
|
|
7247
|
-
insert,
|
|
7248
|
-
remove,
|
|
7249
|
-
cloneNode,
|
|
7250
|
-
createFragment,
|
|
7251
|
-
createElement: createElement$1,
|
|
7252
|
-
createText,
|
|
7253
|
-
createComment,
|
|
7254
|
-
nextSibling,
|
|
7255
|
-
attachShadow,
|
|
7256
|
-
getProperty,
|
|
7257
|
-
setProperty,
|
|
7258
|
-
setText,
|
|
7259
|
-
getAttribute,
|
|
7260
|
-
setAttribute,
|
|
7261
|
-
removeAttribute,
|
|
7262
|
-
addEventListener,
|
|
7263
|
-
removeEventListener,
|
|
7264
|
-
dispatchEvent,
|
|
7265
|
-
getClassList,
|
|
7266
|
-
setCSSStyleProperty,
|
|
7267
|
-
getBoundingClientRect,
|
|
7268
|
-
querySelector,
|
|
7269
|
-
querySelectorAll,
|
|
7270
|
-
getElementsByTagName,
|
|
7271
|
-
getElementsByClassName,
|
|
7272
|
-
getChildren,
|
|
7273
|
-
getChildNodes,
|
|
7274
|
-
getFirstChild,
|
|
7275
|
-
getFirstElementChild,
|
|
7276
|
-
getLastChild,
|
|
7277
|
-
getLastElementChild,
|
|
7278
|
-
isConnected,
|
|
7526
|
+
/**
|
|
7527
|
+
* The base renderer that will be used by engine-core.
|
|
7528
|
+
* This will be used for DOM operations when lwc is running in a browser environment.
|
|
7529
|
+
*/
|
|
7530
|
+
const renderer = assign(
|
|
7531
|
+
// The base renderer will invoke the factory with null and assign additional properties that are
|
|
7532
|
+
// shared across renderers
|
|
7533
|
+
rendererFactory(null),
|
|
7534
|
+
// Properties that are either not required to be sandboxed or rely on a globally shared information
|
|
7535
|
+
{
|
|
7536
|
+
// insertStyleSheet implementation shares a global cache of stylesheet data
|
|
7279
7537
|
insertStylesheet,
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
};
|
|
7538
|
+
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
7539
|
+
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
|
|
7540
|
+
});
|
|
7284
7541
|
|
|
7285
7542
|
/*
|
|
7286
7543
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7329,13 +7586,8 @@ function hydrateComponent(element, Ctor, props = {}) {
|
|
|
7329
7586
|
return;
|
|
7330
7587
|
}
|
|
7331
7588
|
try {
|
|
7332
|
-
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
7333
|
-
// and uses the same algo to create the stylesheets as in SSR.
|
|
7334
|
-
setIsHydrating(true);
|
|
7335
7589
|
const vm = createVMWithProps(element, Ctor, props);
|
|
7336
7590
|
hydrateRoot(vm);
|
|
7337
|
-
// set it back since now we finished hydration.
|
|
7338
|
-
setIsHydrating(false);
|
|
7339
7591
|
}
|
|
7340
7592
|
catch (e) {
|
|
7341
7593
|
// Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
|
|
@@ -7346,13 +7598,8 @@ function hydrateComponent(element, Ctor, props = {}) {
|
|
|
7346
7598
|
resetShadowRootAndLightDom(element, Ctor);
|
|
7347
7599
|
// we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
|
|
7348
7600
|
createVMWithProps(element, Ctor, props);
|
|
7349
|
-
setIsHydrating(false);
|
|
7350
7601
|
connectRootElement(element);
|
|
7351
7602
|
}
|
|
7352
|
-
finally {
|
|
7353
|
-
// in case there's an error during recovery
|
|
7354
|
-
setIsHydrating(false);
|
|
7355
|
-
}
|
|
7356
7603
|
}
|
|
7357
7604
|
|
|
7358
7605
|
/*
|
|
@@ -7426,44 +7673,60 @@ function buildCustomElementConstructor(Ctor) {
|
|
|
7426
7673
|
* SPDX-License-Identifier: MIT
|
|
7427
7674
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7428
7675
|
*/
|
|
7429
|
-
// TODO [#2472]: Remove this workaround when appropriate.
|
|
7430
7676
|
// eslint-disable-next-line @lwc/lwc-internal/no-global-node
|
|
7677
|
+
|
|
7431
7678
|
const _Node$1 = Node;
|
|
7432
7679
|
const ConnectingSlot = new WeakMap();
|
|
7433
7680
|
const DisconnectingSlot = new WeakMap();
|
|
7681
|
+
|
|
7434
7682
|
function callNodeSlot(node, slot) {
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7683
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7684
|
+
assert.isTrue(node, `callNodeSlot() should not be called for a non-object`);
|
|
7685
|
+
}
|
|
7686
|
+
|
|
7687
|
+
const fn = slot.get(node);
|
|
7688
|
+
|
|
7689
|
+
if (!isUndefined$1(fn)) {
|
|
7690
|
+
fn(node);
|
|
7691
|
+
}
|
|
7692
|
+
|
|
7693
|
+
return node; // for convenience
|
|
7443
7694
|
}
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7695
|
+
|
|
7696
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
7697
|
+
// Monkey patching Node methods to be able to detect the insertions and removal of root elements
|
|
7698
|
+
// created via createElement.
|
|
7699
|
+
const {
|
|
7700
|
+
appendChild,
|
|
7701
|
+
insertBefore,
|
|
7702
|
+
removeChild,
|
|
7703
|
+
replaceChild
|
|
7704
|
+
} = _Node$1.prototype;
|
|
7705
|
+
assign(_Node$1.prototype, {
|
|
7448
7706
|
appendChild(newChild) {
|
|
7449
|
-
|
|
7450
|
-
|
|
7707
|
+
const appendedNode = appendChild.call(this, newChild);
|
|
7708
|
+
return callNodeSlot(appendedNode, ConnectingSlot);
|
|
7451
7709
|
},
|
|
7710
|
+
|
|
7452
7711
|
insertBefore(newChild, referenceNode) {
|
|
7453
|
-
|
|
7454
|
-
|
|
7712
|
+
const insertedNode = insertBefore.call(this, newChild, referenceNode);
|
|
7713
|
+
return callNodeSlot(insertedNode, ConnectingSlot);
|
|
7455
7714
|
},
|
|
7715
|
+
|
|
7456
7716
|
removeChild(oldChild) {
|
|
7457
|
-
|
|
7458
|
-
|
|
7717
|
+
const removedNode = removeChild.call(this, oldChild);
|
|
7718
|
+
return callNodeSlot(removedNode, DisconnectingSlot);
|
|
7459
7719
|
},
|
|
7720
|
+
|
|
7460
7721
|
replaceChild(newChild, oldChild) {
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
}
|
|
7466
|
-
|
|
7722
|
+
const replacedNode = replaceChild.call(this, newChild, oldChild);
|
|
7723
|
+
callNodeSlot(replacedNode, DisconnectingSlot);
|
|
7724
|
+
callNodeSlot(newChild, ConnectingSlot);
|
|
7725
|
+
return replacedNode;
|
|
7726
|
+
}
|
|
7727
|
+
|
|
7728
|
+
});
|
|
7729
|
+
}
|
|
7467
7730
|
/**
|
|
7468
7731
|
* EXPERIMENTAL: This function is almost identical to document.createElement with the slightly
|
|
7469
7732
|
* difference that in the options, you can pass the `is` property set to a Constructor instead of
|
|
@@ -7475,38 +7738,50 @@ assign(_Node$1.prototype, {
|
|
|
7475
7738
|
* const el = createElement('x-foo', { is: FooCtor });
|
|
7476
7739
|
* ```
|
|
7477
7740
|
*/
|
|
7741
|
+
|
|
7742
|
+
|
|
7478
7743
|
function createElement(sel, options) {
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7744
|
+
if (!isObject(options) || isNull(options)) {
|
|
7745
|
+
throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
|
|
7746
|
+
}
|
|
7747
|
+
|
|
7748
|
+
const Ctor = options.is;
|
|
7749
|
+
|
|
7750
|
+
if (!isFunction$1(Ctor)) {
|
|
7751
|
+
throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
|
|
7752
|
+
}
|
|
7753
|
+
|
|
7754
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
7755
|
+
let wasComponentUpgraded = false; // the custom element from the registry is expecting an upgrade callback
|
|
7756
|
+
|
|
7757
|
+
/**
|
|
7758
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
7759
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
7760
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
7761
|
+
* an upgradable custom element.
|
|
7762
|
+
*/
|
|
7763
|
+
|
|
7764
|
+
const element = new UpgradableConstructor(elm => {
|
|
7765
|
+
createVM(elm, Ctor, renderer, {
|
|
7766
|
+
tagName: sel,
|
|
7767
|
+
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
7768
|
+
owner: null
|
|
7504
7769
|
});
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7770
|
+
|
|
7771
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
7772
|
+
ConnectingSlot.set(elm, connectRootElement);
|
|
7773
|
+
DisconnectingSlot.set(elm, disconnectRootElement);
|
|
7508
7774
|
}
|
|
7509
|
-
|
|
7775
|
+
|
|
7776
|
+
wasComponentUpgraded = true;
|
|
7777
|
+
});
|
|
7778
|
+
|
|
7779
|
+
if (!wasComponentUpgraded) {
|
|
7780
|
+
/* eslint-disable-next-line no-console */
|
|
7781
|
+
console.error(`Unexpected tag name "${sel}". This name is a registered custom element, preventing LWC to upgrade the element.`);
|
|
7782
|
+
}
|
|
7783
|
+
|
|
7784
|
+
return element;
|
|
7510
7785
|
}
|
|
7511
7786
|
|
|
7512
7787
|
/*
|
|
@@ -7540,7 +7815,7 @@ function isNodeShadowed(node) {
|
|
|
7540
7815
|
}
|
|
7541
7816
|
// TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
|
|
7542
7817
|
// inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
|
|
7543
|
-
return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
|
|
7818
|
+
return renderer.isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
|
|
7544
7819
|
}
|
|
7545
7820
|
|
|
7546
7821
|
/*
|
|
@@ -7577,6 +7852,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
7577
7852
|
});
|
|
7578
7853
|
freeze(LightningElement);
|
|
7579
7854
|
seal(LightningElement.prototype);
|
|
7580
|
-
/* version: 2.
|
|
7855
|
+
/* version: 2.23.2 */
|
|
7581
7856
|
|
|
7582
|
-
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
7857
|
+
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|