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
|
@@ -120,6 +120,8 @@ var LWC = (function (exports) {
|
|
|
120
120
|
setPrototypeOf = Object.setPrototypeOf;
|
|
121
121
|
var isArray$1 = Array.isArray;
|
|
122
122
|
var _Array$prototype = Array.prototype,
|
|
123
|
+
ArrayConcat$1 = _Array$prototype.concat,
|
|
124
|
+
ArrayFilter = _Array$prototype.filter,
|
|
123
125
|
ArrayIndexOf = _Array$prototype.indexOf,
|
|
124
126
|
ArrayJoin = _Array$prototype.join,
|
|
125
127
|
ArrayMap = _Array$prototype.map,
|
|
@@ -346,7 +348,7 @@ var LWC = (function (exports) {
|
|
|
346
348
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
347
349
|
return attributeName;
|
|
348
350
|
}
|
|
349
|
-
/** version: 2.
|
|
351
|
+
/** version: 2.27.0 */
|
|
350
352
|
|
|
351
353
|
/**
|
|
352
354
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -440,7 +442,7 @@ var LWC = (function (exports) {
|
|
|
440
442
|
patch$1(propName);
|
|
441
443
|
}
|
|
442
444
|
}
|
|
443
|
-
/** version: 2.
|
|
445
|
+
/** version: 2.27.0 */
|
|
444
446
|
|
|
445
447
|
/**
|
|
446
448
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -458,7 +460,6 @@ var LWC = (function (exports) {
|
|
|
458
460
|
DUMMY_TEST_FLAG: null,
|
|
459
461
|
ENABLE_ELEMENT_PATCH: null,
|
|
460
462
|
ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
|
|
461
|
-
ENABLE_HMR: null,
|
|
462
463
|
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
463
464
|
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
464
465
|
ENABLE_MIXED_SHADOW_MODE: null,
|
|
@@ -468,7 +469,8 @@ var LWC = (function (exports) {
|
|
|
468
469
|
ENABLE_REACTIVE_SETTER: null,
|
|
469
470
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
470
471
|
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
471
|
-
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null
|
|
472
|
+
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
473
|
+
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null
|
|
472
474
|
};
|
|
473
475
|
|
|
474
476
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
@@ -1794,7 +1796,9 @@ var LWC = (function (exports) {
|
|
|
1794
1796
|
var LightningElement = function LightningElement() {
|
|
1795
1797
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
1796
1798
|
if (isNull(vmBeingConstructed)) {
|
|
1797
|
-
|
|
1799
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1800
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1801
|
+
throw new TypeError('Illegal constructor');
|
|
1798
1802
|
}
|
|
1799
1803
|
|
|
1800
1804
|
var vm = vmBeingConstructed;
|
|
@@ -2766,33 +2770,21 @@ var LWC = (function (exports) {
|
|
|
2766
2770
|
{
|
|
2767
2771
|
// this method should never leak to prod
|
|
2768
2772
|
throw new ReferenceError();
|
|
2769
|
-
}
|
|
2773
|
+
} // tracking active component
|
|
2770
2774
|
}
|
|
2771
2775
|
|
|
2772
2776
|
function swapTemplate(oldTpl, newTpl) {
|
|
2773
2777
|
|
|
2774
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2775
|
-
throw new Error('HMR is not enabled');
|
|
2776
|
-
}
|
|
2777
|
-
|
|
2778
2778
|
return false;
|
|
2779
2779
|
}
|
|
2780
2780
|
|
|
2781
2781
|
function swapComponent(oldComponent, newComponent) {
|
|
2782
2782
|
|
|
2783
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2784
|
-
throw new Error('HMR is not enabled');
|
|
2785
|
-
}
|
|
2786
|
-
|
|
2787
2783
|
return false;
|
|
2788
2784
|
}
|
|
2789
2785
|
|
|
2790
2786
|
function swapStyle(oldStyle, newStyle) {
|
|
2791
2787
|
|
|
2792
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2793
|
-
throw new Error('HMR is not enabled');
|
|
2794
|
-
}
|
|
2795
|
-
|
|
2796
2788
|
return false;
|
|
2797
2789
|
}
|
|
2798
2790
|
/*
|
|
@@ -3218,14 +3210,17 @@ var LWC = (function (exports) {
|
|
|
3218
3210
|
/**
|
|
3219
3211
|
* This function returns the host style token for a custom element if it
|
|
3220
3212
|
* exists. Otherwise it returns null.
|
|
3213
|
+
*
|
|
3214
|
+
* A host style token is applied to the component if scoped styles are used.
|
|
3221
3215
|
*/
|
|
3222
3216
|
|
|
3223
3217
|
|
|
3224
3218
|
function getStylesheetTokenHost(vnode) {
|
|
3225
3219
|
var _getComponentInternal = getComponentInternalDef(vnode.ctor),
|
|
3226
|
-
|
|
3220
|
+
template = _getComponentInternal.template;
|
|
3227
3221
|
|
|
3228
|
-
|
|
3222
|
+
var stylesheetToken = template.stylesheetToken;
|
|
3223
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
3229
3224
|
}
|
|
3230
3225
|
|
|
3231
3226
|
function getNearestNativeShadowComponent(vm) {
|
|
@@ -3274,78 +3269,6 @@ var LWC = (function (exports) {
|
|
|
3274
3269
|
|
|
3275
3270
|
return null;
|
|
3276
3271
|
}
|
|
3277
|
-
/*
|
|
3278
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
3279
|
-
* All rights reserved.
|
|
3280
|
-
* SPDX-License-Identifier: MIT
|
|
3281
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3282
|
-
*/
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
function checkHasVM(elm) {
|
|
3286
|
-
var hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
3287
|
-
|
|
3288
|
-
return hasVM;
|
|
3289
|
-
}
|
|
3290
|
-
|
|
3291
|
-
function getUpgradableConstructor(tagName, renderer) {
|
|
3292
|
-
var getCustomElement = renderer.getCustomElement,
|
|
3293
|
-
RendererHTMLElement = renderer.HTMLElementExported,
|
|
3294
|
-
defineCustomElement = renderer.defineCustomElement; // Should never get a tag with upper case letter at this point, the compiler should
|
|
3295
|
-
// produce only tags with lowercase letters
|
|
3296
|
-
// But, for backwards compatibility, we will lower case the tagName
|
|
3297
|
-
|
|
3298
|
-
tagName = tagName.toLowerCase();
|
|
3299
|
-
var CE = getCustomElement(tagName);
|
|
3300
|
-
|
|
3301
|
-
if (!isUndefined$1(CE)) {
|
|
3302
|
-
return CE;
|
|
3303
|
-
}
|
|
3304
|
-
/**
|
|
3305
|
-
* LWC Upgradable Element reference to an element that was created
|
|
3306
|
-
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3307
|
-
*/
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
CE = /*#__PURE__*/function (_RendererHTMLElement) {
|
|
3311
|
-
_inherits(LWCUpgradableElement, _RendererHTMLElement);
|
|
3312
|
-
|
|
3313
|
-
var _super5 = _createSuper(LWCUpgradableElement);
|
|
3314
|
-
|
|
3315
|
-
function LWCUpgradableElement(upgradeCallback) {
|
|
3316
|
-
var _this4;
|
|
3317
|
-
|
|
3318
|
-
_classCallCheck(this, LWCUpgradableElement);
|
|
3319
|
-
|
|
3320
|
-
_this4 = _super5.call(this);
|
|
3321
|
-
|
|
3322
|
-
if (isFunction$1(upgradeCallback)) {
|
|
3323
|
-
upgradeCallback(_assertThisInitialized(_this4)); // nothing to do with the result for now
|
|
3324
|
-
}
|
|
3325
|
-
|
|
3326
|
-
return _this4;
|
|
3327
|
-
}
|
|
3328
|
-
|
|
3329
|
-
return _createClass(LWCUpgradableElement);
|
|
3330
|
-
}(RendererHTMLElement);
|
|
3331
|
-
|
|
3332
|
-
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3333
|
-
CE.prototype.connectedCallback = function () {
|
|
3334
|
-
if (checkHasVM(this)) {
|
|
3335
|
-
connectRootElement(this);
|
|
3336
|
-
}
|
|
3337
|
-
};
|
|
3338
|
-
|
|
3339
|
-
CE.prototype.disconnectedCallback = function () {
|
|
3340
|
-
if (checkHasVM(this)) {
|
|
3341
|
-
disconnectRootElement(this);
|
|
3342
|
-
}
|
|
3343
|
-
};
|
|
3344
|
-
}
|
|
3345
|
-
|
|
3346
|
-
defineCustomElement(tagName, CE);
|
|
3347
|
-
return CE;
|
|
3348
|
-
}
|
|
3349
3272
|
/*
|
|
3350
3273
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3351
3274
|
* All rights reserved.
|
|
@@ -3372,6 +3295,12 @@ var LWC = (function (exports) {
|
|
|
3372
3295
|
/* VNodeType.CustomElement */
|
|
3373
3296
|
;
|
|
3374
3297
|
}
|
|
3298
|
+
|
|
3299
|
+
function isVScopedSlotFragment(vnode) {
|
|
3300
|
+
return vnode.type === 6
|
|
3301
|
+
/* VNodeType.ScopedSlotFragment */
|
|
3302
|
+
;
|
|
3303
|
+
}
|
|
3375
3304
|
/*
|
|
3376
3305
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3377
3306
|
* All rights reserved.
|
|
@@ -3878,7 +3807,7 @@ var LWC = (function (exports) {
|
|
|
3878
3807
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3879
3808
|
var sel = vnode.sel,
|
|
3880
3809
|
owner = vnode.owner;
|
|
3881
|
-
var
|
|
3810
|
+
var createCustomElement = renderer.createCustomElement;
|
|
3882
3811
|
/**
|
|
3883
3812
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3884
3813
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -3887,10 +3816,25 @@ var LWC = (function (exports) {
|
|
|
3887
3816
|
*/
|
|
3888
3817
|
|
|
3889
3818
|
var vm;
|
|
3890
|
-
|
|
3819
|
+
|
|
3820
|
+
var upgradeCallback = function upgradeCallback(elm) {
|
|
3891
3821
|
// the custom element from the registry is expecting an upgrade callback
|
|
3892
3822
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
3893
|
-
}
|
|
3823
|
+
};
|
|
3824
|
+
|
|
3825
|
+
var connectedCallback = function connectedCallback(elm) {
|
|
3826
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3827
|
+
connectRootElement(elm);
|
|
3828
|
+
}
|
|
3829
|
+
};
|
|
3830
|
+
|
|
3831
|
+
var disconnectedCallback = function disconnectedCallback(elm) {
|
|
3832
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3833
|
+
disconnectRootElement(elm);
|
|
3834
|
+
}
|
|
3835
|
+
};
|
|
3836
|
+
|
|
3837
|
+
var elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
3894
3838
|
vnode.elm = elm;
|
|
3895
3839
|
vnode.vm = vm;
|
|
3896
3840
|
linkNodeToShadow(elm, owner, renderer);
|
|
@@ -3898,8 +3842,6 @@ var LWC = (function (exports) {
|
|
|
3898
3842
|
|
|
3899
3843
|
if (vm) {
|
|
3900
3844
|
allocateChildren(vnode, vm);
|
|
3901
|
-
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
3902
|
-
throw new TypeError("Incorrect Component Constructor");
|
|
3903
3845
|
}
|
|
3904
3846
|
|
|
3905
3847
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
@@ -4138,7 +4080,7 @@ var LWC = (function (exports) {
|
|
|
4138
4080
|
/* RenderMode.Light */
|
|
4139
4081
|
) {
|
|
4140
4082
|
// slow path
|
|
4141
|
-
allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
|
|
4083
|
+
allocateInSlot(vm, children, vnode.owner); // save the allocated children in case this vnode is reused.
|
|
4142
4084
|
|
|
4143
4085
|
vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4144
4086
|
|
|
@@ -4168,11 +4110,15 @@ var LWC = (function (exports) {
|
|
|
4168
4110
|
return vm;
|
|
4169
4111
|
}
|
|
4170
4112
|
|
|
4171
|
-
function allocateInSlot(vm, children) {
|
|
4172
|
-
var _a;
|
|
4113
|
+
function allocateInSlot(vm, children, owner) {
|
|
4114
|
+
var _a, _b;
|
|
4173
4115
|
|
|
4174
|
-
var
|
|
4175
|
-
var
|
|
4116
|
+
var oldSlotsMapping = vm.cmpSlots.slotAssignments;
|
|
4117
|
+
var cmpSlotsMapping = create(null);
|
|
4118
|
+
vm.cmpSlots = {
|
|
4119
|
+
owner: owner,
|
|
4120
|
+
slotAssignments: cmpSlotsMapping
|
|
4121
|
+
};
|
|
4176
4122
|
|
|
4177
4123
|
for (var _i15 = 0, len = children.length; _i15 < len; _i15 += 1) {
|
|
4178
4124
|
var vnode = children[_i15];
|
|
@@ -4184,19 +4130,21 @@ var LWC = (function (exports) {
|
|
|
4184
4130
|
var slotName = '';
|
|
4185
4131
|
|
|
4186
4132
|
if (isVBaseElement(vnode)) {
|
|
4187
|
-
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot)
|
|
4133
|
+
slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
|
|
4134
|
+
} else if (isVScopedSlotFragment(vnode)) {
|
|
4135
|
+
slotName = vnode.slotName;
|
|
4188
4136
|
}
|
|
4189
4137
|
|
|
4190
|
-
var vnodes =
|
|
4138
|
+
var vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
|
|
4191
4139
|
ArrayPush$1.call(vnodes, vnode);
|
|
4192
4140
|
}
|
|
4193
4141
|
|
|
4194
4142
|
if (isFalse(vm.isDirty)) {
|
|
4195
4143
|
// We need to determine if the old allocation is really different from the new one
|
|
4196
4144
|
// and mark the vm as dirty
|
|
4197
|
-
var oldKeys = keys(
|
|
4145
|
+
var oldKeys = keys(oldSlotsMapping);
|
|
4198
4146
|
|
|
4199
|
-
if (oldKeys.length !== keys(
|
|
4147
|
+
if (oldKeys.length !== keys(cmpSlotsMapping).length) {
|
|
4200
4148
|
markComponentAsDirty(vm);
|
|
4201
4149
|
return;
|
|
4202
4150
|
}
|
|
@@ -4204,15 +4152,15 @@ var LWC = (function (exports) {
|
|
|
4204
4152
|
for (var _i16 = 0, _len4 = oldKeys.length; _i16 < _len4; _i16 += 1) {
|
|
4205
4153
|
var key = oldKeys[_i16];
|
|
4206
4154
|
|
|
4207
|
-
if (isUndefined$1(
|
|
4155
|
+
if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
|
|
4208
4156
|
markComponentAsDirty(vm);
|
|
4209
4157
|
return;
|
|
4210
4158
|
}
|
|
4211
4159
|
|
|
4212
|
-
var oldVNodes =
|
|
4213
|
-
var _vnodes =
|
|
4160
|
+
var oldVNodes = oldSlotsMapping[key];
|
|
4161
|
+
var _vnodes = cmpSlotsMapping[key];
|
|
4214
4162
|
|
|
4215
|
-
for (var j = 0, a =
|
|
4163
|
+
for (var j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
|
|
4216
4164
|
if (oldVNodes[j] !== _vnodes[j]) {
|
|
4217
4165
|
markComponentAsDirty(vm);
|
|
4218
4166
|
return;
|
|
@@ -4411,6 +4359,21 @@ var LWC = (function (exports) {
|
|
|
4411
4359
|
|
|
4412
4360
|
function addVNodeToChildLWC(vnode) {
|
|
4413
4361
|
ArrayPush$1.call(getVMBeingRendered().velements, vnode);
|
|
4362
|
+
} // [s]coped [s]lot [f]actory
|
|
4363
|
+
|
|
4364
|
+
|
|
4365
|
+
function ssf(slotName, factory) {
|
|
4366
|
+
return {
|
|
4367
|
+
type: 6
|
|
4368
|
+
/* VNodeType.ScopedSlotFragment */
|
|
4369
|
+
,
|
|
4370
|
+
factory: factory,
|
|
4371
|
+
owner: getVMBeingRendered(),
|
|
4372
|
+
elm: undefined,
|
|
4373
|
+
sel: undefined,
|
|
4374
|
+
key: undefined,
|
|
4375
|
+
slotName: slotName
|
|
4376
|
+
};
|
|
4414
4377
|
} // [st]atic node
|
|
4415
4378
|
|
|
4416
4379
|
|
|
@@ -4481,8 +4444,29 @@ var LWC = (function (exports) {
|
|
|
4481
4444
|
|
|
4482
4445
|
function s(slotName, data, children, slotset) {
|
|
4483
4446
|
|
|
4484
|
-
if (!isUndefined$1(slotset) && !isUndefined$1(slotset[slotName]) && slotset[slotName].length !== 0) {
|
|
4485
|
-
children = slotset[slotName]
|
|
4447
|
+
if (!isUndefined$1(slotset) && !isUndefined$1(slotset.slotAssignments) && !isUndefined$1(slotset.slotAssignments[slotName]) && slotset.slotAssignments[slotName].length !== 0) {
|
|
4448
|
+
children = slotset.slotAssignments[slotName].reduce(function (acc, vnode) {
|
|
4449
|
+
// If the passed slot content is factory, evaluate it and use the produced vnodes
|
|
4450
|
+
if (vnode && isVScopedSlotFragment(vnode)) {
|
|
4451
|
+
var vmBeingRenderedInception = getVMBeingRendered();
|
|
4452
|
+
var _children = []; // Evaluate in the scope of the slot content's owner
|
|
4453
|
+
// if a slotset is provided, there will always be an owner. The only case where owner is
|
|
4454
|
+
// undefined is for root components, but root components cannot accept slotted content
|
|
4455
|
+
|
|
4456
|
+
setVMBeingRendered(slotset.owner);
|
|
4457
|
+
|
|
4458
|
+
try {
|
|
4459
|
+
_children = vnode.factory(data.slotData);
|
|
4460
|
+
} finally {
|
|
4461
|
+
setVMBeingRendered(vmBeingRenderedInception);
|
|
4462
|
+
}
|
|
4463
|
+
|
|
4464
|
+
return ArrayConcat$1.call(acc, _children);
|
|
4465
|
+
} else {
|
|
4466
|
+
// If the slot content is a static list of child nodes provided by the parent, nothing to do
|
|
4467
|
+
return ArrayConcat$1.call(acc, vnode);
|
|
4468
|
+
}
|
|
4469
|
+
}, []);
|
|
4486
4470
|
}
|
|
4487
4471
|
|
|
4488
4472
|
var vmBeingRendered = getVMBeingRendered();
|
|
@@ -4799,7 +4783,8 @@ var LWC = (function (exports) {
|
|
|
4799
4783
|
st: st,
|
|
4800
4784
|
gid: gid,
|
|
4801
4785
|
fid: fid,
|
|
4802
|
-
shc: shc
|
|
4786
|
+
shc: shc,
|
|
4787
|
+
ssf: ssf
|
|
4803
4788
|
});
|
|
4804
4789
|
/** Indicates if operations should be logged by the profiler. */
|
|
4805
4790
|
|
|
@@ -5410,7 +5395,9 @@ var LWC = (function (exports) {
|
|
|
5410
5395
|
velements: EmptyArray,
|
|
5411
5396
|
cmpProps: create(null),
|
|
5412
5397
|
cmpFields: create(null),
|
|
5413
|
-
cmpSlots:
|
|
5398
|
+
cmpSlots: {
|
|
5399
|
+
slotAssignments: create(null)
|
|
5400
|
+
},
|
|
5414
5401
|
oar: create(null),
|
|
5415
5402
|
cmpTemplate: null,
|
|
5416
5403
|
hydrated: Boolean(hydrated),
|
|
@@ -5874,21 +5861,21 @@ var LWC = (function (exports) {
|
|
|
5874
5861
|
var WireContextRegistrationEvent = /*#__PURE__*/function (_CustomEvent) {
|
|
5875
5862
|
_inherits(WireContextRegistrationEvent, _CustomEvent);
|
|
5876
5863
|
|
|
5877
|
-
var
|
|
5864
|
+
var _super5 = _createSuper(WireContextRegistrationEvent);
|
|
5878
5865
|
|
|
5879
5866
|
function WireContextRegistrationEvent(adapterToken, _ref3) {
|
|
5880
|
-
var
|
|
5867
|
+
var _this4;
|
|
5881
5868
|
|
|
5882
5869
|
var setNewContext = _ref3.setNewContext,
|
|
5883
5870
|
setDisconnectedCallback = _ref3.setDisconnectedCallback;
|
|
5884
5871
|
|
|
5885
5872
|
_classCallCheck(this, WireContextRegistrationEvent);
|
|
5886
5873
|
|
|
5887
|
-
|
|
5874
|
+
_this4 = _super5.call(this, adapterToken, {
|
|
5888
5875
|
bubbles: true,
|
|
5889
5876
|
composed: true
|
|
5890
5877
|
});
|
|
5891
|
-
defineProperties(_assertThisInitialized(
|
|
5878
|
+
defineProperties(_assertThisInitialized(_this4), {
|
|
5892
5879
|
setNewContext: {
|
|
5893
5880
|
value: setNewContext
|
|
5894
5881
|
},
|
|
@@ -5896,7 +5883,7 @@ var LWC = (function (exports) {
|
|
|
5896
5883
|
value: setDisconnectedCallback
|
|
5897
5884
|
}
|
|
5898
5885
|
});
|
|
5899
|
-
return
|
|
5886
|
+
return _this4;
|
|
5900
5887
|
}
|
|
5901
5888
|
|
|
5902
5889
|
return _createClass(WireContextRegistrationEvent);
|
|
@@ -6535,13 +6522,27 @@ var LWC = (function (exports) {
|
|
|
6535
6522
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
6536
6523
|
// are rendered during SSR. This needs to be accounted for when validating.
|
|
6537
6524
|
|
|
6538
|
-
if (scopedToken) {
|
|
6525
|
+
if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
|
|
6539
6526
|
if (!isUndefined$1(className)) {
|
|
6540
|
-
|
|
6527
|
+
// The order of the className should be scopedToken className stylesheetTokenHost
|
|
6528
|
+
var classTokens = [scopedToken, className, stylesheetTokenHost];
|
|
6529
|
+
var classNames = ArrayFilter.call(classTokens, function (token) {
|
|
6530
|
+
return !isNull(token);
|
|
6531
|
+
});
|
|
6532
|
+
className = ArrayJoin.call(classNames, ' ');
|
|
6541
6533
|
} else if (!isUndefined$1(classMap)) {
|
|
6542
|
-
classMap = Object.assign(Object.assign(Object.assign({}, classMap), _defineProperty({}, scopedToken, true)), isNull(stylesheetTokenHost) ?
|
|
6534
|
+
classMap = Object.assign(Object.assign(Object.assign({}, classMap), !isNull(scopedToken) ? _defineProperty({}, scopedToken, true) : {}), !isNull(stylesheetTokenHost) ? _defineProperty({}, stylesheetTokenHost, true) : {});
|
|
6543
6535
|
} else {
|
|
6544
|
-
|
|
6536
|
+
// The order of the className should be scopedToken stylesheetTokenHost
|
|
6537
|
+
var _classTokens = [scopedToken, stylesheetTokenHost];
|
|
6538
|
+
|
|
6539
|
+
var _classNames = ArrayFilter.call(_classTokens, function (token) {
|
|
6540
|
+
return !isNull(token);
|
|
6541
|
+
});
|
|
6542
|
+
|
|
6543
|
+
if (_classNames.length) {
|
|
6544
|
+
className = ArrayJoin.call(_classNames, ' ');
|
|
6545
|
+
}
|
|
6545
6546
|
}
|
|
6546
6547
|
}
|
|
6547
6548
|
|
|
@@ -6712,7 +6713,7 @@ var LWC = (function (exports) {
|
|
|
6712
6713
|
|
|
6713
6714
|
return ctor;
|
|
6714
6715
|
}
|
|
6715
|
-
/* version: 2.
|
|
6716
|
+
/* version: 2.27.0 */
|
|
6716
6717
|
|
|
6717
6718
|
/*
|
|
6718
6719
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6863,6 +6864,779 @@ var LWC = (function (exports) {
|
|
|
6863
6864
|
insertLocalStylesheet(content, target);
|
|
6864
6865
|
}
|
|
6865
6866
|
}
|
|
6867
|
+
/*
|
|
6868
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
6869
|
+
* All rights reserved.
|
|
6870
|
+
* SPDX-License-Identifier: MIT
|
|
6871
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6872
|
+
*/
|
|
6873
|
+
|
|
6874
|
+
|
|
6875
|
+
function isCustomElementRegistryAvailable() {
|
|
6876
|
+
if (typeof customElements === 'undefined') {
|
|
6877
|
+
return false;
|
|
6878
|
+
}
|
|
6879
|
+
|
|
6880
|
+
try {
|
|
6881
|
+
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
6882
|
+
// _wrapNativeSuper()
|
|
6883
|
+
// This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
|
|
6884
|
+
// get wrapped by babel.
|
|
6885
|
+
var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
|
|
6886
|
+
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
6887
|
+
// which are not equipped to be initialized that way.
|
|
6888
|
+
|
|
6889
|
+
var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
|
|
6890
|
+
_inherits(clazz, _HTMLElementAlias);
|
|
6891
|
+
|
|
6892
|
+
var _super6 = _createSuper(clazz);
|
|
6893
|
+
|
|
6894
|
+
function clazz() {
|
|
6895
|
+
_classCallCheck(this, clazz);
|
|
6896
|
+
|
|
6897
|
+
return _super6.apply(this, arguments);
|
|
6898
|
+
}
|
|
6899
|
+
|
|
6900
|
+
return _createClass(clazz);
|
|
6901
|
+
}(HTMLElementAlias);
|
|
6902
|
+
|
|
6903
|
+
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
6904
|
+
new clazz();
|
|
6905
|
+
return true;
|
|
6906
|
+
} catch (_a) {
|
|
6907
|
+
return false;
|
|
6908
|
+
}
|
|
6909
|
+
}
|
|
6910
|
+
|
|
6911
|
+
var hasCustomElements = isCustomElementRegistryAvailable();
|
|
6912
|
+
/*
|
|
6913
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6914
|
+
* All rights reserved.
|
|
6915
|
+
* SPDX-License-Identifier: MIT
|
|
6916
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6917
|
+
*/
|
|
6918
|
+
// Creates a custom element for compat (legacy) browser environments
|
|
6919
|
+
|
|
6920
|
+
var createCustomElementCompat = function createCustomElementCompat(tagName, upgradeCallback) {
|
|
6921
|
+
var elm = document.createElement(tagName);
|
|
6922
|
+
upgradeCallback(elm); // nothing to do with the result for now
|
|
6923
|
+
|
|
6924
|
+
return elm;
|
|
6925
|
+
};
|
|
6926
|
+
/*
|
|
6927
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6928
|
+
* All rights reserved.
|
|
6929
|
+
* SPDX-License-Identifier: MIT
|
|
6930
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6931
|
+
*/
|
|
6932
|
+
|
|
6933
|
+
|
|
6934
|
+
var cachedConstructors = new Map();
|
|
6935
|
+
var elementsUpgradedOutsideLWC = new WeakSet();
|
|
6936
|
+
var elementBeingUpgradedByLWC = false; // Creates a constructor that is intended to be used as a vanilla custom element, except that the upgradeCallback is
|
|
6937
|
+
// passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
|
|
6938
|
+
// Another benefit is that only LWC can create components that actually do anything – if you do
|
|
6939
|
+
// `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
|
|
6940
|
+
// This class should be created once per tag name.
|
|
6941
|
+
|
|
6942
|
+
var createUpgradableConstructor = function createUpgradableConstructor(_connectedCallback, _disconnectedCallback) {
|
|
6943
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
6944
|
+
return /*#__PURE__*/function (_HTMLElement) {
|
|
6945
|
+
_inherits(UpgradableConstructor, _HTMLElement);
|
|
6946
|
+
|
|
6947
|
+
var _super7 = _createSuper(UpgradableConstructor);
|
|
6948
|
+
|
|
6949
|
+
function UpgradableConstructor(upgradeCallback) {
|
|
6950
|
+
var _this5;
|
|
6951
|
+
|
|
6952
|
+
_classCallCheck(this, UpgradableConstructor);
|
|
6953
|
+
|
|
6954
|
+
_this5 = _super7.call(this); // If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
|
|
6955
|
+
// then elementBeingUpgraded will be false
|
|
6956
|
+
|
|
6957
|
+
if (elementBeingUpgradedByLWC) {
|
|
6958
|
+
upgradeCallback(_assertThisInitialized(_this5));
|
|
6959
|
+
} else {
|
|
6960
|
+
// keep track of elements that were not created by lwc.createElement,
|
|
6961
|
+
// so we can ignore their lifecycle hooks
|
|
6962
|
+
elementsUpgradedOutsideLWC.add(_assertThisInitialized(_this5)); // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
|
|
6963
|
+
// Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
|
|
6964
|
+
}
|
|
6965
|
+
|
|
6966
|
+
return _this5;
|
|
6967
|
+
}
|
|
6968
|
+
|
|
6969
|
+
_createClass(UpgradableConstructor, [{
|
|
6970
|
+
key: "connectedCallback",
|
|
6971
|
+
value: function connectedCallback() {
|
|
6972
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
6973
|
+
_connectedCallback(this);
|
|
6974
|
+
}
|
|
6975
|
+
}
|
|
6976
|
+
}, {
|
|
6977
|
+
key: "disconnectedCallback",
|
|
6978
|
+
value: function disconnectedCallback() {
|
|
6979
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
6980
|
+
_disconnectedCallback(this);
|
|
6981
|
+
}
|
|
6982
|
+
}
|
|
6983
|
+
}]);
|
|
6984
|
+
|
|
6985
|
+
return UpgradableConstructor;
|
|
6986
|
+
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
|
|
6987
|
+
};
|
|
6988
|
+
|
|
6989
|
+
var createCustomElementVanilla = function createCustomElementVanilla(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
6990
|
+
// use global custom elements registry
|
|
6991
|
+
var UpgradableConstructor = cachedConstructors.get(tagName);
|
|
6992
|
+
|
|
6993
|
+
if (isUndefined$1(UpgradableConstructor)) {
|
|
6994
|
+
if (!isUndefined$1(customElements.get(tagName))) {
|
|
6995
|
+
throw new Error("Unexpected tag name \"".concat(tagName, "\". This name is a registered custom element, preventing LWC to upgrade the element."));
|
|
6996
|
+
}
|
|
6997
|
+
|
|
6998
|
+
UpgradableConstructor = createUpgradableConstructor(connectedCallback, disconnectedCallback);
|
|
6999
|
+
customElements.define(tagName, UpgradableConstructor);
|
|
7000
|
+
cachedConstructors.set(tagName, UpgradableConstructor);
|
|
7001
|
+
}
|
|
7002
|
+
|
|
7003
|
+
elementBeingUpgradedByLWC = true;
|
|
7004
|
+
|
|
7005
|
+
try {
|
|
7006
|
+
return new UpgradableConstructor(upgradeCallback);
|
|
7007
|
+
} finally {
|
|
7008
|
+
elementBeingUpgradedByLWC = false;
|
|
7009
|
+
}
|
|
7010
|
+
};
|
|
7011
|
+
/*
|
|
7012
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
7013
|
+
* All rights reserved.
|
|
7014
|
+
* SPDX-License-Identifier: MIT
|
|
7015
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7016
|
+
*/
|
|
7017
|
+
|
|
7018
|
+
/**
|
|
7019
|
+
* Create a scoped registry, i.e. a function that can create custom elements whose tag names
|
|
7020
|
+
* do not conflict with vanilla custom elements having the same tag name.
|
|
7021
|
+
*/
|
|
7022
|
+
|
|
7023
|
+
|
|
7024
|
+
function createScopedRegistry() {
|
|
7025
|
+
if (!hasCustomElements) {
|
|
7026
|
+
// This code should never be reached, because we don't use the pivot registry if
|
|
7027
|
+
// custom elements are unavailable.
|
|
7028
|
+
throw new Error('Custom elements are not supported in this environment.');
|
|
7029
|
+
}
|
|
7030
|
+
|
|
7031
|
+
var _window = window,
|
|
7032
|
+
NativeHTMLElement = _window.HTMLElement;
|
|
7033
|
+
var _NativeHTMLElement$pr = NativeHTMLElement.prototype,
|
|
7034
|
+
nativeHasAttribute = _NativeHTMLElement$pr.hasAttribute,
|
|
7035
|
+
nativeSetAttribute = _NativeHTMLElement$pr.setAttribute,
|
|
7036
|
+
nativeRemoveAttribute = _NativeHTMLElement$pr.removeAttribute,
|
|
7037
|
+
nativeGetAttribute = _NativeHTMLElement$pr.getAttribute;
|
|
7038
|
+
var definitionForElement = new WeakMap();
|
|
7039
|
+
var pendingRegistryForElement = new WeakMap();
|
|
7040
|
+
var definitionForConstructor = new WeakMap();
|
|
7041
|
+
var registeredUserCtors = new WeakSet();
|
|
7042
|
+
var pivotCtorByTag = new Map();
|
|
7043
|
+
var globalDefinitionsByTag = new Map();
|
|
7044
|
+
var globalDefinitionsByClass = new Map();
|
|
7045
|
+
var awaitingUpgrade = new Map();
|
|
7046
|
+
var EMPTY_SET = new Set();
|
|
7047
|
+
|
|
7048
|
+
function createDefinitionRecord(constructor) {
|
|
7049
|
+
var _a;
|
|
7050
|
+
|
|
7051
|
+
var _constructor$prototyp = constructor.prototype,
|
|
7052
|
+
connectedCallback = _constructor$prototyp.connectedCallback,
|
|
7053
|
+
disconnectedCallback = _constructor$prototyp.disconnectedCallback,
|
|
7054
|
+
adoptedCallback = _constructor$prototyp.adoptedCallback,
|
|
7055
|
+
attributeChangedCallback = _constructor$prototyp.attributeChangedCallback;
|
|
7056
|
+
var observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
|
|
7057
|
+
return {
|
|
7058
|
+
UserCtor: constructor,
|
|
7059
|
+
PivotCtor: undefined,
|
|
7060
|
+
connectedCallback: connectedCallback,
|
|
7061
|
+
disconnectedCallback: disconnectedCallback,
|
|
7062
|
+
adoptedCallback: adoptedCallback,
|
|
7063
|
+
attributeChangedCallback: attributeChangedCallback,
|
|
7064
|
+
observedAttributes: observedAttributes
|
|
7065
|
+
};
|
|
7066
|
+
} // Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
|
|
7067
|
+
// element. Note that the `registeredDefinition` represents the constructor that was used to register during
|
|
7068
|
+
// `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
|
|
7069
|
+
// constructor is invoked with another constructor.
|
|
7070
|
+
|
|
7071
|
+
|
|
7072
|
+
function createPivotingClass(tagName, registeredDefinition) {
|
|
7073
|
+
var PivotCtor = /*#__PURE__*/function (_NativeHTMLElement) {
|
|
7074
|
+
_inherits(PivotCtor, _NativeHTMLElement);
|
|
7075
|
+
|
|
7076
|
+
var _super8 = _createSuper(PivotCtor);
|
|
7077
|
+
|
|
7078
|
+
function PivotCtor(UserCtor) {
|
|
7079
|
+
var _this6;
|
|
7080
|
+
|
|
7081
|
+
_classCallCheck(this, PivotCtor);
|
|
7082
|
+
|
|
7083
|
+
// This constructor can only be invoked by:
|
|
7084
|
+
// a) the browser instantiating an element from parsing or via document.createElement.
|
|
7085
|
+
// b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
|
|
7086
|
+
// b) new UserClass.
|
|
7087
|
+
// When LWC instantiates it, it will pass the upgrading definition as an argument
|
|
7088
|
+
// If the caller signals via UserCtor that this is in fact a controlled
|
|
7089
|
+
// definition, we use that one, otherwise fallback to the global
|
|
7090
|
+
// internal registry.
|
|
7091
|
+
_this6 = _super8.call(this);
|
|
7092
|
+
var userCtorIsDefined = !isUndefined$1(UserCtor);
|
|
7093
|
+
|
|
7094
|
+
if (userCtorIsDefined) {
|
|
7095
|
+
if (!isConstructor(UserCtor)) {
|
|
7096
|
+
throw new TypeError("Failed to create custom element: the provided constructor is not a constructor.");
|
|
7097
|
+
}
|
|
7098
|
+
|
|
7099
|
+
if (!registeredUserCtors.has(UserCtor)) {
|
|
7100
|
+
throw new Error("Failed to create custom element: the provided constructor is unregistered: ".concat(UserCtor.name, "."));
|
|
7101
|
+
}
|
|
7102
|
+
}
|
|
7103
|
+
|
|
7104
|
+
var definition = userCtorIsDefined ? getOrCreateDefinitionForConstructor(UserCtor) : globalDefinitionsByTag.get(tagName);
|
|
7105
|
+
|
|
7106
|
+
if (!isUndefined$1(definition)) {
|
|
7107
|
+
internalUpgrade(_assertThisInitialized(_this6), registeredDefinition, definition);
|
|
7108
|
+
} else {
|
|
7109
|
+
// This is the case in which there is no global definition, and
|
|
7110
|
+
// it is not handled by LWC (otherwise it will have a valid UserCtor)
|
|
7111
|
+
// so we need to add it to the pending queue just in case it eventually
|
|
7112
|
+
// gets defined in the global registry.
|
|
7113
|
+
pendingRegistryForElement.set(_assertThisInitialized(_this6), registeredDefinition);
|
|
7114
|
+
}
|
|
7115
|
+
|
|
7116
|
+
return _this6;
|
|
7117
|
+
}
|
|
7118
|
+
|
|
7119
|
+
_createClass(PivotCtor, [{
|
|
7120
|
+
key: "connectedCallback",
|
|
7121
|
+
value: function connectedCallback() {
|
|
7122
|
+
var _a;
|
|
7123
|
+
|
|
7124
|
+
var definition = definitionForElement.get(this);
|
|
7125
|
+
|
|
7126
|
+
if (!isUndefined$1(definition)) {
|
|
7127
|
+
// Delegate out to user callback
|
|
7128
|
+
(_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7129
|
+
} else {
|
|
7130
|
+
// Register for upgrade when defined (only when connected, so we don't leak)
|
|
7131
|
+
var awaiting = awaitingUpgrade.get(tagName);
|
|
7132
|
+
|
|
7133
|
+
if (isUndefined$1(awaiting)) {
|
|
7134
|
+
awaitingUpgrade.set(tagName, awaiting = new Set());
|
|
7135
|
+
}
|
|
7136
|
+
|
|
7137
|
+
awaiting.add(this);
|
|
7138
|
+
}
|
|
7139
|
+
}
|
|
7140
|
+
}, {
|
|
7141
|
+
key: "disconnectedCallback",
|
|
7142
|
+
value: function disconnectedCallback() {
|
|
7143
|
+
var _a;
|
|
7144
|
+
|
|
7145
|
+
var definition = definitionForElement.get(this);
|
|
7146
|
+
|
|
7147
|
+
if (!isUndefined$1(definition)) {
|
|
7148
|
+
// Delegate out to user callback
|
|
7149
|
+
(_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7150
|
+
} else {
|
|
7151
|
+
// Un-register for upgrade when defined (so we don't leak)
|
|
7152
|
+
var awaiting = awaitingUpgrade.get(tagName); // At this point, awaiting should never be undefined, because connectedCallback
|
|
7153
|
+
// must have been called before disconnectedCallback. But just to be safe, we check
|
|
7154
|
+
|
|
7155
|
+
if (!isUndefined$1(awaiting)) {
|
|
7156
|
+
awaiting.delete(this);
|
|
7157
|
+
}
|
|
7158
|
+
}
|
|
7159
|
+
}
|
|
7160
|
+
}, {
|
|
7161
|
+
key: "adoptedCallback",
|
|
7162
|
+
value: function adoptedCallback() {
|
|
7163
|
+
var _a;
|
|
7164
|
+
|
|
7165
|
+
var definition = definitionForElement.get(this);
|
|
7166
|
+
(_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7167
|
+
}
|
|
7168
|
+
}, {
|
|
7169
|
+
key: "attributeChangedCallback",
|
|
7170
|
+
value: function attributeChangedCallback(name, oldValue, newValue) {
|
|
7171
|
+
var _a;
|
|
7172
|
+
|
|
7173
|
+
var definition = definitionForElement.get(this); // if both definitions are the same, then the observedAttributes is the same,
|
|
7174
|
+
// but if they are different, only if the runtime definition has the attribute
|
|
7175
|
+
// marked as observed, then it should invoke attributeChangedCallback.
|
|
7176
|
+
|
|
7177
|
+
if (registeredDefinition === definition || (definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
|
|
7178
|
+
(_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
|
|
7179
|
+
}
|
|
7180
|
+
}
|
|
7181
|
+
}]);
|
|
7182
|
+
|
|
7183
|
+
return PivotCtor;
|
|
7184
|
+
}(NativeHTMLElement);
|
|
7185
|
+
|
|
7186
|
+
PivotCtor.observedAttributes = _toConsumableArray(registeredDefinition.observedAttributes);
|
|
7187
|
+
return PivotCtor;
|
|
7188
|
+
}
|
|
7189
|
+
|
|
7190
|
+
function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
|
|
7191
|
+
var observedAttributes = pivotDefinition.observedAttributes,
|
|
7192
|
+
attributeChangedCallback = pivotDefinition.attributeChangedCallback;
|
|
7193
|
+
|
|
7194
|
+
if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
|
|
7195
|
+
// This instance does not need to observe any attributes, no need to patch
|
|
7196
|
+
return EMPTY_SET;
|
|
7197
|
+
} // Natively, the attributes observed by the registered definition are going to be taken
|
|
7198
|
+
// care of by the browser, only the difference between the two sets has to be taken
|
|
7199
|
+
// care by the patched version.
|
|
7200
|
+
|
|
7201
|
+
|
|
7202
|
+
return new Set(_toConsumableArray(pivotDefinition.observedAttributes).filter(function (x) {
|
|
7203
|
+
return !registeredDefinition.observedAttributes.has(x);
|
|
7204
|
+
}));
|
|
7205
|
+
}
|
|
7206
|
+
|
|
7207
|
+
function throwAsyncError(error) {
|
|
7208
|
+
// Per native custom element behavior, errors thrown in attributeChangedCallback
|
|
7209
|
+
// become unhandled async errors. We use setTimeout() instead of Promise.resolve()
|
|
7210
|
+
// to make it an unhandled error rather than an unhandled rejection.
|
|
7211
|
+
setTimeout(function () {
|
|
7212
|
+
throw error;
|
|
7213
|
+
});
|
|
7214
|
+
} // Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
|
|
7215
|
+
// Why is this necessary? Well basically, you can't change the `observedAttributes` after
|
|
7216
|
+
// a custom element is defined. So with pivots, if two classes share the same tag name,
|
|
7217
|
+
// and the second class observes attributes that aren't observed by the first one,
|
|
7218
|
+
// then those attributes can never be observed by the native `observedAttributes` system.
|
|
7219
|
+
// So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
|
|
7220
|
+
// we only do this when absolutely necessary, though; i.e. because we've determined
|
|
7221
|
+
// that we aren't observing the attributes we need to.
|
|
7222
|
+
|
|
7223
|
+
|
|
7224
|
+
function patchAttributes(instance, registeredDefinition, pivotDefinition) {
|
|
7225
|
+
var newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
7226
|
+
|
|
7227
|
+
if (newObservedAttributes.size === 0) {
|
|
7228
|
+
return;
|
|
7229
|
+
}
|
|
7230
|
+
|
|
7231
|
+
var attributeChangedCallback = pivotDefinition.attributeChangedCallback; // Patch the instance.
|
|
7232
|
+
// Note we use the native `getAttribute` rather than the super's `getAttribute` because
|
|
7233
|
+
// we don't actually want it to be observable that we're calling `getAttribute` from
|
|
7234
|
+
// `setAttribute` and `removeAttribute`.
|
|
7235
|
+
// TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
|
|
7236
|
+
|
|
7237
|
+
defineProperties(instance, {
|
|
7238
|
+
setAttribute: {
|
|
7239
|
+
value: function setAttribute(name, value) {
|
|
7240
|
+
if (newObservedAttributes.has(name)) {
|
|
7241
|
+
var old = nativeGetAttribute.call(this, name);
|
|
7242
|
+
nativeSetAttribute.call(this, name, value);
|
|
7243
|
+
|
|
7244
|
+
try {
|
|
7245
|
+
attributeChangedCallback.call(this, name, old, value + '');
|
|
7246
|
+
} catch (error) {
|
|
7247
|
+
throwAsyncError(error);
|
|
7248
|
+
}
|
|
7249
|
+
} else {
|
|
7250
|
+
nativeSetAttribute.call(this, name, value);
|
|
7251
|
+
}
|
|
7252
|
+
},
|
|
7253
|
+
writable: true,
|
|
7254
|
+
enumerable: true,
|
|
7255
|
+
configurable: true
|
|
7256
|
+
},
|
|
7257
|
+
removeAttribute: {
|
|
7258
|
+
value: function removeAttribute(name) {
|
|
7259
|
+
if (newObservedAttributes.has(name)) {
|
|
7260
|
+
var old = nativeGetAttribute.call(this, name);
|
|
7261
|
+
nativeRemoveAttribute.call(this, name);
|
|
7262
|
+
|
|
7263
|
+
try {
|
|
7264
|
+
attributeChangedCallback.call(this, name, old, null);
|
|
7265
|
+
} catch (error) {
|
|
7266
|
+
throwAsyncError(error);
|
|
7267
|
+
}
|
|
7268
|
+
} else {
|
|
7269
|
+
nativeRemoveAttribute.call(this, name);
|
|
7270
|
+
}
|
|
7271
|
+
},
|
|
7272
|
+
writable: true,
|
|
7273
|
+
enumerable: true,
|
|
7274
|
+
configurable: true
|
|
7275
|
+
}
|
|
7276
|
+
});
|
|
7277
|
+
}
|
|
7278
|
+
|
|
7279
|
+
function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
7280
|
+
// The below case patches observed attributes for the case where the HTML element is upgraded
|
|
7281
|
+
// from a pre-existing one in the DOM.
|
|
7282
|
+
var newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
7283
|
+
|
|
7284
|
+
if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
|
|
7285
|
+
return;
|
|
7286
|
+
}
|
|
7287
|
+
|
|
7288
|
+
var attributeChangedCallback = pivotDefinition.attributeChangedCallback; // Approximate observedAttributes from the user class, but only for the new observed attributes
|
|
7289
|
+
|
|
7290
|
+
newObservedAttributes.forEach(function (name) {
|
|
7291
|
+
if (nativeHasAttribute.call(instance, name)) {
|
|
7292
|
+
var newValue = nativeGetAttribute.call(instance, name);
|
|
7293
|
+
attributeChangedCallback.call(instance, name, null, newValue);
|
|
7294
|
+
}
|
|
7295
|
+
});
|
|
7296
|
+
} // User extends this HTMLElement, which returns the CE being upgraded
|
|
7297
|
+
|
|
7298
|
+
|
|
7299
|
+
var upgradingInstance; // Helper to upgrade an instance with a CE definition using "constructor call trick"
|
|
7300
|
+
|
|
7301
|
+
function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
7302
|
+
setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
|
|
7303
|
+
definitionForElement.set(instance, pivotDefinition); // attributes patches when needed
|
|
7304
|
+
|
|
7305
|
+
if (pivotDefinition !== registeredDefinition) {
|
|
7306
|
+
patchAttributes(instance, registeredDefinition, pivotDefinition);
|
|
7307
|
+
} // Tricking the construction path to believe that a new instance is being created,
|
|
7308
|
+
// that way it will execute the super initialization mechanism but the HTMLElement
|
|
7309
|
+
// constructor will reuse the instance by returning the upgradingInstance.
|
|
7310
|
+
// This is by far the most important piece of the puzzle
|
|
7311
|
+
|
|
7312
|
+
|
|
7313
|
+
upgradingInstance = instance; // By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
|
|
7314
|
+
// The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
|
|
7315
|
+
// Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
|
|
7316
|
+
|
|
7317
|
+
new pivotDefinition.UserCtor();
|
|
7318
|
+
patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
|
|
7319
|
+
}
|
|
7320
|
+
|
|
7321
|
+
function isConstructor(constructor) {
|
|
7322
|
+
return isFunction$1(constructor) && isObject(constructor.prototype);
|
|
7323
|
+
}
|
|
7324
|
+
|
|
7325
|
+
function getOrCreateDefinitionForConstructor(constructor) {
|
|
7326
|
+
if (!isConstructor(constructor)) {
|
|
7327
|
+
throw new TypeError('The referenced constructor is not a constructor.');
|
|
7328
|
+
}
|
|
7329
|
+
|
|
7330
|
+
var definition = definitionForConstructor.get(constructor);
|
|
7331
|
+
|
|
7332
|
+
if (!isUndefined$1(definition)) {
|
|
7333
|
+
return definition;
|
|
7334
|
+
}
|
|
7335
|
+
|
|
7336
|
+
return createDefinitionRecord(constructor);
|
|
7337
|
+
}
|
|
7338
|
+
|
|
7339
|
+
var _window2 = window,
|
|
7340
|
+
nativeRegistry = _window2.customElements;
|
|
7341
|
+
var nativeDefine = nativeRegistry.define,
|
|
7342
|
+
nativeWhenDefined = nativeRegistry.whenDefined,
|
|
7343
|
+
nativeGet = nativeRegistry.get; // patch for the global registry define mechanism
|
|
7344
|
+
|
|
7345
|
+
CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
|
|
7346
|
+
if (options && options.extends) {
|
|
7347
|
+
// TODO [#2983]: should we support `extends`?
|
|
7348
|
+
throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
|
|
7349
|
+
}
|
|
7350
|
+
|
|
7351
|
+
if (globalDefinitionsByTag.has(tagName)) {
|
|
7352
|
+
throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': the name \"".concat(tagName, "\" has already been used with this registry"));
|
|
7353
|
+
}
|
|
7354
|
+
|
|
7355
|
+
if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
|
|
7356
|
+
throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry");
|
|
7357
|
+
}
|
|
7358
|
+
|
|
7359
|
+
var definition = getOrCreateDefinitionForConstructor(constructor);
|
|
7360
|
+
registeredUserCtors.add(constructor);
|
|
7361
|
+
var PivotCtor = pivotCtorByTag.get(tagName);
|
|
7362
|
+
|
|
7363
|
+
if (isUndefined$1(PivotCtor)) {
|
|
7364
|
+
PivotCtor = createPivotingClass(tagName, definition); // Register a pivoting class which will handle global registry initializations
|
|
7365
|
+
|
|
7366
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
7367
|
+
} // Only cache after nativeDefine has been called, because if it throws an error
|
|
7368
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
7369
|
+
|
|
7370
|
+
|
|
7371
|
+
definitionForConstructor.set(constructor, definition);
|
|
7372
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
7373
|
+
globalDefinitionsByTag.set(tagName, definition);
|
|
7374
|
+
globalDefinitionsByClass.set(constructor, definition); // For globally defined custom elements, the definition associated
|
|
7375
|
+
// to the UserCtor has a back-pointer to PivotCtor in case the user
|
|
7376
|
+
// new the UserCtor, so we know how to create the underlying element.
|
|
7377
|
+
|
|
7378
|
+
definition.PivotCtor = PivotCtor; // Upgrade any elements created in this scope before customElements.define
|
|
7379
|
+
// was called, which should be exhibited by the following steps:
|
|
7380
|
+
// 1) LWC registers a tagName for an LWC component.
|
|
7381
|
+
// 2) Element with same tagName is created with document.createElement()
|
|
7382
|
+
// and inserted into DOM.
|
|
7383
|
+
// 3) customElements.define() is called with tagName and non-LWC constructor.
|
|
7384
|
+
// This requires immediate upgrade when the new global tagName is defined.
|
|
7385
|
+
|
|
7386
|
+
var awaiting = awaitingUpgrade.get(tagName);
|
|
7387
|
+
|
|
7388
|
+
if (!isUndefined$1(awaiting)) {
|
|
7389
|
+
awaitingUpgrade.delete(tagName);
|
|
7390
|
+
|
|
7391
|
+
var _iterator6 = _createForOfIteratorHelper(awaiting),
|
|
7392
|
+
_step6;
|
|
7393
|
+
|
|
7394
|
+
try {
|
|
7395
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
7396
|
+
var element = _step6.value;
|
|
7397
|
+
var registeredDefinition = pendingRegistryForElement.get(element); // At this point, registeredDefinition should never be undefined because awaitingUpgrade
|
|
7398
|
+
// is only populated when we haven't run internalUpgrade yet, and we only populate
|
|
7399
|
+
// pendingRegistryForElement when internalUpgrade hasn't run yet.
|
|
7400
|
+
// But just to be safe, we check.
|
|
7401
|
+
|
|
7402
|
+
if (!isUndefined$1(registeredDefinition)) {
|
|
7403
|
+
pendingRegistryForElement.delete(element);
|
|
7404
|
+
internalUpgrade(element, registeredDefinition, definition);
|
|
7405
|
+
}
|
|
7406
|
+
}
|
|
7407
|
+
} catch (err) {
|
|
7408
|
+
_iterator6.e(err);
|
|
7409
|
+
} finally {
|
|
7410
|
+
_iterator6.f();
|
|
7411
|
+
}
|
|
7412
|
+
}
|
|
7413
|
+
};
|
|
7414
|
+
|
|
7415
|
+
CustomElementRegistry.prototype.get = function get(tagName) {
|
|
7416
|
+
var NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
7417
|
+
|
|
7418
|
+
if (!isUndefined$1(NativeCtor)) {
|
|
7419
|
+
var definition = globalDefinitionsByTag.get(tagName);
|
|
7420
|
+
|
|
7421
|
+
if (!isUndefined$1(definition)) {
|
|
7422
|
+
return definition.UserCtor; // defined by the patched custom elements registry
|
|
7423
|
+
} // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
7424
|
+
|
|
7425
|
+
|
|
7426
|
+
return NativeCtor; // return the pivot constructor or constructor that existed before patching
|
|
7427
|
+
}
|
|
7428
|
+
};
|
|
7429
|
+
|
|
7430
|
+
CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
|
|
7431
|
+
return nativeWhenDefined.call(nativeRegistry, tagName).then(function (NativeCtor) {
|
|
7432
|
+
var definition = globalDefinitionsByTag.get(tagName);
|
|
7433
|
+
|
|
7434
|
+
if (!isUndefined$1(definition)) {
|
|
7435
|
+
return definition.UserCtor;
|
|
7436
|
+
} // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
7437
|
+
// In this case, the custom element must have been defined before the registry patches
|
|
7438
|
+
// were applied. So return the non-pivot constructor
|
|
7439
|
+
|
|
7440
|
+
|
|
7441
|
+
if (isUndefined$1(NativeCtor)) {
|
|
7442
|
+
// Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
|
|
7443
|
+
// We can patch the correct behavior using customElements.get()
|
|
7444
|
+
return nativeGet.call(nativeRegistry, tagName);
|
|
7445
|
+
}
|
|
7446
|
+
|
|
7447
|
+
return NativeCtor;
|
|
7448
|
+
});
|
|
7449
|
+
}; // This constructor is invoked when we call `new pivotDefinition.UserCtor()`
|
|
7450
|
+
// @ts-ignore
|
|
7451
|
+
|
|
7452
|
+
|
|
7453
|
+
window.HTMLElement = function HTMLElement() {
|
|
7454
|
+
// Upgrading case: the pivoting class constructor was run by the browser's
|
|
7455
|
+
// native custom elements and we're in the process of running the
|
|
7456
|
+
// "constructor-call trick" on the natively constructed instance, so just
|
|
7457
|
+
// return that here.
|
|
7458
|
+
// This code path is also called when LWC `new`s a PivotCtor.
|
|
7459
|
+
var instance = upgradingInstance;
|
|
7460
|
+
|
|
7461
|
+
if (!isUndefined$1(instance)) {
|
|
7462
|
+
upgradingInstance = undefined;
|
|
7463
|
+
return instance;
|
|
7464
|
+
} // Construction case: we need to construct the pivoting instance and return it.
|
|
7465
|
+
// This is possible when the user register it via global registry and instantiate
|
|
7466
|
+
// it via `new Ctor()`.
|
|
7467
|
+
|
|
7468
|
+
|
|
7469
|
+
var constructor = this.constructor;
|
|
7470
|
+
var definition = globalDefinitionsByClass.get(constructor);
|
|
7471
|
+
|
|
7472
|
+
if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
|
|
7473
|
+
// This code path is hit if someone `new`s a class that extends `HTMLElement` without
|
|
7474
|
+
// doing `customElements.define()` first. This matches native browser behavior:
|
|
7475
|
+
// https://stackoverflow.com/a/61883392
|
|
7476
|
+
throw new TypeError('Illegal constructor');
|
|
7477
|
+
} // This constructor is ONLY invoked when it is the user instantiating
|
|
7478
|
+
// an element via new Ctor while Ctor is a registered global constructor.
|
|
7479
|
+
|
|
7480
|
+
|
|
7481
|
+
var PivotCtor = definition.PivotCtor,
|
|
7482
|
+
UserCtor = definition.UserCtor;
|
|
7483
|
+
return new PivotCtor(UserCtor);
|
|
7484
|
+
};
|
|
7485
|
+
|
|
7486
|
+
HTMLElement.prototype = NativeHTMLElement.prototype;
|
|
7487
|
+
/**
|
|
7488
|
+
* Create a new PivotConstructor for the given tagName, which is capable of being constructed
|
|
7489
|
+
* with a UserConstructor defining the behavior. Passing in the UserConstructor here
|
|
7490
|
+
* is a hint that can be used when registering a custom element with the global custom elements
|
|
7491
|
+
* registry for the first time, which provides certain optimizations. It also marks the UserConstructor
|
|
7492
|
+
* as "safe" to be used when passed in to a PivotConstructor.
|
|
7493
|
+
*
|
|
7494
|
+
* @param tagName - element tag name
|
|
7495
|
+
* @param UserCtor - userland custom element constructor
|
|
7496
|
+
* @returns a new custom element constructor
|
|
7497
|
+
*/
|
|
7498
|
+
|
|
7499
|
+
return function createPivotConstructor(tagName, UserCtor) {
|
|
7500
|
+
tagName = StringToLowerCase.call(tagName);
|
|
7501
|
+
var PivotCtor = pivotCtorByTag.get(tagName);
|
|
7502
|
+
|
|
7503
|
+
if (isUndefined$1(PivotCtor)) {
|
|
7504
|
+
var definition = getOrCreateDefinitionForConstructor(UserCtor);
|
|
7505
|
+
PivotCtor = createPivotingClass(tagName, definition); // Register a pivoting class as a global custom element
|
|
7506
|
+
|
|
7507
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
7508
|
+
definition.PivotCtor = PivotCtor; // Only cache after nativeDefine has been called, because if it throws an error
|
|
7509
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
7510
|
+
|
|
7511
|
+
definitionForConstructor.set(UserCtor, definition);
|
|
7512
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
7513
|
+
} // Register a UserConstructor as "safe" to be used within a PivotConstructor
|
|
7514
|
+
|
|
7515
|
+
|
|
7516
|
+
registeredUserCtors.add(UserCtor);
|
|
7517
|
+
return PivotCtor;
|
|
7518
|
+
};
|
|
7519
|
+
}
|
|
7520
|
+
/*
|
|
7521
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7522
|
+
* All rights reserved.
|
|
7523
|
+
* SPDX-License-Identifier: MIT
|
|
7524
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7525
|
+
*/
|
|
7526
|
+
|
|
7527
|
+
|
|
7528
|
+
var createScopedConstructor;
|
|
7529
|
+
var CachedHTMLElement; // We only call `createScopedRegistry()` if the browser supports custom elements and
|
|
7530
|
+
// ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
|
|
7531
|
+
// or we're in a legacy browser.
|
|
7532
|
+
|
|
7533
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
7534
|
+
if (hasCustomElements) {
|
|
7535
|
+
// If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
|
|
7536
|
+
// It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
|
|
7537
|
+
//
|
|
7538
|
+
// Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
|
|
7539
|
+
//
|
|
7540
|
+
// 1. LWC loads
|
|
7541
|
+
// 2. `const Ctor = class extends HTMLElement {}`
|
|
7542
|
+
// 3. `lwc.createElement(...)` // here we lazily patch
|
|
7543
|
+
// 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
|
|
7544
|
+
//
|
|
7545
|
+
// To reduce the risk of this, it's safer to patch the registry eagerly.
|
|
7546
|
+
createScopedConstructor = createScopedRegistry(); // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
|
|
7547
|
+
// another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
|
|
7548
|
+
// because the HTMLElement prototypes are mixed up.
|
|
7549
|
+
//
|
|
7550
|
+
// The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
|
|
7551
|
+
// with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
|
|
7552
|
+
// the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
|
|
7553
|
+
// Caching avoids this problem.
|
|
7554
|
+
|
|
7555
|
+
CachedHTMLElement = window.HTMLElement;
|
|
7556
|
+
}
|
|
7557
|
+
} // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
|
|
7558
|
+
// In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
|
|
7559
|
+
// multiple times per tag name.
|
|
7560
|
+
|
|
7561
|
+
|
|
7562
|
+
var createUserConstructor = function createUserConstructor(upgradeCallback, _connectedCallback2, _disconnectedCallback2, HTMLElementToExtend) {
|
|
7563
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
7564
|
+
return /*#__PURE__*/function (_HTMLElementToExtend) {
|
|
7565
|
+
_inherits(UserConstructor, _HTMLElementToExtend);
|
|
7566
|
+
|
|
7567
|
+
var _super9 = _createSuper(UserConstructor);
|
|
7568
|
+
|
|
7569
|
+
function UserConstructor() {
|
|
7570
|
+
var _this7;
|
|
7571
|
+
|
|
7572
|
+
_classCallCheck(this, UserConstructor);
|
|
7573
|
+
|
|
7574
|
+
_this7 = _super9.call(this);
|
|
7575
|
+
upgradeCallback(_assertThisInitialized(_this7));
|
|
7576
|
+
return _this7;
|
|
7577
|
+
}
|
|
7578
|
+
|
|
7579
|
+
_createClass(UserConstructor, [{
|
|
7580
|
+
key: "connectedCallback",
|
|
7581
|
+
value: function connectedCallback() {
|
|
7582
|
+
_connectedCallback2(this);
|
|
7583
|
+
}
|
|
7584
|
+
}, {
|
|
7585
|
+
key: "disconnectedCallback",
|
|
7586
|
+
value: function disconnectedCallback() {
|
|
7587
|
+
_disconnectedCallback2(this);
|
|
7588
|
+
}
|
|
7589
|
+
}]);
|
|
7590
|
+
|
|
7591
|
+
return UserConstructor;
|
|
7592
|
+
}(HTMLElementToExtend);
|
|
7593
|
+
};
|
|
7594
|
+
|
|
7595
|
+
function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
7596
|
+
if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
|
|
7597
|
+
// This error should be impossible to hit
|
|
7598
|
+
throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
|
|
7599
|
+
}
|
|
7600
|
+
|
|
7601
|
+
var UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
|
|
7602
|
+
var ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
|
|
7603
|
+
return new ScopedConstructor(UserConstructor);
|
|
7604
|
+
}
|
|
7605
|
+
/*
|
|
7606
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7607
|
+
* All rights reserved.
|
|
7608
|
+
* SPDX-License-Identifier: MIT
|
|
7609
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7610
|
+
*/
|
|
7611
|
+
|
|
7612
|
+
/**
|
|
7613
|
+
* We have three modes for creating custom elements:
|
|
7614
|
+
*
|
|
7615
|
+
* 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
|
|
7616
|
+
* 2. "Vanilla" custom elements registry. This system actually still allows us to have two LWC components with the
|
|
7617
|
+
* same tag name, via a simple trick: every custom element constructor we define in the registry is basically
|
|
7618
|
+
* the same. It's essentially a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its
|
|
7619
|
+
* constructor, which allows us to have completely customized functionality for different components.
|
|
7620
|
+
* 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
|
|
7621
|
+
* elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
|
|
7622
|
+
* between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
|
|
7623
|
+
* because it must patch the global `customElements` and `HTMLElement` objects.
|
|
7624
|
+
*/
|
|
7625
|
+
|
|
7626
|
+
|
|
7627
|
+
var createCustomElement;
|
|
7628
|
+
|
|
7629
|
+
if (hasCustomElements) {
|
|
7630
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
7631
|
+
createCustomElement = createCustomElementScoped;
|
|
7632
|
+
} else {
|
|
7633
|
+
// use global custom elements registry (vanilla)
|
|
7634
|
+
createCustomElement = createCustomElementVanilla;
|
|
7635
|
+
}
|
|
7636
|
+
} else {
|
|
7637
|
+
// no registry available here
|
|
7638
|
+
createCustomElement = createCustomElementCompat;
|
|
7639
|
+
}
|
|
6866
7640
|
/*
|
|
6867
7641
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
6868
7642
|
* All rights reserved.
|
|
@@ -6931,7 +7705,7 @@ var LWC = (function (exports) {
|
|
|
6931
7705
|
function isNull(obj) {
|
|
6932
7706
|
return obj === null;
|
|
6933
7707
|
}
|
|
6934
|
-
/** version: 2.
|
|
7708
|
+
/** version: 2.27.0 */
|
|
6935
7709
|
|
|
6936
7710
|
/*
|
|
6937
7711
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6941,87 +7715,6 @@ var LWC = (function (exports) {
|
|
|
6941
7715
|
*/
|
|
6942
7716
|
|
|
6943
7717
|
|
|
6944
|
-
exports.getCustomElement = void 0;
|
|
6945
|
-
exports.defineCustomElement = void 0;
|
|
6946
|
-
var HTMLElementConstructor;
|
|
6947
|
-
|
|
6948
|
-
function isCustomElementRegistryAvailable() {
|
|
6949
|
-
if (typeof customElements === 'undefined') {
|
|
6950
|
-
return false;
|
|
6951
|
-
}
|
|
6952
|
-
|
|
6953
|
-
try {
|
|
6954
|
-
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
6955
|
-
// _wrapNativeSuper()
|
|
6956
|
-
// This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
|
|
6957
|
-
// get wrapped by babel.
|
|
6958
|
-
var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
|
|
6959
|
-
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
6960
|
-
// which are not equipped to be initialized that way.
|
|
6961
|
-
|
|
6962
|
-
var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
|
|
6963
|
-
_inherits(clazz, _HTMLElementAlias);
|
|
6964
|
-
|
|
6965
|
-
var _super7 = _createSuper(clazz);
|
|
6966
|
-
|
|
6967
|
-
function clazz() {
|
|
6968
|
-
_classCallCheck(this, clazz);
|
|
6969
|
-
|
|
6970
|
-
return _super7.apply(this, arguments);
|
|
6971
|
-
}
|
|
6972
|
-
|
|
6973
|
-
return _createClass(clazz);
|
|
6974
|
-
}(HTMLElementAlias);
|
|
6975
|
-
|
|
6976
|
-
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
6977
|
-
new clazz();
|
|
6978
|
-
return true;
|
|
6979
|
-
} catch (_a) {
|
|
6980
|
-
return false;
|
|
6981
|
-
}
|
|
6982
|
-
}
|
|
6983
|
-
|
|
6984
|
-
if (isCustomElementRegistryAvailable()) {
|
|
6985
|
-
exports.getCustomElement = customElements.get.bind(customElements);
|
|
6986
|
-
exports.defineCustomElement = customElements.define.bind(customElements);
|
|
6987
|
-
HTMLElementConstructor = HTMLElement;
|
|
6988
|
-
} else {
|
|
6989
|
-
var registry = Object.create(null);
|
|
6990
|
-
var reverseRegistry = new WeakMap();
|
|
6991
|
-
|
|
6992
|
-
exports.defineCustomElement = function define(name, ctor) {
|
|
6993
|
-
if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
|
|
6994
|
-
throw new TypeError("Invalid Registration");
|
|
6995
|
-
}
|
|
6996
|
-
|
|
6997
|
-
registry[name] = ctor;
|
|
6998
|
-
reverseRegistry.set(ctor, name);
|
|
6999
|
-
};
|
|
7000
|
-
|
|
7001
|
-
exports.getCustomElement = function get(name) {
|
|
7002
|
-
return registry[name];
|
|
7003
|
-
};
|
|
7004
|
-
|
|
7005
|
-
HTMLElementConstructor = function HTMLElement() {
|
|
7006
|
-
if (!(this instanceof HTMLElement)) {
|
|
7007
|
-
throw new TypeError("Invalid Invocation");
|
|
7008
|
-
}
|
|
7009
|
-
|
|
7010
|
-
var constructor = this.constructor;
|
|
7011
|
-
var name = reverseRegistry.get(constructor);
|
|
7012
|
-
|
|
7013
|
-
if (!name) {
|
|
7014
|
-
throw new TypeError("Invalid Construction");
|
|
7015
|
-
}
|
|
7016
|
-
|
|
7017
|
-
var elm = document.createElement(name);
|
|
7018
|
-
Object.setPrototypeOf(elm, constructor.prototype);
|
|
7019
|
-
return elm;
|
|
7020
|
-
};
|
|
7021
|
-
|
|
7022
|
-
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
7023
|
-
}
|
|
7024
|
-
|
|
7025
7718
|
function cloneNode(node, deep) {
|
|
7026
7719
|
return node.cloneNode(deep);
|
|
7027
7720
|
}
|
|
@@ -7080,18 +7773,18 @@ var LWC = (function (exports) {
|
|
|
7080
7773
|
var wrapperTags = topLevelWrappingMap[getTagName(html)];
|
|
7081
7774
|
|
|
7082
7775
|
if (!isUndefined(wrapperTags)) {
|
|
7083
|
-
var
|
|
7084
|
-
|
|
7776
|
+
var _iterator7 = _createForOfIteratorHelper(wrapperTags),
|
|
7777
|
+
_step7;
|
|
7085
7778
|
|
|
7086
7779
|
try {
|
|
7087
|
-
for (
|
|
7088
|
-
var wrapperTag =
|
|
7780
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
7781
|
+
var wrapperTag = _step7.value;
|
|
7089
7782
|
html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
|
|
7090
7783
|
}
|
|
7091
7784
|
} catch (err) {
|
|
7092
|
-
|
|
7785
|
+
_iterator7.e(err);
|
|
7093
7786
|
} finally {
|
|
7094
|
-
|
|
7787
|
+
_iterator7.f();
|
|
7095
7788
|
}
|
|
7096
7789
|
} // For IE11, the document title must not be undefined, but it can be an empty string
|
|
7097
7790
|
// https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
|
|
@@ -7237,8 +7930,6 @@ var LWC = (function (exports) {
|
|
|
7237
7930
|
assert.invariant(elm instanceof HTMLElement, msg);
|
|
7238
7931
|
}
|
|
7239
7932
|
|
|
7240
|
-
var HTMLElementExported = HTMLElementConstructor;
|
|
7241
|
-
exports.HTMLElementExported = HTMLElementExported;
|
|
7242
7933
|
exports.addEventListener = addEventListener;
|
|
7243
7934
|
exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
|
|
7244
7935
|
exports.attachShadow = attachShadow;
|
|
@@ -7297,6 +7988,8 @@ var LWC = (function (exports) {
|
|
|
7297
7988
|
{
|
|
7298
7989
|
// insertStyleSheet implementation shares a global cache of stylesheet data
|
|
7299
7990
|
insertStylesheet: insertStylesheet,
|
|
7991
|
+
// relies on a shared global cache
|
|
7992
|
+
createCustomElement: createCustomElement,
|
|
7300
7993
|
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
7301
7994
|
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN)
|
|
7302
7995
|
});
|
|
@@ -7413,35 +8106,39 @@ var LWC = (function (exports) {
|
|
|
7413
8106
|
var hydratedCustomElements = new WeakSet();
|
|
7414
8107
|
|
|
7415
8108
|
function buildCustomElementConstructor(Ctor) {
|
|
8109
|
+
var _a;
|
|
8110
|
+
|
|
7416
8111
|
var HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
7417
|
-
|
|
7418
|
-
|
|
8112
|
+
var observedAttributes = HtmlPrototype.observedAttributes;
|
|
8113
|
+
var _attributeChangedCallback = HtmlPrototype.prototype.attributeChangedCallback;
|
|
8114
|
+
return _a = /*#__PURE__*/function (_HTMLElement2) {
|
|
8115
|
+
_inherits(_a, _HTMLElement2);
|
|
7419
8116
|
|
|
7420
|
-
var
|
|
8117
|
+
var _super10 = _createSuper(_a);
|
|
7421
8118
|
|
|
7422
|
-
function
|
|
7423
|
-
var
|
|
8119
|
+
function _a() {
|
|
8120
|
+
var _this8;
|
|
7424
8121
|
|
|
7425
|
-
_classCallCheck(this,
|
|
8122
|
+
_classCallCheck(this, _a);
|
|
7426
8123
|
|
|
7427
|
-
|
|
8124
|
+
_this8 = _super10.call(this);
|
|
7428
8125
|
|
|
7429
|
-
if (
|
|
8126
|
+
if (_this8.isConnected) {
|
|
7430
8127
|
// this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
|
|
7431
|
-
hydrateComponent(_assertThisInitialized(
|
|
7432
|
-
hydratedCustomElements.add(_assertThisInitialized(
|
|
8128
|
+
hydrateComponent(_assertThisInitialized(_this8), Ctor, {});
|
|
8129
|
+
hydratedCustomElements.add(_assertThisInitialized(_this8));
|
|
7433
8130
|
} else {
|
|
7434
|
-
createVM(_assertThisInitialized(
|
|
8131
|
+
createVM(_assertThisInitialized(_this8), Ctor, renderer, {
|
|
7435
8132
|
mode: 'open',
|
|
7436
8133
|
owner: null,
|
|
7437
|
-
tagName:
|
|
8134
|
+
tagName: _this8.tagName
|
|
7438
8135
|
});
|
|
7439
8136
|
}
|
|
7440
8137
|
|
|
7441
|
-
return
|
|
8138
|
+
return _this8;
|
|
7442
8139
|
}
|
|
7443
8140
|
|
|
7444
|
-
_createClass(
|
|
8141
|
+
_createClass(_a, [{
|
|
7445
8142
|
key: "connectedCallback",
|
|
7446
8143
|
value: function connectedCallback() {
|
|
7447
8144
|
if (hydratedCustomElements.has(this)) {
|
|
@@ -7456,10 +8153,15 @@ var LWC = (function (exports) {
|
|
|
7456
8153
|
value: function disconnectedCallback() {
|
|
7457
8154
|
disconnectRootElement(this);
|
|
7458
8155
|
}
|
|
8156
|
+
}, {
|
|
8157
|
+
key: "attributeChangedCallback",
|
|
8158
|
+
value: function attributeChangedCallback(name, oldValue, newValue) {
|
|
8159
|
+
_attributeChangedCallback.call(this, name, oldValue, newValue);
|
|
8160
|
+
}
|
|
7459
8161
|
}]);
|
|
7460
8162
|
|
|
7461
|
-
return
|
|
7462
|
-
}(
|
|
8163
|
+
return _a;
|
|
8164
|
+
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement)), _a.observedAttributes = observedAttributes, _a;
|
|
7463
8165
|
}
|
|
7464
8166
|
/*
|
|
7465
8167
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7542,8 +8244,11 @@ var LWC = (function (exports) {
|
|
|
7542
8244
|
throw new TypeError("\"createElement\" function expects an \"is\" option with a valid component constructor.");
|
|
7543
8245
|
}
|
|
7544
8246
|
|
|
7545
|
-
var
|
|
7546
|
-
|
|
8247
|
+
var createCustomElement = renderer.createCustomElement; // tagName must be all lowercase, unfortunately, we have legacy code that is
|
|
8248
|
+
// passing `sel` as a camel-case, which makes them invalid custom elements name
|
|
8249
|
+
// the following line guarantees that this does not leaks beyond this point.
|
|
8250
|
+
|
|
8251
|
+
var tagName = StringToLowerCase.call(sel); // the custom element from the registry is expecting an upgrade callback
|
|
7547
8252
|
|
|
7548
8253
|
/**
|
|
7549
8254
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
@@ -7552,9 +8257,9 @@ var LWC = (function (exports) {
|
|
|
7552
8257
|
* an upgradable custom element.
|
|
7553
8258
|
*/
|
|
7554
8259
|
|
|
7555
|
-
var
|
|
8260
|
+
var upgradeCallback = function upgradeCallback(elm) {
|
|
7556
8261
|
createVM(elm, Ctor, renderer, {
|
|
7557
|
-
tagName:
|
|
8262
|
+
tagName: tagName,
|
|
7558
8263
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
7559
8264
|
owner: null
|
|
7560
8265
|
});
|
|
@@ -7563,15 +8268,21 @@ var LWC = (function (exports) {
|
|
|
7563
8268
|
ConnectingSlot.set(elm, connectRootElement);
|
|
7564
8269
|
DisconnectingSlot.set(elm, disconnectRootElement);
|
|
7565
8270
|
}
|
|
8271
|
+
};
|
|
7566
8272
|
|
|
7567
|
-
|
|
7568
|
-
|
|
8273
|
+
var connectedCallback = function connectedCallback(elm) {
|
|
8274
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8275
|
+
connectRootElement(elm);
|
|
8276
|
+
}
|
|
8277
|
+
};
|
|
7569
8278
|
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
8279
|
+
var disconnectedCallback = function disconnectedCallback(elm) {
|
|
8280
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8281
|
+
disconnectRootElement(elm);
|
|
8282
|
+
}
|
|
8283
|
+
};
|
|
7574
8284
|
|
|
8285
|
+
var element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
7575
8286
|
return element;
|
|
7576
8287
|
}
|
|
7577
8288
|
/*
|
|
@@ -7654,7 +8365,7 @@ var LWC = (function (exports) {
|
|
|
7654
8365
|
});
|
|
7655
8366
|
freeze(LightningElement);
|
|
7656
8367
|
seal(LightningElement.prototype);
|
|
7657
|
-
/* version: 2.
|
|
8368
|
+
/* version: 2.27.0 */
|
|
7658
8369
|
|
|
7659
8370
|
exports.LightningElement = LightningElement;
|
|
7660
8371
|
exports.__unstable__ProfilerControl = profilerControl;
|