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