lwc 2.25.1 → 2.27.0
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 +953 -431
- package/dist/engine-dom/iife/es2017/engine-dom.js +953 -431
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +797 -223
- package/dist/engine-dom/iife/es5/engine-dom.js +1025 -330
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +952 -241
- package/dist/engine-dom/umd/es2017/engine-dom.js +953 -431
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +797 -223
- package/dist/engine-dom/umd/es5/engine-dom.js +1025 -330
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +952 -241
- package/dist/engine-server/commonjs/es2017/engine-server.js +201 -247
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +201 -247
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +4 -4
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +4 -4
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +4 -4
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +4 -4
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +4 -4
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
- 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
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
*/
|
|
50
50
|
const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getPrototypeOf: getPrototypeOf$1, hasOwnProperty: hasOwnProperty$1, isFrozen, keys, seal, setPrototypeOf, } = Object;
|
|
51
51
|
const { isArray: isArray$1 } = Array;
|
|
52
|
-
const { copyWithin: ArrayCopyWithin, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
|
|
52
|
+
const { concat: ArrayConcat$1, copyWithin: ArrayCopyWithin, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
|
|
53
53
|
const { fromCharCode: StringFromCharCode } = String;
|
|
54
54
|
const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
|
|
55
55
|
function isUndefined$1(obj) {
|
|
@@ -294,7 +294,7 @@
|
|
|
294
294
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
295
295
|
return attributeName;
|
|
296
296
|
}
|
|
297
|
-
/** version: 2.
|
|
297
|
+
/** version: 2.27.0 */
|
|
298
298
|
|
|
299
299
|
/**
|
|
300
300
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -376,7 +376,7 @@
|
|
|
376
376
|
patch$1(propName);
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
/** version: 2.
|
|
379
|
+
/** version: 2.27.0 */
|
|
380
380
|
|
|
381
381
|
/**
|
|
382
382
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -392,7 +392,6 @@
|
|
|
392
392
|
DUMMY_TEST_FLAG: null,
|
|
393
393
|
ENABLE_ELEMENT_PATCH: null,
|
|
394
394
|
ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
|
|
395
|
-
ENABLE_HMR: null,
|
|
396
395
|
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
397
396
|
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
398
397
|
ENABLE_MIXED_SHADOW_MODE: null,
|
|
@@ -403,6 +402,7 @@
|
|
|
403
402
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
404
403
|
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
405
404
|
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
405
|
+
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
406
406
|
};
|
|
407
407
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
408
408
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -1387,7 +1387,9 @@
|
|
|
1387
1387
|
const LightningElement = function () {
|
|
1388
1388
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
1389
1389
|
if (isNull(vmBeingConstructed)) {
|
|
1390
|
-
|
|
1390
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1391
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1392
|
+
throw new TypeError('Illegal constructor');
|
|
1391
1393
|
}
|
|
1392
1394
|
const vm = vmBeingConstructed;
|
|
1393
1395
|
const { def, elm } = vm;
|
|
@@ -2167,34 +2169,19 @@
|
|
|
2167
2169
|
freeze(BaseBridgeElement);
|
|
2168
2170
|
seal(BaseBridgeElement.prototype);
|
|
2169
2171
|
function setActiveVM(vm) {
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2172
|
+
{
|
|
2173
|
+
// this method should never leak to prod
|
|
2174
|
+
throw new ReferenceError();
|
|
2175
|
+
}
|
|
2174
2176
|
}
|
|
2175
2177
|
function swapTemplate(oldTpl, newTpl) {
|
|
2176
|
-
|
|
2177
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2178
|
-
throw new Error('HMR is not enabled');
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
|
-
return false;
|
|
2178
|
+
return false;
|
|
2182
2179
|
}
|
|
2183
2180
|
function swapComponent(oldComponent, newComponent) {
|
|
2184
|
-
|
|
2185
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2186
|
-
throw new Error('HMR is not enabled');
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
return false;
|
|
2181
|
+
return false;
|
|
2190
2182
|
}
|
|
2191
2183
|
function swapStyle(oldStyle, newStyle) {
|
|
2192
|
-
|
|
2193
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2194
|
-
throw new Error('HMR is not enabled');
|
|
2195
|
-
}
|
|
2196
|
-
|
|
2197
|
-
return false;
|
|
2184
|
+
return false;
|
|
2198
2185
|
}
|
|
2199
2186
|
|
|
2200
2187
|
/*
|
|
@@ -2573,15 +2560,18 @@
|
|
|
2573
2560
|
/**
|
|
2574
2561
|
* This function returns the host style token for a custom element if it
|
|
2575
2562
|
* exists. Otherwise it returns null.
|
|
2563
|
+
*
|
|
2564
|
+
* A host style token is applied to the component if scoped styles are used.
|
|
2576
2565
|
*/
|
|
2577
2566
|
|
|
2578
2567
|
function getStylesheetTokenHost(vnode) {
|
|
2579
2568
|
const {
|
|
2580
|
-
template
|
|
2581
|
-
stylesheetToken
|
|
2582
|
-
}
|
|
2569
|
+
template
|
|
2583
2570
|
} = getComponentInternalDef(vnode.ctor);
|
|
2584
|
-
|
|
2571
|
+
const {
|
|
2572
|
+
stylesheetToken
|
|
2573
|
+
} = template;
|
|
2574
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
2585
2575
|
}
|
|
2586
2576
|
|
|
2587
2577
|
function getNearestNativeShadowComponent(vm) {
|
|
@@ -2635,69 +2625,6 @@
|
|
|
2635
2625
|
return null;
|
|
2636
2626
|
}
|
|
2637
2627
|
|
|
2638
|
-
/*
|
|
2639
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
2640
|
-
* All rights reserved.
|
|
2641
|
-
* SPDX-License-Identifier: MIT
|
|
2642
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2643
|
-
*/
|
|
2644
|
-
|
|
2645
|
-
function checkHasVM(elm) {
|
|
2646
|
-
const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
2647
|
-
|
|
2648
|
-
return hasVM;
|
|
2649
|
-
}
|
|
2650
|
-
|
|
2651
|
-
function getUpgradableConstructor(tagName, renderer) {
|
|
2652
|
-
const {
|
|
2653
|
-
getCustomElement,
|
|
2654
|
-
HTMLElementExported: RendererHTMLElement,
|
|
2655
|
-
defineCustomElement
|
|
2656
|
-
} = renderer; // Should never get a tag with upper case letter at this point, the compiler should
|
|
2657
|
-
// produce only tags with lowercase letters
|
|
2658
|
-
// But, for backwards compatibility, we will lower case the tagName
|
|
2659
|
-
|
|
2660
|
-
tagName = tagName.toLowerCase();
|
|
2661
|
-
let CE = getCustomElement(tagName);
|
|
2662
|
-
|
|
2663
|
-
if (!isUndefined$1(CE)) {
|
|
2664
|
-
return CE;
|
|
2665
|
-
}
|
|
2666
|
-
/**
|
|
2667
|
-
* LWC Upgradable Element reference to an element that was created
|
|
2668
|
-
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
2669
|
-
*/
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
2673
|
-
constructor(upgradeCallback) {
|
|
2674
|
-
super();
|
|
2675
|
-
|
|
2676
|
-
if (isFunction$1(upgradeCallback)) {
|
|
2677
|
-
upgradeCallback(this); // nothing to do with the result for now
|
|
2678
|
-
}
|
|
2679
|
-
}
|
|
2680
|
-
|
|
2681
|
-
};
|
|
2682
|
-
|
|
2683
|
-
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
2684
|
-
CE.prototype.connectedCallback = function () {
|
|
2685
|
-
if (checkHasVM(this)) {
|
|
2686
|
-
connectRootElement(this);
|
|
2687
|
-
}
|
|
2688
|
-
};
|
|
2689
|
-
|
|
2690
|
-
CE.prototype.disconnectedCallback = function () {
|
|
2691
|
-
if (checkHasVM(this)) {
|
|
2692
|
-
disconnectRootElement(this);
|
|
2693
|
-
}
|
|
2694
|
-
};
|
|
2695
|
-
}
|
|
2696
|
-
|
|
2697
|
-
defineCustomElement(tagName, CE);
|
|
2698
|
-
return CE;
|
|
2699
|
-
}
|
|
2700
|
-
|
|
2701
2628
|
/*
|
|
2702
2629
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2703
2630
|
* All rights reserved.
|
|
@@ -2714,6 +2641,9 @@
|
|
|
2714
2641
|
function isVCustomElement(vnode) {
|
|
2715
2642
|
return vnode.type === 3 /* VNodeType.CustomElement */;
|
|
2716
2643
|
}
|
|
2644
|
+
function isVScopedSlotFragment(vnode) {
|
|
2645
|
+
return vnode.type === 6 /* VNodeType.ScopedSlotFragment */;
|
|
2646
|
+
}
|
|
2717
2647
|
|
|
2718
2648
|
/*
|
|
2719
2649
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -3185,7 +3115,9 @@
|
|
|
3185
3115
|
sel,
|
|
3186
3116
|
owner
|
|
3187
3117
|
} = vnode;
|
|
3188
|
-
const
|
|
3118
|
+
const {
|
|
3119
|
+
createCustomElement
|
|
3120
|
+
} = renderer;
|
|
3189
3121
|
/**
|
|
3190
3122
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3191
3123
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -3194,10 +3126,25 @@
|
|
|
3194
3126
|
*/
|
|
3195
3127
|
|
|
3196
3128
|
let vm;
|
|
3197
|
-
|
|
3129
|
+
|
|
3130
|
+
const upgradeCallback = elm => {
|
|
3198
3131
|
// the custom element from the registry is expecting an upgrade callback
|
|
3199
3132
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
3200
|
-
}
|
|
3133
|
+
};
|
|
3134
|
+
|
|
3135
|
+
const connectedCallback = elm => {
|
|
3136
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3137
|
+
connectRootElement(elm);
|
|
3138
|
+
}
|
|
3139
|
+
};
|
|
3140
|
+
|
|
3141
|
+
const disconnectedCallback = elm => {
|
|
3142
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3143
|
+
disconnectRootElement(elm);
|
|
3144
|
+
}
|
|
3145
|
+
};
|
|
3146
|
+
|
|
3147
|
+
const elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
3201
3148
|
vnode.elm = elm;
|
|
3202
3149
|
vnode.vm = vm;
|
|
3203
3150
|
linkNodeToShadow(elm, owner, renderer);
|
|
@@ -3205,8 +3152,6 @@
|
|
|
3205
3152
|
|
|
3206
3153
|
if (vm) {
|
|
3207
3154
|
allocateChildren(vnode, vm);
|
|
3208
|
-
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
3209
|
-
throw new TypeError(`Incorrect Component Constructor`);
|
|
3210
3155
|
}
|
|
3211
3156
|
|
|
3212
3157
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
@@ -3459,7 +3404,7 @@
|
|
|
3459
3404
|
/* RenderMode.Light */
|
|
3460
3405
|
) {
|
|
3461
3406
|
// slow path
|
|
3462
|
-
allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
|
|
3407
|
+
allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
|
|
3463
3408
|
|
|
3464
3409
|
vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
3465
3410
|
|
|
@@ -3491,13 +3436,19 @@
|
|
|
3491
3436
|
return vm;
|
|
3492
3437
|
}
|
|
3493
3438
|
|
|
3494
|
-
function allocateInSlot(vm, children) {
|
|
3495
|
-
var _a;
|
|
3439
|
+
function allocateInSlot(vm, children, owner) {
|
|
3440
|
+
var _a, _b;
|
|
3496
3441
|
|
|
3497
3442
|
const {
|
|
3498
|
-
cmpSlots:
|
|
3443
|
+
cmpSlots: {
|
|
3444
|
+
slotAssignments: oldSlotsMapping
|
|
3445
|
+
}
|
|
3499
3446
|
} = vm;
|
|
3500
|
-
const
|
|
3447
|
+
const cmpSlotsMapping = create(null);
|
|
3448
|
+
vm.cmpSlots = {
|
|
3449
|
+
owner,
|
|
3450
|
+
slotAssignments: cmpSlotsMapping
|
|
3451
|
+
};
|
|
3501
3452
|
|
|
3502
3453
|
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
3503
3454
|
const vnode = children[i];
|
|
@@ -3509,19 +3460,21 @@
|
|
|
3509
3460
|
let slotName = '';
|
|
3510
3461
|
|
|
3511
3462
|
if (isVBaseElement(vnode)) {
|
|
3512
|
-
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot)
|
|
3463
|
+
slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
|
|
3464
|
+
} else if (isVScopedSlotFragment(vnode)) {
|
|
3465
|
+
slotName = vnode.slotName;
|
|
3513
3466
|
}
|
|
3514
3467
|
|
|
3515
|
-
const vnodes =
|
|
3468
|
+
const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
|
|
3516
3469
|
ArrayPush$1.call(vnodes, vnode);
|
|
3517
3470
|
}
|
|
3518
3471
|
|
|
3519
3472
|
if (isFalse(vm.isDirty)) {
|
|
3520
3473
|
// We need to determine if the old allocation is really different from the new one
|
|
3521
3474
|
// and mark the vm as dirty
|
|
3522
|
-
const oldKeys = keys(
|
|
3475
|
+
const oldKeys = keys(oldSlotsMapping);
|
|
3523
3476
|
|
|
3524
|
-
if (oldKeys.length !== keys(
|
|
3477
|
+
if (oldKeys.length !== keys(cmpSlotsMapping).length) {
|
|
3525
3478
|
markComponentAsDirty(vm);
|
|
3526
3479
|
return;
|
|
3527
3480
|
}
|
|
@@ -3529,15 +3482,15 @@
|
|
|
3529
3482
|
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
3530
3483
|
const key = oldKeys[i];
|
|
3531
3484
|
|
|
3532
|
-
if (isUndefined$1(
|
|
3485
|
+
if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
|
|
3533
3486
|
markComponentAsDirty(vm);
|
|
3534
3487
|
return;
|
|
3535
3488
|
}
|
|
3536
3489
|
|
|
3537
|
-
const oldVNodes =
|
|
3538
|
-
const vnodes =
|
|
3490
|
+
const oldVNodes = oldSlotsMapping[key];
|
|
3491
|
+
const vnodes = cmpSlotsMapping[key];
|
|
3539
3492
|
|
|
3540
|
-
for (let j = 0, a =
|
|
3493
|
+
for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
|
|
3541
3494
|
if (oldVNodes[j] !== vnodes[j]) {
|
|
3542
3495
|
markComponentAsDirty(vm);
|
|
3543
3496
|
return;
|
|
@@ -3737,6 +3690,18 @@
|
|
|
3737
3690
|
function addVNodeToChildLWC(vnode) {
|
|
3738
3691
|
ArrayPush$1.call(getVMBeingRendered().velements, vnode);
|
|
3739
3692
|
}
|
|
3693
|
+
// [s]coped [s]lot [f]actory
|
|
3694
|
+
function ssf(slotName, factory) {
|
|
3695
|
+
return {
|
|
3696
|
+
type: 6 /* VNodeType.ScopedSlotFragment */,
|
|
3697
|
+
factory,
|
|
3698
|
+
owner: getVMBeingRendered(),
|
|
3699
|
+
elm: undefined,
|
|
3700
|
+
sel: undefined,
|
|
3701
|
+
key: undefined,
|
|
3702
|
+
slotName,
|
|
3703
|
+
};
|
|
3704
|
+
}
|
|
3740
3705
|
// [st]atic node
|
|
3741
3706
|
function st(fragment, key) {
|
|
3742
3707
|
return {
|
|
@@ -3789,9 +3754,31 @@
|
|
|
3789
3754
|
// [s]lot element node
|
|
3790
3755
|
function s(slotName, data, children, slotset) {
|
|
3791
3756
|
if (!isUndefined$1(slotset) &&
|
|
3792
|
-
!isUndefined$1(slotset
|
|
3793
|
-
slotset[slotName]
|
|
3794
|
-
|
|
3757
|
+
!isUndefined$1(slotset.slotAssignments) &&
|
|
3758
|
+
!isUndefined$1(slotset.slotAssignments[slotName]) &&
|
|
3759
|
+
slotset.slotAssignments[slotName].length !== 0) {
|
|
3760
|
+
children = slotset.slotAssignments[slotName].reduce((acc, vnode) => {
|
|
3761
|
+
// If the passed slot content is factory, evaluate it and use the produced vnodes
|
|
3762
|
+
if (vnode && isVScopedSlotFragment(vnode)) {
|
|
3763
|
+
const vmBeingRenderedInception = getVMBeingRendered();
|
|
3764
|
+
let children = [];
|
|
3765
|
+
// Evaluate in the scope of the slot content's owner
|
|
3766
|
+
// if a slotset is provided, there will always be an owner. The only case where owner is
|
|
3767
|
+
// undefined is for root components, but root components cannot accept slotted content
|
|
3768
|
+
setVMBeingRendered(slotset.owner);
|
|
3769
|
+
try {
|
|
3770
|
+
children = vnode.factory(data.slotData);
|
|
3771
|
+
}
|
|
3772
|
+
finally {
|
|
3773
|
+
setVMBeingRendered(vmBeingRenderedInception);
|
|
3774
|
+
}
|
|
3775
|
+
return ArrayConcat$1.call(acc, children);
|
|
3776
|
+
}
|
|
3777
|
+
else {
|
|
3778
|
+
// If the slot content is a static list of child nodes provided by the parent, nothing to do
|
|
3779
|
+
return ArrayConcat$1.call(acc, vnode);
|
|
3780
|
+
}
|
|
3781
|
+
}, []);
|
|
3795
3782
|
}
|
|
3796
3783
|
const vmBeingRendered = getVMBeingRendered();
|
|
3797
3784
|
const { renderMode, shadowMode } = vmBeingRendered;
|
|
@@ -4029,6 +4016,7 @@
|
|
|
4029
4016
|
gid,
|
|
4030
4017
|
fid,
|
|
4031
4018
|
shc,
|
|
4019
|
+
ssf,
|
|
4032
4020
|
});
|
|
4033
4021
|
/** Indicates if operations should be logged by the profiler. */
|
|
4034
4022
|
let isProfilerEnabled = false;
|
|
@@ -4521,7 +4509,9 @@
|
|
|
4521
4509
|
velements: EmptyArray,
|
|
4522
4510
|
cmpProps: create(null),
|
|
4523
4511
|
cmpFields: create(null),
|
|
4524
|
-
cmpSlots:
|
|
4512
|
+
cmpSlots: {
|
|
4513
|
+
slotAssignments: create(null)
|
|
4514
|
+
},
|
|
4525
4515
|
oar: create(null),
|
|
4526
4516
|
cmpTemplate: null,
|
|
4527
4517
|
hydrated: Boolean(hydrated),
|
|
@@ -5562,19 +5552,23 @@
|
|
|
5562
5552
|
//
|
|
5563
5553
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
5564
5554
|
// are rendered during SSR. This needs to be accounted for when validating.
|
|
5565
|
-
if (scopedToken) {
|
|
5555
|
+
if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
|
|
5566
5556
|
if (!isUndefined$1(className)) {
|
|
5567
|
-
className
|
|
5568
|
-
|
|
5569
|
-
|
|
5557
|
+
// The order of the className should be scopedToken className stylesheetTokenHost
|
|
5558
|
+
const classTokens = [scopedToken, className, stylesheetTokenHost];
|
|
5559
|
+
const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
|
|
5560
|
+
className = ArrayJoin.call(classNames, ' ');
|
|
5570
5561
|
}
|
|
5571
5562
|
else if (!isUndefined$1(classMap)) {
|
|
5572
|
-
classMap = Object.assign(Object.assign(Object.assign({}, classMap), { [scopedToken]: true }), (isNull(stylesheetTokenHost) ? {
|
|
5563
|
+
classMap = Object.assign(Object.assign(Object.assign({}, classMap), (!isNull(scopedToken) ? { [scopedToken]: true } : {})), (!isNull(stylesheetTokenHost) ? { [stylesheetTokenHost]: true } : {}));
|
|
5573
5564
|
}
|
|
5574
5565
|
else {
|
|
5575
|
-
className
|
|
5576
|
-
|
|
5577
|
-
|
|
5566
|
+
// The order of the className should be scopedToken stylesheetTokenHost
|
|
5567
|
+
const classTokens = [scopedToken, stylesheetTokenHost];
|
|
5568
|
+
const classNames = ArrayFilter.call(classTokens, (token) => !isNull(token));
|
|
5569
|
+
if (classNames.length) {
|
|
5570
|
+
className = ArrayJoin.call(classNames, ' ');
|
|
5571
|
+
}
|
|
5578
5572
|
}
|
|
5579
5573
|
}
|
|
5580
5574
|
let nodesAreCompatible = true;
|
|
@@ -5703,7 +5697,7 @@
|
|
|
5703
5697
|
}
|
|
5704
5698
|
return ctor;
|
|
5705
5699
|
}
|
|
5706
|
-
/* version: 2.
|
|
5700
|
+
/* version: 2.27.0 */
|
|
5707
5701
|
|
|
5708
5702
|
/*
|
|
5709
5703
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5838,6 +5832,626 @@
|
|
|
5838
5832
|
}
|
|
5839
5833
|
}
|
|
5840
5834
|
|
|
5835
|
+
/*
|
|
5836
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
5837
|
+
* All rights reserved.
|
|
5838
|
+
* SPDX-License-Identifier: MIT
|
|
5839
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5840
|
+
*/
|
|
5841
|
+
function isCustomElementRegistryAvailable() {
|
|
5842
|
+
if (typeof customElements === 'undefined') {
|
|
5843
|
+
return false;
|
|
5844
|
+
}
|
|
5845
|
+
try {
|
|
5846
|
+
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
5847
|
+
// _wrapNativeSuper()
|
|
5848
|
+
// This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
|
|
5849
|
+
// get wrapped by babel.
|
|
5850
|
+
const HTMLElementAlias = HTMLElement;
|
|
5851
|
+
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
5852
|
+
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
5853
|
+
// which are not equipped to be initialized that way.
|
|
5854
|
+
class clazz extends HTMLElementAlias {
|
|
5855
|
+
}
|
|
5856
|
+
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
5857
|
+
new clazz();
|
|
5858
|
+
return true;
|
|
5859
|
+
}
|
|
5860
|
+
catch (_a) {
|
|
5861
|
+
return false;
|
|
5862
|
+
}
|
|
5863
|
+
}
|
|
5864
|
+
const hasCustomElements = isCustomElementRegistryAvailable();
|
|
5865
|
+
|
|
5866
|
+
/*
|
|
5867
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
5868
|
+
* All rights reserved.
|
|
5869
|
+
* SPDX-License-Identifier: MIT
|
|
5870
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5871
|
+
*/
|
|
5872
|
+
// Creates a custom element for compat (legacy) browser environments
|
|
5873
|
+
const createCustomElementCompat = (tagName, upgradeCallback) => {
|
|
5874
|
+
const elm = document.createElement(tagName);
|
|
5875
|
+
upgradeCallback(elm); // nothing to do with the result for now
|
|
5876
|
+
return elm;
|
|
5877
|
+
};
|
|
5878
|
+
|
|
5879
|
+
/*
|
|
5880
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
5881
|
+
* All rights reserved.
|
|
5882
|
+
* SPDX-License-Identifier: MIT
|
|
5883
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5884
|
+
*/
|
|
5885
|
+
const cachedConstructors = new Map();
|
|
5886
|
+
const elementsUpgradedOutsideLWC = new WeakSet();
|
|
5887
|
+
let elementBeingUpgradedByLWC = false;
|
|
5888
|
+
// Creates a constructor that is intended to be used as a vanilla custom element, except that the upgradeCallback is
|
|
5889
|
+
// passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
|
|
5890
|
+
// Another benefit is that only LWC can create components that actually do anything – if you do
|
|
5891
|
+
// `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
|
|
5892
|
+
// This class should be created once per tag name.
|
|
5893
|
+
const createUpgradableConstructor = (connectedCallback, disconnectedCallback) => {
|
|
5894
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
5895
|
+
return class UpgradableConstructor extends HTMLElement {
|
|
5896
|
+
constructor(upgradeCallback) {
|
|
5897
|
+
super();
|
|
5898
|
+
// If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
|
|
5899
|
+
// then elementBeingUpgraded will be false
|
|
5900
|
+
if (elementBeingUpgradedByLWC) {
|
|
5901
|
+
upgradeCallback(this);
|
|
5902
|
+
}
|
|
5903
|
+
else {
|
|
5904
|
+
// keep track of elements that were not created by lwc.createElement,
|
|
5905
|
+
// so we can ignore their lifecycle hooks
|
|
5906
|
+
elementsUpgradedOutsideLWC.add(this);
|
|
5907
|
+
// TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
|
|
5908
|
+
// Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
|
|
5909
|
+
}
|
|
5910
|
+
}
|
|
5911
|
+
connectedCallback() {
|
|
5912
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
5913
|
+
connectedCallback(this);
|
|
5914
|
+
}
|
|
5915
|
+
}
|
|
5916
|
+
disconnectedCallback() {
|
|
5917
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
5918
|
+
disconnectedCallback(this);
|
|
5919
|
+
}
|
|
5920
|
+
}
|
|
5921
|
+
};
|
|
5922
|
+
};
|
|
5923
|
+
const createCustomElementVanilla = (tagName, upgradeCallback, connectedCallback, disconnectedCallback) => {
|
|
5924
|
+
// use global custom elements registry
|
|
5925
|
+
let UpgradableConstructor = cachedConstructors.get(tagName);
|
|
5926
|
+
if (isUndefined$1(UpgradableConstructor)) {
|
|
5927
|
+
if (!isUndefined$1(customElements.get(tagName))) {
|
|
5928
|
+
throw new Error(`Unexpected tag name "${tagName}". This name is a registered custom element, preventing LWC to upgrade the element.`);
|
|
5929
|
+
}
|
|
5930
|
+
UpgradableConstructor = createUpgradableConstructor(connectedCallback, disconnectedCallback);
|
|
5931
|
+
customElements.define(tagName, UpgradableConstructor);
|
|
5932
|
+
cachedConstructors.set(tagName, UpgradableConstructor);
|
|
5933
|
+
}
|
|
5934
|
+
elementBeingUpgradedByLWC = true;
|
|
5935
|
+
try {
|
|
5936
|
+
return new UpgradableConstructor(upgradeCallback);
|
|
5937
|
+
}
|
|
5938
|
+
finally {
|
|
5939
|
+
elementBeingUpgradedByLWC = false;
|
|
5940
|
+
}
|
|
5941
|
+
};
|
|
5942
|
+
|
|
5943
|
+
/*
|
|
5944
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
5945
|
+
* All rights reserved.
|
|
5946
|
+
* SPDX-License-Identifier: MIT
|
|
5947
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5948
|
+
*/
|
|
5949
|
+
/**
|
|
5950
|
+
* Create a scoped registry, i.e. a function that can create custom elements whose tag names
|
|
5951
|
+
* do not conflict with vanilla custom elements having the same tag name.
|
|
5952
|
+
*/
|
|
5953
|
+
function createScopedRegistry() {
|
|
5954
|
+
if (!hasCustomElements) {
|
|
5955
|
+
// This code should never be reached, because we don't use the pivot registry if
|
|
5956
|
+
// custom elements are unavailable.
|
|
5957
|
+
throw new Error('Custom elements are not supported in this environment.');
|
|
5958
|
+
}
|
|
5959
|
+
const { HTMLElement: NativeHTMLElement } = window;
|
|
5960
|
+
const { hasAttribute: nativeHasAttribute, setAttribute: nativeSetAttribute, removeAttribute: nativeRemoveAttribute, getAttribute: nativeGetAttribute, } = NativeHTMLElement.prototype;
|
|
5961
|
+
const definitionForElement = new WeakMap();
|
|
5962
|
+
const pendingRegistryForElement = new WeakMap();
|
|
5963
|
+
const definitionForConstructor = new WeakMap();
|
|
5964
|
+
const registeredUserCtors = new WeakSet();
|
|
5965
|
+
const pivotCtorByTag = new Map();
|
|
5966
|
+
const globalDefinitionsByTag = new Map();
|
|
5967
|
+
const globalDefinitionsByClass = new Map();
|
|
5968
|
+
const awaitingUpgrade = new Map();
|
|
5969
|
+
const EMPTY_SET = new Set();
|
|
5970
|
+
function createDefinitionRecord(constructor) {
|
|
5971
|
+
var _a;
|
|
5972
|
+
const { connectedCallback, disconnectedCallback, adoptedCallback, attributeChangedCallback, } = constructor.prototype;
|
|
5973
|
+
const observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
|
|
5974
|
+
return {
|
|
5975
|
+
UserCtor: constructor,
|
|
5976
|
+
PivotCtor: undefined,
|
|
5977
|
+
connectedCallback,
|
|
5978
|
+
disconnectedCallback,
|
|
5979
|
+
adoptedCallback,
|
|
5980
|
+
attributeChangedCallback,
|
|
5981
|
+
observedAttributes,
|
|
5982
|
+
};
|
|
5983
|
+
}
|
|
5984
|
+
// Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
|
|
5985
|
+
// element. Note that the `registeredDefinition` represents the constructor that was used to register during
|
|
5986
|
+
// `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
|
|
5987
|
+
// constructor is invoked with another constructor.
|
|
5988
|
+
function createPivotingClass(tagName, registeredDefinition) {
|
|
5989
|
+
class PivotCtor extends NativeHTMLElement {
|
|
5990
|
+
constructor(UserCtor) {
|
|
5991
|
+
// This constructor can only be invoked by:
|
|
5992
|
+
// a) the browser instantiating an element from parsing or via document.createElement.
|
|
5993
|
+
// b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
|
|
5994
|
+
// b) new UserClass.
|
|
5995
|
+
// When LWC instantiates it, it will pass the upgrading definition as an argument
|
|
5996
|
+
// If the caller signals via UserCtor that this is in fact a controlled
|
|
5997
|
+
// definition, we use that one, otherwise fallback to the global
|
|
5998
|
+
// internal registry.
|
|
5999
|
+
super();
|
|
6000
|
+
const userCtorIsDefined = !isUndefined$1(UserCtor);
|
|
6001
|
+
if (userCtorIsDefined) {
|
|
6002
|
+
if (!isConstructor(UserCtor)) {
|
|
6003
|
+
throw new TypeError(`Failed to create custom element: the provided constructor is not a constructor.`);
|
|
6004
|
+
}
|
|
6005
|
+
if (!registeredUserCtors.has(UserCtor)) {
|
|
6006
|
+
throw new Error(`Failed to create custom element: the provided constructor is unregistered: ${UserCtor.name}.`);
|
|
6007
|
+
}
|
|
6008
|
+
}
|
|
6009
|
+
const definition = userCtorIsDefined
|
|
6010
|
+
? getOrCreateDefinitionForConstructor(UserCtor)
|
|
6011
|
+
: globalDefinitionsByTag.get(tagName);
|
|
6012
|
+
if (!isUndefined$1(definition)) {
|
|
6013
|
+
internalUpgrade(this, registeredDefinition, definition);
|
|
6014
|
+
}
|
|
6015
|
+
else {
|
|
6016
|
+
// This is the case in which there is no global definition, and
|
|
6017
|
+
// it is not handled by LWC (otherwise it will have a valid UserCtor)
|
|
6018
|
+
// so we need to add it to the pending queue just in case it eventually
|
|
6019
|
+
// gets defined in the global registry.
|
|
6020
|
+
pendingRegistryForElement.set(this, registeredDefinition);
|
|
6021
|
+
}
|
|
6022
|
+
}
|
|
6023
|
+
connectedCallback() {
|
|
6024
|
+
var _a;
|
|
6025
|
+
const definition = definitionForElement.get(this);
|
|
6026
|
+
if (!isUndefined$1(definition)) {
|
|
6027
|
+
// Delegate out to user callback
|
|
6028
|
+
(_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
6029
|
+
}
|
|
6030
|
+
else {
|
|
6031
|
+
// Register for upgrade when defined (only when connected, so we don't leak)
|
|
6032
|
+
let awaiting = awaitingUpgrade.get(tagName);
|
|
6033
|
+
if (isUndefined$1(awaiting)) {
|
|
6034
|
+
awaitingUpgrade.set(tagName, (awaiting = new Set()));
|
|
6035
|
+
}
|
|
6036
|
+
awaiting.add(this);
|
|
6037
|
+
}
|
|
6038
|
+
}
|
|
6039
|
+
disconnectedCallback() {
|
|
6040
|
+
var _a;
|
|
6041
|
+
const definition = definitionForElement.get(this);
|
|
6042
|
+
if (!isUndefined$1(definition)) {
|
|
6043
|
+
// Delegate out to user callback
|
|
6044
|
+
(_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
6045
|
+
}
|
|
6046
|
+
else {
|
|
6047
|
+
// Un-register for upgrade when defined (so we don't leak)
|
|
6048
|
+
const awaiting = awaitingUpgrade.get(tagName);
|
|
6049
|
+
// At this point, awaiting should never be undefined, because connectedCallback
|
|
6050
|
+
// must have been called before disconnectedCallback. But just to be safe, we check
|
|
6051
|
+
if (!isUndefined$1(awaiting)) {
|
|
6052
|
+
awaiting.delete(this);
|
|
6053
|
+
}
|
|
6054
|
+
}
|
|
6055
|
+
}
|
|
6056
|
+
adoptedCallback() {
|
|
6057
|
+
var _a;
|
|
6058
|
+
const definition = definitionForElement.get(this);
|
|
6059
|
+
(_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
6060
|
+
}
|
|
6061
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
6062
|
+
var _a;
|
|
6063
|
+
const definition = definitionForElement.get(this);
|
|
6064
|
+
// if both definitions are the same, then the observedAttributes is the same,
|
|
6065
|
+
// but if they are different, only if the runtime definition has the attribute
|
|
6066
|
+
// marked as observed, then it should invoke attributeChangedCallback.
|
|
6067
|
+
if (registeredDefinition === definition ||
|
|
6068
|
+
(definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
|
|
6069
|
+
(_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
|
|
6070
|
+
}
|
|
6071
|
+
}
|
|
6072
|
+
}
|
|
6073
|
+
PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
|
|
6074
|
+
return PivotCtor;
|
|
6075
|
+
}
|
|
6076
|
+
function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
|
|
6077
|
+
const { observedAttributes, attributeChangedCallback } = pivotDefinition;
|
|
6078
|
+
if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
|
|
6079
|
+
// This instance does not need to observe any attributes, no need to patch
|
|
6080
|
+
return EMPTY_SET;
|
|
6081
|
+
}
|
|
6082
|
+
// Natively, the attributes observed by the registered definition are going to be taken
|
|
6083
|
+
// care of by the browser, only the difference between the two sets has to be taken
|
|
6084
|
+
// care by the patched version.
|
|
6085
|
+
return new Set([...pivotDefinition.observedAttributes].filter((x) => !registeredDefinition.observedAttributes.has(x)));
|
|
6086
|
+
}
|
|
6087
|
+
function throwAsyncError(error) {
|
|
6088
|
+
// Per native custom element behavior, errors thrown in attributeChangedCallback
|
|
6089
|
+
// become unhandled async errors. We use setTimeout() instead of Promise.resolve()
|
|
6090
|
+
// to make it an unhandled error rather than an unhandled rejection.
|
|
6091
|
+
setTimeout(() => {
|
|
6092
|
+
throw error;
|
|
6093
|
+
});
|
|
6094
|
+
}
|
|
6095
|
+
// Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
|
|
6096
|
+
// Why is this necessary? Well basically, you can't change the `observedAttributes` after
|
|
6097
|
+
// a custom element is defined. So with pivots, if two classes share the same tag name,
|
|
6098
|
+
// and the second class observes attributes that aren't observed by the first one,
|
|
6099
|
+
// then those attributes can never be observed by the native `observedAttributes` system.
|
|
6100
|
+
// So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
|
|
6101
|
+
// we only do this when absolutely necessary, though; i.e. because we've determined
|
|
6102
|
+
// that we aren't observing the attributes we need to.
|
|
6103
|
+
function patchAttributes(instance, registeredDefinition, pivotDefinition) {
|
|
6104
|
+
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
6105
|
+
if (newObservedAttributes.size === 0) {
|
|
6106
|
+
return;
|
|
6107
|
+
}
|
|
6108
|
+
const { attributeChangedCallback } = pivotDefinition;
|
|
6109
|
+
// Patch the instance.
|
|
6110
|
+
// Note we use the native `getAttribute` rather than the super's `getAttribute` because
|
|
6111
|
+
// we don't actually want it to be observable that we're calling `getAttribute` from
|
|
6112
|
+
// `setAttribute` and `removeAttribute`.
|
|
6113
|
+
// TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
|
|
6114
|
+
defineProperties(instance, {
|
|
6115
|
+
setAttribute: {
|
|
6116
|
+
value: function setAttribute(name, value) {
|
|
6117
|
+
if (newObservedAttributes.has(name)) {
|
|
6118
|
+
const old = nativeGetAttribute.call(this, name);
|
|
6119
|
+
nativeSetAttribute.call(this, name, value);
|
|
6120
|
+
try {
|
|
6121
|
+
attributeChangedCallback.call(this, name, old, value + '');
|
|
6122
|
+
}
|
|
6123
|
+
catch (error) {
|
|
6124
|
+
throwAsyncError(error);
|
|
6125
|
+
}
|
|
6126
|
+
}
|
|
6127
|
+
else {
|
|
6128
|
+
nativeSetAttribute.call(this, name, value);
|
|
6129
|
+
}
|
|
6130
|
+
},
|
|
6131
|
+
writable: true,
|
|
6132
|
+
enumerable: true,
|
|
6133
|
+
configurable: true,
|
|
6134
|
+
},
|
|
6135
|
+
removeAttribute: {
|
|
6136
|
+
value: function removeAttribute(name) {
|
|
6137
|
+
if (newObservedAttributes.has(name)) {
|
|
6138
|
+
const old = nativeGetAttribute.call(this, name);
|
|
6139
|
+
nativeRemoveAttribute.call(this, name);
|
|
6140
|
+
try {
|
|
6141
|
+
attributeChangedCallback.call(this, name, old, null);
|
|
6142
|
+
}
|
|
6143
|
+
catch (error) {
|
|
6144
|
+
throwAsyncError(error);
|
|
6145
|
+
}
|
|
6146
|
+
}
|
|
6147
|
+
else {
|
|
6148
|
+
nativeRemoveAttribute.call(this, name);
|
|
6149
|
+
}
|
|
6150
|
+
},
|
|
6151
|
+
writable: true,
|
|
6152
|
+
enumerable: true,
|
|
6153
|
+
configurable: true,
|
|
6154
|
+
},
|
|
6155
|
+
});
|
|
6156
|
+
}
|
|
6157
|
+
function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
6158
|
+
// The below case patches observed attributes for the case where the HTML element is upgraded
|
|
6159
|
+
// from a pre-existing one in the DOM.
|
|
6160
|
+
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
6161
|
+
if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
|
|
6162
|
+
return;
|
|
6163
|
+
}
|
|
6164
|
+
const { attributeChangedCallback } = pivotDefinition;
|
|
6165
|
+
// Approximate observedAttributes from the user class, but only for the new observed attributes
|
|
6166
|
+
newObservedAttributes.forEach((name) => {
|
|
6167
|
+
if (nativeHasAttribute.call(instance, name)) {
|
|
6168
|
+
const newValue = nativeGetAttribute.call(instance, name);
|
|
6169
|
+
attributeChangedCallback.call(instance, name, null, newValue);
|
|
6170
|
+
}
|
|
6171
|
+
});
|
|
6172
|
+
}
|
|
6173
|
+
// User extends this HTMLElement, which returns the CE being upgraded
|
|
6174
|
+
let upgradingInstance;
|
|
6175
|
+
// Helper to upgrade an instance with a CE definition using "constructor call trick"
|
|
6176
|
+
function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
6177
|
+
setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
|
|
6178
|
+
definitionForElement.set(instance, pivotDefinition);
|
|
6179
|
+
// attributes patches when needed
|
|
6180
|
+
if (pivotDefinition !== registeredDefinition) {
|
|
6181
|
+
patchAttributes(instance, registeredDefinition, pivotDefinition);
|
|
6182
|
+
}
|
|
6183
|
+
// Tricking the construction path to believe that a new instance is being created,
|
|
6184
|
+
// that way it will execute the super initialization mechanism but the HTMLElement
|
|
6185
|
+
// constructor will reuse the instance by returning the upgradingInstance.
|
|
6186
|
+
// This is by far the most important piece of the puzzle
|
|
6187
|
+
upgradingInstance = instance;
|
|
6188
|
+
// By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
|
|
6189
|
+
// The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
|
|
6190
|
+
// Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
|
|
6191
|
+
new pivotDefinition.UserCtor();
|
|
6192
|
+
patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
|
|
6193
|
+
}
|
|
6194
|
+
function isConstructor(constructor) {
|
|
6195
|
+
return isFunction$1(constructor) && isObject(constructor.prototype);
|
|
6196
|
+
}
|
|
6197
|
+
function getOrCreateDefinitionForConstructor(constructor) {
|
|
6198
|
+
if (!isConstructor(constructor)) {
|
|
6199
|
+
throw new TypeError('The referenced constructor is not a constructor.');
|
|
6200
|
+
}
|
|
6201
|
+
const definition = definitionForConstructor.get(constructor);
|
|
6202
|
+
if (!isUndefined$1(definition)) {
|
|
6203
|
+
return definition;
|
|
6204
|
+
}
|
|
6205
|
+
return createDefinitionRecord(constructor);
|
|
6206
|
+
}
|
|
6207
|
+
const { customElements: nativeRegistry } = window;
|
|
6208
|
+
const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
|
|
6209
|
+
// patch for the global registry define mechanism
|
|
6210
|
+
CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
|
|
6211
|
+
if (options && options.extends) {
|
|
6212
|
+
// TODO [#2983]: should we support `extends`?
|
|
6213
|
+
throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
|
|
6214
|
+
}
|
|
6215
|
+
if (globalDefinitionsByTag.has(tagName)) {
|
|
6216
|
+
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`);
|
|
6217
|
+
}
|
|
6218
|
+
if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
|
|
6219
|
+
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`);
|
|
6220
|
+
}
|
|
6221
|
+
const definition = getOrCreateDefinitionForConstructor(constructor);
|
|
6222
|
+
registeredUserCtors.add(constructor);
|
|
6223
|
+
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
6224
|
+
if (isUndefined$1(PivotCtor)) {
|
|
6225
|
+
PivotCtor = createPivotingClass(tagName, definition);
|
|
6226
|
+
// Register a pivoting class which will handle global registry initializations
|
|
6227
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
6228
|
+
}
|
|
6229
|
+
// Only cache after nativeDefine has been called, because if it throws an error
|
|
6230
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
6231
|
+
definitionForConstructor.set(constructor, definition);
|
|
6232
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
6233
|
+
globalDefinitionsByTag.set(tagName, definition);
|
|
6234
|
+
globalDefinitionsByClass.set(constructor, definition);
|
|
6235
|
+
// For globally defined custom elements, the definition associated
|
|
6236
|
+
// to the UserCtor has a back-pointer to PivotCtor in case the user
|
|
6237
|
+
// new the UserCtor, so we know how to create the underlying element.
|
|
6238
|
+
definition.PivotCtor = PivotCtor;
|
|
6239
|
+
// Upgrade any elements created in this scope before customElements.define
|
|
6240
|
+
// was called, which should be exhibited by the following steps:
|
|
6241
|
+
// 1) LWC registers a tagName for an LWC component.
|
|
6242
|
+
// 2) Element with same tagName is created with document.createElement()
|
|
6243
|
+
// and inserted into DOM.
|
|
6244
|
+
// 3) customElements.define() is called with tagName and non-LWC constructor.
|
|
6245
|
+
// This requires immediate upgrade when the new global tagName is defined.
|
|
6246
|
+
const awaiting = awaitingUpgrade.get(tagName);
|
|
6247
|
+
if (!isUndefined$1(awaiting)) {
|
|
6248
|
+
awaitingUpgrade.delete(tagName);
|
|
6249
|
+
for (const element of awaiting) {
|
|
6250
|
+
const registeredDefinition = pendingRegistryForElement.get(element);
|
|
6251
|
+
// At this point, registeredDefinition should never be undefined because awaitingUpgrade
|
|
6252
|
+
// is only populated when we haven't run internalUpgrade yet, and we only populate
|
|
6253
|
+
// pendingRegistryForElement when internalUpgrade hasn't run yet.
|
|
6254
|
+
// But just to be safe, we check.
|
|
6255
|
+
if (!isUndefined$1(registeredDefinition)) {
|
|
6256
|
+
pendingRegistryForElement.delete(element);
|
|
6257
|
+
internalUpgrade(element, registeredDefinition, definition);
|
|
6258
|
+
}
|
|
6259
|
+
}
|
|
6260
|
+
}
|
|
6261
|
+
};
|
|
6262
|
+
CustomElementRegistry.prototype.get = function get(tagName) {
|
|
6263
|
+
const NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
6264
|
+
if (!isUndefined$1(NativeCtor)) {
|
|
6265
|
+
const definition = globalDefinitionsByTag.get(tagName);
|
|
6266
|
+
if (!isUndefined$1(definition)) {
|
|
6267
|
+
return definition.UserCtor; // defined by the patched custom elements registry
|
|
6268
|
+
}
|
|
6269
|
+
// TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
6270
|
+
return NativeCtor; // return the pivot constructor or constructor that existed before patching
|
|
6271
|
+
}
|
|
6272
|
+
};
|
|
6273
|
+
CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
|
|
6274
|
+
return nativeWhenDefined.call(nativeRegistry, tagName).then((NativeCtor) => {
|
|
6275
|
+
const definition = globalDefinitionsByTag.get(tagName);
|
|
6276
|
+
if (!isUndefined$1(definition)) {
|
|
6277
|
+
return definition.UserCtor;
|
|
6278
|
+
}
|
|
6279
|
+
// TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
6280
|
+
// In this case, the custom element must have been defined before the registry patches
|
|
6281
|
+
// were applied. So return the non-pivot constructor
|
|
6282
|
+
if (isUndefined$1(NativeCtor)) {
|
|
6283
|
+
// Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
|
|
6284
|
+
// We can patch the correct behavior using customElements.get()
|
|
6285
|
+
return nativeGet.call(nativeRegistry, tagName);
|
|
6286
|
+
}
|
|
6287
|
+
return NativeCtor;
|
|
6288
|
+
});
|
|
6289
|
+
};
|
|
6290
|
+
// This constructor is invoked when we call `new pivotDefinition.UserCtor()`
|
|
6291
|
+
// @ts-ignore
|
|
6292
|
+
window.HTMLElement = function HTMLElement() {
|
|
6293
|
+
// Upgrading case: the pivoting class constructor was run by the browser's
|
|
6294
|
+
// native custom elements and we're in the process of running the
|
|
6295
|
+
// "constructor-call trick" on the natively constructed instance, so just
|
|
6296
|
+
// return that here.
|
|
6297
|
+
// This code path is also called when LWC `new`s a PivotCtor.
|
|
6298
|
+
const instance = upgradingInstance;
|
|
6299
|
+
if (!isUndefined$1(instance)) {
|
|
6300
|
+
upgradingInstance = undefined;
|
|
6301
|
+
return instance;
|
|
6302
|
+
}
|
|
6303
|
+
// Construction case: we need to construct the pivoting instance and return it.
|
|
6304
|
+
// This is possible when the user register it via global registry and instantiate
|
|
6305
|
+
// it via `new Ctor()`.
|
|
6306
|
+
const { constructor } = this;
|
|
6307
|
+
const definition = globalDefinitionsByClass.get(constructor);
|
|
6308
|
+
if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
|
|
6309
|
+
// This code path is hit if someone `new`s a class that extends `HTMLElement` without
|
|
6310
|
+
// doing `customElements.define()` first. This matches native browser behavior:
|
|
6311
|
+
// https://stackoverflow.com/a/61883392
|
|
6312
|
+
throw new TypeError('Illegal constructor');
|
|
6313
|
+
}
|
|
6314
|
+
// This constructor is ONLY invoked when it is the user instantiating
|
|
6315
|
+
// an element via new Ctor while Ctor is a registered global constructor.
|
|
6316
|
+
const { PivotCtor, UserCtor } = definition;
|
|
6317
|
+
return new PivotCtor(UserCtor);
|
|
6318
|
+
};
|
|
6319
|
+
HTMLElement.prototype = NativeHTMLElement.prototype;
|
|
6320
|
+
/**
|
|
6321
|
+
* Create a new PivotConstructor for the given tagName, which is capable of being constructed
|
|
6322
|
+
* with a UserConstructor defining the behavior. Passing in the UserConstructor here
|
|
6323
|
+
* is a hint that can be used when registering a custom element with the global custom elements
|
|
6324
|
+
* registry for the first time, which provides certain optimizations. It also marks the UserConstructor
|
|
6325
|
+
* as "safe" to be used when passed in to a PivotConstructor.
|
|
6326
|
+
*
|
|
6327
|
+
* @param tagName - element tag name
|
|
6328
|
+
* @param UserCtor - userland custom element constructor
|
|
6329
|
+
* @returns a new custom element constructor
|
|
6330
|
+
*/
|
|
6331
|
+
return function createPivotConstructor(tagName, UserCtor) {
|
|
6332
|
+
tagName = StringToLowerCase.call(tagName);
|
|
6333
|
+
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
6334
|
+
if (isUndefined$1(PivotCtor)) {
|
|
6335
|
+
const definition = getOrCreateDefinitionForConstructor(UserCtor);
|
|
6336
|
+
PivotCtor = createPivotingClass(tagName, definition);
|
|
6337
|
+
// Register a pivoting class as a global custom element
|
|
6338
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
6339
|
+
definition.PivotCtor = PivotCtor;
|
|
6340
|
+
// Only cache after nativeDefine has been called, because if it throws an error
|
|
6341
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
6342
|
+
definitionForConstructor.set(UserCtor, definition);
|
|
6343
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
6344
|
+
}
|
|
6345
|
+
// Register a UserConstructor as "safe" to be used within a PivotConstructor
|
|
6346
|
+
registeredUserCtors.add(UserCtor);
|
|
6347
|
+
return PivotCtor;
|
|
6348
|
+
};
|
|
6349
|
+
}
|
|
6350
|
+
|
|
6351
|
+
/*
|
|
6352
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6353
|
+
* All rights reserved.
|
|
6354
|
+
* SPDX-License-Identifier: MIT
|
|
6355
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6356
|
+
*/
|
|
6357
|
+
let createScopedConstructor;
|
|
6358
|
+
let CachedHTMLElement; // We only call `createScopedRegistry()` if the browser supports custom elements and
|
|
6359
|
+
// ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
|
|
6360
|
+
// or we're in a legacy browser.
|
|
6361
|
+
|
|
6362
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
6363
|
+
if (hasCustomElements) {
|
|
6364
|
+
// If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
|
|
6365
|
+
// It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
|
|
6366
|
+
//
|
|
6367
|
+
// Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
|
|
6368
|
+
//
|
|
6369
|
+
// 1. LWC loads
|
|
6370
|
+
// 2. `const Ctor = class extends HTMLElement {}`
|
|
6371
|
+
// 3. `lwc.createElement(...)` // here we lazily patch
|
|
6372
|
+
// 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
|
|
6373
|
+
//
|
|
6374
|
+
// To reduce the risk of this, it's safer to patch the registry eagerly.
|
|
6375
|
+
createScopedConstructor = createScopedRegistry(); // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
|
|
6376
|
+
// another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
|
|
6377
|
+
// because the HTMLElement prototypes are mixed up.
|
|
6378
|
+
//
|
|
6379
|
+
// The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
|
|
6380
|
+
// with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
|
|
6381
|
+
// the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
|
|
6382
|
+
// Caching avoids this problem.
|
|
6383
|
+
|
|
6384
|
+
CachedHTMLElement = window.HTMLElement;
|
|
6385
|
+
}
|
|
6386
|
+
} // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
|
|
6387
|
+
// In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
|
|
6388
|
+
// multiple times per tag name.
|
|
6389
|
+
|
|
6390
|
+
|
|
6391
|
+
const createUserConstructor = (upgradeCallback, connectedCallback, disconnectedCallback, HTMLElementToExtend) => {
|
|
6392
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
6393
|
+
return class UserConstructor extends HTMLElementToExtend {
|
|
6394
|
+
constructor() {
|
|
6395
|
+
super();
|
|
6396
|
+
upgradeCallback(this);
|
|
6397
|
+
}
|
|
6398
|
+
|
|
6399
|
+
connectedCallback() {
|
|
6400
|
+
connectedCallback(this);
|
|
6401
|
+
}
|
|
6402
|
+
|
|
6403
|
+
disconnectedCallback() {
|
|
6404
|
+
disconnectedCallback(this);
|
|
6405
|
+
}
|
|
6406
|
+
|
|
6407
|
+
};
|
|
6408
|
+
};
|
|
6409
|
+
|
|
6410
|
+
function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
6411
|
+
if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
|
|
6412
|
+
// This error should be impossible to hit
|
|
6413
|
+
throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
|
|
6414
|
+
}
|
|
6415
|
+
|
|
6416
|
+
const UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
|
|
6417
|
+
const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
|
|
6418
|
+
return new ScopedConstructor(UserConstructor);
|
|
6419
|
+
}
|
|
6420
|
+
|
|
6421
|
+
/*
|
|
6422
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6423
|
+
* All rights reserved.
|
|
6424
|
+
* SPDX-License-Identifier: MIT
|
|
6425
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6426
|
+
*/
|
|
6427
|
+
/**
|
|
6428
|
+
* We have three modes for creating custom elements:
|
|
6429
|
+
*
|
|
6430
|
+
* 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
|
|
6431
|
+
* 2. "Vanilla" custom elements registry. This system actually still allows us to have two LWC components with the
|
|
6432
|
+
* same tag name, via a simple trick: every custom element constructor we define in the registry is basically
|
|
6433
|
+
* the same. It's essentially a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its
|
|
6434
|
+
* constructor, which allows us to have completely customized functionality for different components.
|
|
6435
|
+
* 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
|
|
6436
|
+
* elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
|
|
6437
|
+
* between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
|
|
6438
|
+
* because it must patch the global `customElements` and `HTMLElement` objects.
|
|
6439
|
+
*/
|
|
6440
|
+
|
|
6441
|
+
let createCustomElement;
|
|
6442
|
+
|
|
6443
|
+
if (hasCustomElements) {
|
|
6444
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
6445
|
+
createCustomElement = createCustomElementScoped;
|
|
6446
|
+
} else {
|
|
6447
|
+
// use global custom elements registry (vanilla)
|
|
6448
|
+
createCustomElement = createCustomElementVanilla;
|
|
6449
|
+
}
|
|
6450
|
+
} else {
|
|
6451
|
+
// no registry available here
|
|
6452
|
+
createCustomElement = createCustomElementCompat;
|
|
6453
|
+
}
|
|
6454
|
+
|
|
5841
6455
|
/*
|
|
5842
6456
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
5843
6457
|
* All rights reserved.
|
|
@@ -5898,7 +6512,7 @@
|
|
|
5898
6512
|
function isNull(obj) {
|
|
5899
6513
|
return obj === null;
|
|
5900
6514
|
}
|
|
5901
|
-
/** version: 2.
|
|
6515
|
+
/** version: 2.27.0 */
|
|
5902
6516
|
|
|
5903
6517
|
/*
|
|
5904
6518
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5906,65 +6520,6 @@
|
|
|
5906
6520
|
* SPDX-License-Identifier: MIT
|
|
5907
6521
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5908
6522
|
*/
|
|
5909
|
-
exports.getCustomElement = void 0;
|
|
5910
|
-
exports.defineCustomElement = void 0;
|
|
5911
|
-
let HTMLElementConstructor;
|
|
5912
|
-
function isCustomElementRegistryAvailable() {
|
|
5913
|
-
if (typeof customElements === 'undefined') {
|
|
5914
|
-
return false;
|
|
5915
|
-
}
|
|
5916
|
-
try {
|
|
5917
|
-
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
5918
|
-
// _wrapNativeSuper()
|
|
5919
|
-
// This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
|
|
5920
|
-
// get wrapped by babel.
|
|
5921
|
-
const HTMLElementAlias = HTMLElement;
|
|
5922
|
-
// In case we use compat mode with a modern browser, the compat mode transformation
|
|
5923
|
-
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
5924
|
-
// which are not equipped to be initialized that way.
|
|
5925
|
-
class clazz extends HTMLElementAlias {
|
|
5926
|
-
}
|
|
5927
|
-
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
5928
|
-
new clazz();
|
|
5929
|
-
return true;
|
|
5930
|
-
}
|
|
5931
|
-
catch (_a) {
|
|
5932
|
-
return false;
|
|
5933
|
-
}
|
|
5934
|
-
}
|
|
5935
|
-
if (isCustomElementRegistryAvailable()) {
|
|
5936
|
-
exports.getCustomElement = customElements.get.bind(customElements);
|
|
5937
|
-
exports.defineCustomElement = customElements.define.bind(customElements);
|
|
5938
|
-
HTMLElementConstructor = HTMLElement;
|
|
5939
|
-
}
|
|
5940
|
-
else {
|
|
5941
|
-
const registry = Object.create(null);
|
|
5942
|
-
const reverseRegistry = new WeakMap();
|
|
5943
|
-
exports.defineCustomElement = function define(name, ctor) {
|
|
5944
|
-
if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
|
|
5945
|
-
throw new TypeError(`Invalid Registration`);
|
|
5946
|
-
}
|
|
5947
|
-
registry[name] = ctor;
|
|
5948
|
-
reverseRegistry.set(ctor, name);
|
|
5949
|
-
};
|
|
5950
|
-
exports.getCustomElement = function get(name) {
|
|
5951
|
-
return registry[name];
|
|
5952
|
-
};
|
|
5953
|
-
HTMLElementConstructor = function HTMLElement() {
|
|
5954
|
-
if (!(this instanceof HTMLElement)) {
|
|
5955
|
-
throw new TypeError(`Invalid Invocation`);
|
|
5956
|
-
}
|
|
5957
|
-
const { constructor } = this;
|
|
5958
|
-
const name = reverseRegistry.get(constructor);
|
|
5959
|
-
if (!name) {
|
|
5960
|
-
throw new TypeError(`Invalid Construction`);
|
|
5961
|
-
}
|
|
5962
|
-
const elm = document.createElement(name);
|
|
5963
|
-
Object.setPrototypeOf(elm, constructor.prototype);
|
|
5964
|
-
return elm;
|
|
5965
|
-
};
|
|
5966
|
-
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
5967
|
-
}
|
|
5968
6523
|
function cloneNode(node, deep) {
|
|
5969
6524
|
return node.cloneNode(deep);
|
|
5970
6525
|
}
|
|
@@ -6138,9 +6693,7 @@
|
|
|
6138
6693
|
function assertInstanceOfHTMLElement(elm, msg) {
|
|
6139
6694
|
assert.invariant(elm instanceof HTMLElement, msg);
|
|
6140
6695
|
}
|
|
6141
|
-
const HTMLElementExported = HTMLElementConstructor;
|
|
6142
6696
|
|
|
6143
|
-
exports.HTMLElementExported = HTMLElementExported;
|
|
6144
6697
|
exports.addEventListener = addEventListener;
|
|
6145
6698
|
exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
|
|
6146
6699
|
exports.attachShadow = attachShadow;
|
|
@@ -6200,6 +6753,8 @@
|
|
|
6200
6753
|
{
|
|
6201
6754
|
// insertStyleSheet implementation shares a global cache of stylesheet data
|
|
6202
6755
|
insertStylesheet,
|
|
6756
|
+
// relies on a shared global cache
|
|
6757
|
+
createCustomElement,
|
|
6203
6758
|
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
6204
6759
|
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
|
|
6205
6760
|
});
|
|
@@ -6295,36 +6850,44 @@
|
|
|
6295
6850
|
// This WeakSet usage is valid because this functionality is not meant to run in IE11.
|
|
6296
6851
|
const hydratedCustomElements = new WeakSet();
|
|
6297
6852
|
function buildCustomElementConstructor(Ctor) {
|
|
6853
|
+
var _a;
|
|
6298
6854
|
const HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6855
|
+
const { observedAttributes } = HtmlPrototype;
|
|
6856
|
+
const { attributeChangedCallback } = HtmlPrototype.prototype;
|
|
6857
|
+
return _a = class extends HTMLElement {
|
|
6858
|
+
constructor() {
|
|
6859
|
+
super();
|
|
6860
|
+
if (this.isConnected) {
|
|
6861
|
+
// this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
|
|
6862
|
+
hydrateComponent(this, Ctor, {});
|
|
6863
|
+
hydratedCustomElements.add(this);
|
|
6864
|
+
}
|
|
6865
|
+
else {
|
|
6866
|
+
createVM(this, Ctor, renderer, {
|
|
6867
|
+
mode: 'open',
|
|
6868
|
+
owner: null,
|
|
6869
|
+
tagName: this.tagName,
|
|
6870
|
+
});
|
|
6871
|
+
}
|
|
6306
6872
|
}
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6873
|
+
connectedCallback() {
|
|
6874
|
+
if (hydratedCustomElements.has(this)) {
|
|
6875
|
+
// This is an un-upgraded element that was hydrated in the constructor.
|
|
6876
|
+
hydratedCustomElements.delete(this);
|
|
6877
|
+
}
|
|
6878
|
+
else {
|
|
6879
|
+
connectRootElement(this);
|
|
6880
|
+
}
|
|
6313
6881
|
}
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
if (hydratedCustomElements.has(this)) {
|
|
6317
|
-
// This is an un-upgraded element that was hydrated in the constructor.
|
|
6318
|
-
hydratedCustomElements.delete(this);
|
|
6882
|
+
disconnectedCallback() {
|
|
6883
|
+
disconnectRootElement(this);
|
|
6319
6884
|
}
|
|
6320
|
-
|
|
6321
|
-
|
|
6885
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
6886
|
+
attributeChangedCallback.call(this, name, oldValue, newValue);
|
|
6322
6887
|
}
|
|
6323
|
-
}
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
}
|
|
6327
|
-
};
|
|
6888
|
+
},
|
|
6889
|
+
_a.observedAttributes = observedAttributes,
|
|
6890
|
+
_a;
|
|
6328
6891
|
}
|
|
6329
6892
|
|
|
6330
6893
|
/*
|
|
@@ -6408,8 +6971,13 @@
|
|
|
6408
6971
|
throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
|
|
6409
6972
|
}
|
|
6410
6973
|
|
|
6411
|
-
const
|
|
6412
|
-
|
|
6974
|
+
const {
|
|
6975
|
+
createCustomElement
|
|
6976
|
+
} = renderer; // tagName must be all lowercase, unfortunately, we have legacy code that is
|
|
6977
|
+
// passing `sel` as a camel-case, which makes them invalid custom elements name
|
|
6978
|
+
// the following line guarantees that this does not leaks beyond this point.
|
|
6979
|
+
|
|
6980
|
+
const tagName = StringToLowerCase.call(sel); // the custom element from the registry is expecting an upgrade callback
|
|
6413
6981
|
|
|
6414
6982
|
/**
|
|
6415
6983
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
@@ -6418,9 +6986,9 @@
|
|
|
6418
6986
|
* an upgradable custom element.
|
|
6419
6987
|
*/
|
|
6420
6988
|
|
|
6421
|
-
const
|
|
6989
|
+
const upgradeCallback = elm => {
|
|
6422
6990
|
createVM(elm, Ctor, renderer, {
|
|
6423
|
-
tagName
|
|
6991
|
+
tagName,
|
|
6424
6992
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
6425
6993
|
owner: null
|
|
6426
6994
|
});
|
|
@@ -6429,15 +6997,21 @@
|
|
|
6429
6997
|
ConnectingSlot.set(elm, connectRootElement);
|
|
6430
6998
|
DisconnectingSlot.set(elm, disconnectRootElement);
|
|
6431
6999
|
}
|
|
7000
|
+
};
|
|
6432
7001
|
|
|
6433
|
-
|
|
6434
|
-
|
|
7002
|
+
const connectedCallback = elm => {
|
|
7003
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
7004
|
+
connectRootElement(elm);
|
|
7005
|
+
}
|
|
7006
|
+
};
|
|
6435
7007
|
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
7008
|
+
const disconnectedCallback = elm => {
|
|
7009
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
7010
|
+
disconnectRootElement(elm);
|
|
7011
|
+
}
|
|
7012
|
+
};
|
|
6440
7013
|
|
|
7014
|
+
const element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
6441
7015
|
return element;
|
|
6442
7016
|
}
|
|
6443
7017
|
|
|
@@ -6509,7 +7083,7 @@
|
|
|
6509
7083
|
});
|
|
6510
7084
|
freeze(LightningElement);
|
|
6511
7085
|
seal(LightningElement.prototype);
|
|
6512
|
-
/* version: 2.
|
|
7086
|
+
/* version: 2.27.0 */
|
|
6513
7087
|
|
|
6514
7088
|
exports.LightningElement = LightningElement;
|
|
6515
7089
|
exports.__unstable__ProfilerControl = profilerControl;
|