lwc 2.25.1 → 2.26.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 +885 -411
- package/dist/engine-dom/iife/es2017/engine-dom.js +885 -411
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +731 -205
- package/dist/engine-dom/iife/es5/engine-dom.js +954 -311
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +883 -224
- package/dist/engine-dom/umd/es2017/engine-dom.js +885 -411
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +731 -205
- package/dist/engine-dom/umd/es5/engine-dom.js +954 -311
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +883 -224
- package/dist/engine-server/commonjs/es2017/engine-server.js +133 -227
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +133 -227
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
- 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 +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
- 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,7 @@
|
|
|
123
123
|
setPrototypeOf = Object.setPrototypeOf;
|
|
124
124
|
var isArray$1 = Array.isArray;
|
|
125
125
|
var _Array$prototype = Array.prototype,
|
|
126
|
+
ArrayFilter = _Array$prototype.filter,
|
|
126
127
|
ArrayIndexOf = _Array$prototype.indexOf,
|
|
127
128
|
ArrayJoin = _Array$prototype.join,
|
|
128
129
|
ArrayMap = _Array$prototype.map,
|
|
@@ -349,7 +350,7 @@
|
|
|
349
350
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
350
351
|
return attributeName;
|
|
351
352
|
}
|
|
352
|
-
/** version: 2.
|
|
353
|
+
/** version: 2.26.0 */
|
|
353
354
|
|
|
354
355
|
/**
|
|
355
356
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -443,7 +444,7 @@
|
|
|
443
444
|
patch$1(propName);
|
|
444
445
|
}
|
|
445
446
|
}
|
|
446
|
-
/** version: 2.
|
|
447
|
+
/** version: 2.26.0 */
|
|
447
448
|
|
|
448
449
|
/**
|
|
449
450
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -461,7 +462,6 @@
|
|
|
461
462
|
DUMMY_TEST_FLAG: null,
|
|
462
463
|
ENABLE_ELEMENT_PATCH: null,
|
|
463
464
|
ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
|
|
464
|
-
ENABLE_HMR: null,
|
|
465
465
|
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
466
466
|
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
467
467
|
ENABLE_MIXED_SHADOW_MODE: null,
|
|
@@ -471,7 +471,8 @@
|
|
|
471
471
|
ENABLE_REACTIVE_SETTER: null,
|
|
472
472
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
473
473
|
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
474
|
-
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null
|
|
474
|
+
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
475
|
+
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null
|
|
475
476
|
};
|
|
476
477
|
|
|
477
478
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
@@ -1797,7 +1798,9 @@
|
|
|
1797
1798
|
var LightningElement = function LightningElement() {
|
|
1798
1799
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
1799
1800
|
if (isNull(vmBeingConstructed)) {
|
|
1800
|
-
|
|
1801
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1802
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1803
|
+
throw new TypeError('Illegal constructor');
|
|
1801
1804
|
}
|
|
1802
1805
|
|
|
1803
1806
|
var vm = vmBeingConstructed;
|
|
@@ -2769,33 +2772,21 @@
|
|
|
2769
2772
|
{
|
|
2770
2773
|
// this method should never leak to prod
|
|
2771
2774
|
throw new ReferenceError();
|
|
2772
|
-
}
|
|
2775
|
+
} // tracking active component
|
|
2773
2776
|
}
|
|
2774
2777
|
|
|
2775
2778
|
function swapTemplate(oldTpl, newTpl) {
|
|
2776
2779
|
|
|
2777
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2778
|
-
throw new Error('HMR is not enabled');
|
|
2779
|
-
}
|
|
2780
|
-
|
|
2781
2780
|
return false;
|
|
2782
2781
|
}
|
|
2783
2782
|
|
|
2784
2783
|
function swapComponent(oldComponent, newComponent) {
|
|
2785
2784
|
|
|
2786
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2787
|
-
throw new Error('HMR is not enabled');
|
|
2788
|
-
}
|
|
2789
|
-
|
|
2790
2785
|
return false;
|
|
2791
2786
|
}
|
|
2792
2787
|
|
|
2793
2788
|
function swapStyle(oldStyle, newStyle) {
|
|
2794
2789
|
|
|
2795
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2796
|
-
throw new Error('HMR is not enabled');
|
|
2797
|
-
}
|
|
2798
|
-
|
|
2799
2790
|
return false;
|
|
2800
2791
|
}
|
|
2801
2792
|
/*
|
|
@@ -3221,14 +3212,17 @@
|
|
|
3221
3212
|
/**
|
|
3222
3213
|
* This function returns the host style token for a custom element if it
|
|
3223
3214
|
* exists. Otherwise it returns null.
|
|
3215
|
+
*
|
|
3216
|
+
* A host style token is applied to the component if scoped styles are used.
|
|
3224
3217
|
*/
|
|
3225
3218
|
|
|
3226
3219
|
|
|
3227
3220
|
function getStylesheetTokenHost(vnode) {
|
|
3228
3221
|
var _getComponentInternal = getComponentInternalDef(vnode.ctor),
|
|
3229
|
-
|
|
3222
|
+
template = _getComponentInternal.template;
|
|
3230
3223
|
|
|
3231
|
-
|
|
3224
|
+
var stylesheetToken = template.stylesheetToken;
|
|
3225
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
3232
3226
|
}
|
|
3233
3227
|
|
|
3234
3228
|
function getNearestNativeShadowComponent(vm) {
|
|
@@ -3277,78 +3271,6 @@
|
|
|
3277
3271
|
|
|
3278
3272
|
return null;
|
|
3279
3273
|
}
|
|
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
3274
|
/*
|
|
3353
3275
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3354
3276
|
* All rights reserved.
|
|
@@ -3881,7 +3803,7 @@
|
|
|
3881
3803
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3882
3804
|
var sel = vnode.sel,
|
|
3883
3805
|
owner = vnode.owner;
|
|
3884
|
-
var
|
|
3806
|
+
var createCustomElement = renderer.createCustomElement;
|
|
3885
3807
|
/**
|
|
3886
3808
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3887
3809
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -3890,10 +3812,25 @@
|
|
|
3890
3812
|
*/
|
|
3891
3813
|
|
|
3892
3814
|
var vm;
|
|
3893
|
-
|
|
3815
|
+
|
|
3816
|
+
var upgradeCallback = function upgradeCallback(elm) {
|
|
3894
3817
|
// the custom element from the registry is expecting an upgrade callback
|
|
3895
3818
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
3896
|
-
}
|
|
3819
|
+
};
|
|
3820
|
+
|
|
3821
|
+
var connectedCallback = function connectedCallback(elm) {
|
|
3822
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3823
|
+
connectRootElement(elm);
|
|
3824
|
+
}
|
|
3825
|
+
};
|
|
3826
|
+
|
|
3827
|
+
var disconnectedCallback = function disconnectedCallback(elm) {
|
|
3828
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3829
|
+
disconnectRootElement(elm);
|
|
3830
|
+
}
|
|
3831
|
+
};
|
|
3832
|
+
|
|
3833
|
+
var elm = createCustomElement(sel, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
3897
3834
|
vnode.elm = elm;
|
|
3898
3835
|
vnode.vm = vm;
|
|
3899
3836
|
linkNodeToShadow(elm, owner, renderer);
|
|
@@ -3901,8 +3838,6 @@
|
|
|
3901
3838
|
|
|
3902
3839
|
if (vm) {
|
|
3903
3840
|
allocateChildren(vnode, vm);
|
|
3904
|
-
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
3905
|
-
throw new TypeError("Incorrect Component Constructor");
|
|
3906
3841
|
}
|
|
3907
3842
|
|
|
3908
3843
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
@@ -5877,21 +5812,21 @@
|
|
|
5877
5812
|
var WireContextRegistrationEvent = /*#__PURE__*/function (_CustomEvent) {
|
|
5878
5813
|
_inherits(WireContextRegistrationEvent, _CustomEvent);
|
|
5879
5814
|
|
|
5880
|
-
var
|
|
5815
|
+
var _super5 = _createSuper(WireContextRegistrationEvent);
|
|
5881
5816
|
|
|
5882
5817
|
function WireContextRegistrationEvent(adapterToken, _ref3) {
|
|
5883
|
-
var
|
|
5818
|
+
var _this4;
|
|
5884
5819
|
|
|
5885
5820
|
var setNewContext = _ref3.setNewContext,
|
|
5886
5821
|
setDisconnectedCallback = _ref3.setDisconnectedCallback;
|
|
5887
5822
|
|
|
5888
5823
|
_classCallCheck(this, WireContextRegistrationEvent);
|
|
5889
5824
|
|
|
5890
|
-
|
|
5825
|
+
_this4 = _super5.call(this, adapterToken, {
|
|
5891
5826
|
bubbles: true,
|
|
5892
5827
|
composed: true
|
|
5893
5828
|
});
|
|
5894
|
-
defineProperties(_assertThisInitialized(
|
|
5829
|
+
defineProperties(_assertThisInitialized(_this4), {
|
|
5895
5830
|
setNewContext: {
|
|
5896
5831
|
value: setNewContext
|
|
5897
5832
|
},
|
|
@@ -5899,7 +5834,7 @@
|
|
|
5899
5834
|
value: setDisconnectedCallback
|
|
5900
5835
|
}
|
|
5901
5836
|
});
|
|
5902
|
-
return
|
|
5837
|
+
return _this4;
|
|
5903
5838
|
}
|
|
5904
5839
|
|
|
5905
5840
|
return _createClass(WireContextRegistrationEvent);
|
|
@@ -6538,13 +6473,27 @@
|
|
|
6538
6473
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
6539
6474
|
// are rendered during SSR. This needs to be accounted for when validating.
|
|
6540
6475
|
|
|
6541
|
-
if (scopedToken) {
|
|
6476
|
+
if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
|
|
6542
6477
|
if (!isUndefined$1(className)) {
|
|
6543
|
-
|
|
6478
|
+
// The order of the className should be scopedToken className stylesheetTokenHost
|
|
6479
|
+
var classTokens = [scopedToken, className, stylesheetTokenHost];
|
|
6480
|
+
var classNames = ArrayFilter.call(classTokens, function (token) {
|
|
6481
|
+
return !isNull(token);
|
|
6482
|
+
});
|
|
6483
|
+
className = ArrayJoin.call(classNames, ' ');
|
|
6544
6484
|
} else if (!isUndefined$1(classMap)) {
|
|
6545
|
-
classMap = Object.assign(Object.assign(Object.assign({}, classMap), _defineProperty({}, scopedToken, true)), isNull(stylesheetTokenHost) ?
|
|
6485
|
+
classMap = Object.assign(Object.assign(Object.assign({}, classMap), !isNull(scopedToken) ? _defineProperty({}, scopedToken, true) : {}), !isNull(stylesheetTokenHost) ? _defineProperty({}, stylesheetTokenHost, true) : {});
|
|
6546
6486
|
} else {
|
|
6547
|
-
|
|
6487
|
+
// The order of the className should be scopedToken stylesheetTokenHost
|
|
6488
|
+
var _classTokens = [scopedToken, stylesheetTokenHost];
|
|
6489
|
+
|
|
6490
|
+
var _classNames = ArrayFilter.call(_classTokens, function (token) {
|
|
6491
|
+
return !isNull(token);
|
|
6492
|
+
});
|
|
6493
|
+
|
|
6494
|
+
if (_classNames.length) {
|
|
6495
|
+
className = ArrayJoin.call(_classNames, ' ');
|
|
6496
|
+
}
|
|
6548
6497
|
}
|
|
6549
6498
|
}
|
|
6550
6499
|
|
|
@@ -6715,7 +6664,7 @@
|
|
|
6715
6664
|
|
|
6716
6665
|
return ctor;
|
|
6717
6666
|
}
|
|
6718
|
-
/* version: 2.
|
|
6667
|
+
/* version: 2.26.0 */
|
|
6719
6668
|
|
|
6720
6669
|
/*
|
|
6721
6670
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6866,6 +6815,779 @@
|
|
|
6866
6815
|
insertLocalStylesheet(content, target);
|
|
6867
6816
|
}
|
|
6868
6817
|
}
|
|
6818
|
+
/*
|
|
6819
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
6820
|
+
* All rights reserved.
|
|
6821
|
+
* SPDX-License-Identifier: MIT
|
|
6822
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6823
|
+
*/
|
|
6824
|
+
|
|
6825
|
+
|
|
6826
|
+
function isCustomElementRegistryAvailable() {
|
|
6827
|
+
if (typeof customElements === 'undefined') {
|
|
6828
|
+
return false;
|
|
6829
|
+
}
|
|
6830
|
+
|
|
6831
|
+
try {
|
|
6832
|
+
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
6833
|
+
// _wrapNativeSuper()
|
|
6834
|
+
// This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
|
|
6835
|
+
// get wrapped by babel.
|
|
6836
|
+
var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
|
|
6837
|
+
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
6838
|
+
// which are not equipped to be initialized that way.
|
|
6839
|
+
|
|
6840
|
+
var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
|
|
6841
|
+
_inherits(clazz, _HTMLElementAlias);
|
|
6842
|
+
|
|
6843
|
+
var _super6 = _createSuper(clazz);
|
|
6844
|
+
|
|
6845
|
+
function clazz() {
|
|
6846
|
+
_classCallCheck(this, clazz);
|
|
6847
|
+
|
|
6848
|
+
return _super6.apply(this, arguments);
|
|
6849
|
+
}
|
|
6850
|
+
|
|
6851
|
+
return _createClass(clazz);
|
|
6852
|
+
}(HTMLElementAlias);
|
|
6853
|
+
|
|
6854
|
+
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
6855
|
+
new clazz();
|
|
6856
|
+
return true;
|
|
6857
|
+
} catch (_a) {
|
|
6858
|
+
return false;
|
|
6859
|
+
}
|
|
6860
|
+
}
|
|
6861
|
+
|
|
6862
|
+
var hasCustomElements = isCustomElementRegistryAvailable();
|
|
6863
|
+
/*
|
|
6864
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6865
|
+
* All rights reserved.
|
|
6866
|
+
* SPDX-License-Identifier: MIT
|
|
6867
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6868
|
+
*/
|
|
6869
|
+
// Creates a custom element for compat (legacy) browser environments
|
|
6870
|
+
|
|
6871
|
+
var createCustomElementCompat = function createCustomElementCompat(tagName, upgradeCallback) {
|
|
6872
|
+
var elm = document.createElement(tagName);
|
|
6873
|
+
upgradeCallback(elm); // nothing to do with the result for now
|
|
6874
|
+
|
|
6875
|
+
return elm;
|
|
6876
|
+
};
|
|
6877
|
+
/*
|
|
6878
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6879
|
+
* All rights reserved.
|
|
6880
|
+
* SPDX-License-Identifier: MIT
|
|
6881
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6882
|
+
*/
|
|
6883
|
+
|
|
6884
|
+
|
|
6885
|
+
var cachedConstructors = new Map();
|
|
6886
|
+
var elementsUpgradedOutsideLWC = new WeakSet();
|
|
6887
|
+
var elementBeingUpgradedByLWC = false; // Creates a constructor that is intended to be used as a vanilla custom element, except that the upgradeCallback is
|
|
6888
|
+
// passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
|
|
6889
|
+
// Another benefit is that only LWC can create components that actually do anything – if you do
|
|
6890
|
+
// `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
|
|
6891
|
+
// This class should be created once per tag name.
|
|
6892
|
+
|
|
6893
|
+
var createUpgradableConstructor = function createUpgradableConstructor(_connectedCallback, _disconnectedCallback) {
|
|
6894
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
6895
|
+
return /*#__PURE__*/function (_HTMLElement) {
|
|
6896
|
+
_inherits(UpgradableConstructor, _HTMLElement);
|
|
6897
|
+
|
|
6898
|
+
var _super7 = _createSuper(UpgradableConstructor);
|
|
6899
|
+
|
|
6900
|
+
function UpgradableConstructor(upgradeCallback) {
|
|
6901
|
+
var _this5;
|
|
6902
|
+
|
|
6903
|
+
_classCallCheck(this, UpgradableConstructor);
|
|
6904
|
+
|
|
6905
|
+
_this5 = _super7.call(this); // If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
|
|
6906
|
+
// then elementBeingUpgraded will be false
|
|
6907
|
+
|
|
6908
|
+
if (elementBeingUpgradedByLWC) {
|
|
6909
|
+
upgradeCallback(_assertThisInitialized(_this5));
|
|
6910
|
+
} else {
|
|
6911
|
+
// keep track of elements that were not created by lwc.createElement,
|
|
6912
|
+
// so we can ignore their lifecycle hooks
|
|
6913
|
+
elementsUpgradedOutsideLWC.add(_assertThisInitialized(_this5)); // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
|
|
6914
|
+
// Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
|
|
6915
|
+
}
|
|
6916
|
+
|
|
6917
|
+
return _this5;
|
|
6918
|
+
}
|
|
6919
|
+
|
|
6920
|
+
_createClass(UpgradableConstructor, [{
|
|
6921
|
+
key: "connectedCallback",
|
|
6922
|
+
value: function connectedCallback() {
|
|
6923
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
6924
|
+
_connectedCallback(this);
|
|
6925
|
+
}
|
|
6926
|
+
}
|
|
6927
|
+
}, {
|
|
6928
|
+
key: "disconnectedCallback",
|
|
6929
|
+
value: function disconnectedCallback() {
|
|
6930
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
6931
|
+
_disconnectedCallback(this);
|
|
6932
|
+
}
|
|
6933
|
+
}
|
|
6934
|
+
}]);
|
|
6935
|
+
|
|
6936
|
+
return UpgradableConstructor;
|
|
6937
|
+
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
|
|
6938
|
+
};
|
|
6939
|
+
|
|
6940
|
+
var createCustomElementVanilla = function createCustomElementVanilla(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
6941
|
+
// use global custom elements registry
|
|
6942
|
+
var UpgradableConstructor = cachedConstructors.get(tagName);
|
|
6943
|
+
|
|
6944
|
+
if (isUndefined$1(UpgradableConstructor)) {
|
|
6945
|
+
if (!isUndefined$1(customElements.get(tagName))) {
|
|
6946
|
+
throw new Error("Unexpected tag name \"".concat(tagName, "\". This name is a registered custom element, preventing LWC to upgrade the element."));
|
|
6947
|
+
}
|
|
6948
|
+
|
|
6949
|
+
UpgradableConstructor = createUpgradableConstructor(connectedCallback, disconnectedCallback);
|
|
6950
|
+
customElements.define(tagName, UpgradableConstructor);
|
|
6951
|
+
cachedConstructors.set(tagName, UpgradableConstructor);
|
|
6952
|
+
}
|
|
6953
|
+
|
|
6954
|
+
elementBeingUpgradedByLWC = true;
|
|
6955
|
+
|
|
6956
|
+
try {
|
|
6957
|
+
return new UpgradableConstructor(upgradeCallback);
|
|
6958
|
+
} finally {
|
|
6959
|
+
elementBeingUpgradedByLWC = false;
|
|
6960
|
+
}
|
|
6961
|
+
};
|
|
6962
|
+
/*
|
|
6963
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
6964
|
+
* All rights reserved.
|
|
6965
|
+
* SPDX-License-Identifier: MIT
|
|
6966
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6967
|
+
*/
|
|
6968
|
+
|
|
6969
|
+
/**
|
|
6970
|
+
* Create a scoped registry, i.e. a function that can create custom elements whose tag names
|
|
6971
|
+
* do not conflict with vanilla custom elements having the same tag name.
|
|
6972
|
+
*/
|
|
6973
|
+
|
|
6974
|
+
|
|
6975
|
+
function createScopedRegistry() {
|
|
6976
|
+
if (!hasCustomElements) {
|
|
6977
|
+
// This code should never be reached, because we don't use the pivot registry if
|
|
6978
|
+
// custom elements are unavailable.
|
|
6979
|
+
throw new Error('Custom elements are not supported in this environment.');
|
|
6980
|
+
}
|
|
6981
|
+
|
|
6982
|
+
var _window = window,
|
|
6983
|
+
NativeHTMLElement = _window.HTMLElement;
|
|
6984
|
+
var _NativeHTMLElement$pr = NativeHTMLElement.prototype,
|
|
6985
|
+
nativeHasAttribute = _NativeHTMLElement$pr.hasAttribute,
|
|
6986
|
+
nativeSetAttribute = _NativeHTMLElement$pr.setAttribute,
|
|
6987
|
+
nativeRemoveAttribute = _NativeHTMLElement$pr.removeAttribute,
|
|
6988
|
+
nativeGetAttribute = _NativeHTMLElement$pr.getAttribute;
|
|
6989
|
+
var definitionForElement = new WeakMap();
|
|
6990
|
+
var pendingRegistryForElement = new WeakMap();
|
|
6991
|
+
var definitionForConstructor = new WeakMap();
|
|
6992
|
+
var registeredUserCtors = new WeakSet();
|
|
6993
|
+
var pivotCtorByTag = new Map();
|
|
6994
|
+
var globalDefinitionsByTag = new Map();
|
|
6995
|
+
var globalDefinitionsByClass = new Map();
|
|
6996
|
+
var awaitingUpgrade = new Map();
|
|
6997
|
+
var EMPTY_SET = new Set();
|
|
6998
|
+
|
|
6999
|
+
function createDefinitionRecord(constructor) {
|
|
7000
|
+
var _a;
|
|
7001
|
+
|
|
7002
|
+
var _constructor$prototyp = constructor.prototype,
|
|
7003
|
+
connectedCallback = _constructor$prototyp.connectedCallback,
|
|
7004
|
+
disconnectedCallback = _constructor$prototyp.disconnectedCallback,
|
|
7005
|
+
adoptedCallback = _constructor$prototyp.adoptedCallback,
|
|
7006
|
+
attributeChangedCallback = _constructor$prototyp.attributeChangedCallback;
|
|
7007
|
+
var observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
|
|
7008
|
+
return {
|
|
7009
|
+
UserCtor: constructor,
|
|
7010
|
+
PivotCtor: undefined,
|
|
7011
|
+
connectedCallback: connectedCallback,
|
|
7012
|
+
disconnectedCallback: disconnectedCallback,
|
|
7013
|
+
adoptedCallback: adoptedCallback,
|
|
7014
|
+
attributeChangedCallback: attributeChangedCallback,
|
|
7015
|
+
observedAttributes: observedAttributes
|
|
7016
|
+
};
|
|
7017
|
+
} // Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
|
|
7018
|
+
// element. Note that the `registeredDefinition` represents the constructor that was used to register during
|
|
7019
|
+
// `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
|
|
7020
|
+
// constructor is invoked with another constructor.
|
|
7021
|
+
|
|
7022
|
+
|
|
7023
|
+
function createPivotingClass(tagName, registeredDefinition) {
|
|
7024
|
+
var PivotCtor = /*#__PURE__*/function (_NativeHTMLElement) {
|
|
7025
|
+
_inherits(PivotCtor, _NativeHTMLElement);
|
|
7026
|
+
|
|
7027
|
+
var _super8 = _createSuper(PivotCtor);
|
|
7028
|
+
|
|
7029
|
+
function PivotCtor(UserCtor) {
|
|
7030
|
+
var _this6;
|
|
7031
|
+
|
|
7032
|
+
_classCallCheck(this, PivotCtor);
|
|
7033
|
+
|
|
7034
|
+
// This constructor can only be invoked by:
|
|
7035
|
+
// a) the browser instantiating an element from parsing or via document.createElement.
|
|
7036
|
+
// b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
|
|
7037
|
+
// b) new UserClass.
|
|
7038
|
+
// When LWC instantiates it, it will pass the upgrading definition as an argument
|
|
7039
|
+
// If the caller signals via UserCtor that this is in fact a controlled
|
|
7040
|
+
// definition, we use that one, otherwise fallback to the global
|
|
7041
|
+
// internal registry.
|
|
7042
|
+
_this6 = _super8.call(this);
|
|
7043
|
+
var userCtorIsDefined = !isUndefined$1(UserCtor);
|
|
7044
|
+
|
|
7045
|
+
if (userCtorIsDefined) {
|
|
7046
|
+
if (!isConstructor(UserCtor)) {
|
|
7047
|
+
throw new TypeError("Failed to create custom element: the provided constructor is not a constructor.");
|
|
7048
|
+
}
|
|
7049
|
+
|
|
7050
|
+
if (!registeredUserCtors.has(UserCtor)) {
|
|
7051
|
+
throw new Error("Failed to create custom element: the provided constructor is unregistered: ".concat(UserCtor.name, "."));
|
|
7052
|
+
}
|
|
7053
|
+
}
|
|
7054
|
+
|
|
7055
|
+
var definition = userCtorIsDefined ? getOrCreateDefinitionForConstructor(UserCtor) : globalDefinitionsByTag.get(tagName);
|
|
7056
|
+
|
|
7057
|
+
if (!isUndefined$1(definition)) {
|
|
7058
|
+
internalUpgrade(_assertThisInitialized(_this6), registeredDefinition, definition);
|
|
7059
|
+
} else {
|
|
7060
|
+
// This is the case in which there is no global definition, and
|
|
7061
|
+
// it is not handled by LWC (otherwise it will have a valid UserCtor)
|
|
7062
|
+
// so we need to add it to the pending queue just in case it eventually
|
|
7063
|
+
// gets defined in the global registry.
|
|
7064
|
+
pendingRegistryForElement.set(_assertThisInitialized(_this6), registeredDefinition);
|
|
7065
|
+
}
|
|
7066
|
+
|
|
7067
|
+
return _this6;
|
|
7068
|
+
}
|
|
7069
|
+
|
|
7070
|
+
_createClass(PivotCtor, [{
|
|
7071
|
+
key: "connectedCallback",
|
|
7072
|
+
value: function connectedCallback() {
|
|
7073
|
+
var _a;
|
|
7074
|
+
|
|
7075
|
+
var definition = definitionForElement.get(this);
|
|
7076
|
+
|
|
7077
|
+
if (!isUndefined$1(definition)) {
|
|
7078
|
+
// Delegate out to user callback
|
|
7079
|
+
(_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7080
|
+
} else {
|
|
7081
|
+
// Register for upgrade when defined (only when connected, so we don't leak)
|
|
7082
|
+
var awaiting = awaitingUpgrade.get(tagName);
|
|
7083
|
+
|
|
7084
|
+
if (isUndefined$1(awaiting)) {
|
|
7085
|
+
awaitingUpgrade.set(tagName, awaiting = new Set());
|
|
7086
|
+
}
|
|
7087
|
+
|
|
7088
|
+
awaiting.add(this);
|
|
7089
|
+
}
|
|
7090
|
+
}
|
|
7091
|
+
}, {
|
|
7092
|
+
key: "disconnectedCallback",
|
|
7093
|
+
value: function disconnectedCallback() {
|
|
7094
|
+
var _a;
|
|
7095
|
+
|
|
7096
|
+
var definition = definitionForElement.get(this);
|
|
7097
|
+
|
|
7098
|
+
if (!isUndefined$1(definition)) {
|
|
7099
|
+
// Delegate out to user callback
|
|
7100
|
+
(_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7101
|
+
} else {
|
|
7102
|
+
// Un-register for upgrade when defined (so we don't leak)
|
|
7103
|
+
var awaiting = awaitingUpgrade.get(tagName); // At this point, awaiting should never be undefined, because connectedCallback
|
|
7104
|
+
// must have been called before disconnectedCallback. But just to be safe, we check
|
|
7105
|
+
|
|
7106
|
+
if (!isUndefined$1(awaiting)) {
|
|
7107
|
+
awaiting.delete(this);
|
|
7108
|
+
}
|
|
7109
|
+
}
|
|
7110
|
+
}
|
|
7111
|
+
}, {
|
|
7112
|
+
key: "adoptedCallback",
|
|
7113
|
+
value: function adoptedCallback() {
|
|
7114
|
+
var _a;
|
|
7115
|
+
|
|
7116
|
+
var definition = definitionForElement.get(this);
|
|
7117
|
+
(_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7118
|
+
}
|
|
7119
|
+
}, {
|
|
7120
|
+
key: "attributeChangedCallback",
|
|
7121
|
+
value: function attributeChangedCallback(name, oldValue, newValue) {
|
|
7122
|
+
var _a;
|
|
7123
|
+
|
|
7124
|
+
var definition = definitionForElement.get(this); // if both definitions are the same, then the observedAttributes is the same,
|
|
7125
|
+
// but if they are different, only if the runtime definition has the attribute
|
|
7126
|
+
// marked as observed, then it should invoke attributeChangedCallback.
|
|
7127
|
+
|
|
7128
|
+
if (registeredDefinition === definition || (definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
|
|
7129
|
+
(_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
|
|
7130
|
+
}
|
|
7131
|
+
}
|
|
7132
|
+
}]);
|
|
7133
|
+
|
|
7134
|
+
return PivotCtor;
|
|
7135
|
+
}(NativeHTMLElement);
|
|
7136
|
+
|
|
7137
|
+
PivotCtor.observedAttributes = _toConsumableArray(registeredDefinition.observedAttributes);
|
|
7138
|
+
return PivotCtor;
|
|
7139
|
+
}
|
|
7140
|
+
|
|
7141
|
+
function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
|
|
7142
|
+
var observedAttributes = pivotDefinition.observedAttributes,
|
|
7143
|
+
attributeChangedCallback = pivotDefinition.attributeChangedCallback;
|
|
7144
|
+
|
|
7145
|
+
if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
|
|
7146
|
+
// This instance does not need to observe any attributes, no need to patch
|
|
7147
|
+
return EMPTY_SET;
|
|
7148
|
+
} // Natively, the attributes observed by the registered definition are going to be taken
|
|
7149
|
+
// care of by the browser, only the difference between the two sets has to be taken
|
|
7150
|
+
// care by the patched version.
|
|
7151
|
+
|
|
7152
|
+
|
|
7153
|
+
return new Set(_toConsumableArray(pivotDefinition.observedAttributes).filter(function (x) {
|
|
7154
|
+
return !registeredDefinition.observedAttributes.has(x);
|
|
7155
|
+
}));
|
|
7156
|
+
}
|
|
7157
|
+
|
|
7158
|
+
function throwAsyncError(error) {
|
|
7159
|
+
// Per native custom element behavior, errors thrown in attributeChangedCallback
|
|
7160
|
+
// become unhandled async errors. We use setTimeout() instead of Promise.resolve()
|
|
7161
|
+
// to make it an unhandled error rather than an unhandled rejection.
|
|
7162
|
+
setTimeout(function () {
|
|
7163
|
+
throw error;
|
|
7164
|
+
});
|
|
7165
|
+
} // Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
|
|
7166
|
+
// Why is this necessary? Well basically, you can't change the `observedAttributes` after
|
|
7167
|
+
// a custom element is defined. So with pivots, if two classes share the same tag name,
|
|
7168
|
+
// and the second class observes attributes that aren't observed by the first one,
|
|
7169
|
+
// then those attributes can never be observed by the native `observedAttributes` system.
|
|
7170
|
+
// So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
|
|
7171
|
+
// we only do this when absolutely necessary, though; i.e. because we've determined
|
|
7172
|
+
// that we aren't observing the attributes we need to.
|
|
7173
|
+
|
|
7174
|
+
|
|
7175
|
+
function patchAttributes(instance, registeredDefinition, pivotDefinition) {
|
|
7176
|
+
var newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
7177
|
+
|
|
7178
|
+
if (newObservedAttributes.size === 0) {
|
|
7179
|
+
return;
|
|
7180
|
+
}
|
|
7181
|
+
|
|
7182
|
+
var attributeChangedCallback = pivotDefinition.attributeChangedCallback; // Patch the instance.
|
|
7183
|
+
// Note we use the native `getAttribute` rather than the super's `getAttribute` because
|
|
7184
|
+
// we don't actually want it to be observable that we're calling `getAttribute` from
|
|
7185
|
+
// `setAttribute` and `removeAttribute`.
|
|
7186
|
+
// TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
|
|
7187
|
+
|
|
7188
|
+
defineProperties(instance, {
|
|
7189
|
+
setAttribute: {
|
|
7190
|
+
value: function setAttribute(name, value) {
|
|
7191
|
+
if (newObservedAttributes.has(name)) {
|
|
7192
|
+
var old = nativeGetAttribute.call(this, name);
|
|
7193
|
+
nativeSetAttribute.call(this, name, value);
|
|
7194
|
+
|
|
7195
|
+
try {
|
|
7196
|
+
attributeChangedCallback.call(this, name, old, value + '');
|
|
7197
|
+
} catch (error) {
|
|
7198
|
+
throwAsyncError(error);
|
|
7199
|
+
}
|
|
7200
|
+
} else {
|
|
7201
|
+
nativeSetAttribute.call(this, name, value);
|
|
7202
|
+
}
|
|
7203
|
+
},
|
|
7204
|
+
writable: true,
|
|
7205
|
+
enumerable: true,
|
|
7206
|
+
configurable: true
|
|
7207
|
+
},
|
|
7208
|
+
removeAttribute: {
|
|
7209
|
+
value: function removeAttribute(name) {
|
|
7210
|
+
if (newObservedAttributes.has(name)) {
|
|
7211
|
+
var old = nativeGetAttribute.call(this, name);
|
|
7212
|
+
nativeRemoveAttribute.call(this, name);
|
|
7213
|
+
|
|
7214
|
+
try {
|
|
7215
|
+
attributeChangedCallback.call(this, name, old, null);
|
|
7216
|
+
} catch (error) {
|
|
7217
|
+
throwAsyncError(error);
|
|
7218
|
+
}
|
|
7219
|
+
} else {
|
|
7220
|
+
nativeRemoveAttribute.call(this, name);
|
|
7221
|
+
}
|
|
7222
|
+
},
|
|
7223
|
+
writable: true,
|
|
7224
|
+
enumerable: true,
|
|
7225
|
+
configurable: true
|
|
7226
|
+
}
|
|
7227
|
+
});
|
|
7228
|
+
}
|
|
7229
|
+
|
|
7230
|
+
function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
7231
|
+
// The below case patches observed attributes for the case where the HTML element is upgraded
|
|
7232
|
+
// from a pre-existing one in the DOM.
|
|
7233
|
+
var newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
7234
|
+
|
|
7235
|
+
if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
|
|
7236
|
+
return;
|
|
7237
|
+
}
|
|
7238
|
+
|
|
7239
|
+
var attributeChangedCallback = pivotDefinition.attributeChangedCallback; // Approximate observedAttributes from the user class, but only for the new observed attributes
|
|
7240
|
+
|
|
7241
|
+
newObservedAttributes.forEach(function (name) {
|
|
7242
|
+
if (nativeHasAttribute.call(instance, name)) {
|
|
7243
|
+
var newValue = nativeGetAttribute.call(instance, name);
|
|
7244
|
+
attributeChangedCallback.call(instance, name, null, newValue);
|
|
7245
|
+
}
|
|
7246
|
+
});
|
|
7247
|
+
} // User extends this HTMLElement, which returns the CE being upgraded
|
|
7248
|
+
|
|
7249
|
+
|
|
7250
|
+
var upgradingInstance; // Helper to upgrade an instance with a CE definition using "constructor call trick"
|
|
7251
|
+
|
|
7252
|
+
function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
7253
|
+
setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
|
|
7254
|
+
definitionForElement.set(instance, pivotDefinition); // attributes patches when needed
|
|
7255
|
+
|
|
7256
|
+
if (pivotDefinition !== registeredDefinition) {
|
|
7257
|
+
patchAttributes(instance, registeredDefinition, pivotDefinition);
|
|
7258
|
+
} // Tricking the construction path to believe that a new instance is being created,
|
|
7259
|
+
// that way it will execute the super initialization mechanism but the HTMLElement
|
|
7260
|
+
// constructor will reuse the instance by returning the upgradingInstance.
|
|
7261
|
+
// This is by far the most important piece of the puzzle
|
|
7262
|
+
|
|
7263
|
+
|
|
7264
|
+
upgradingInstance = instance; // By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
|
|
7265
|
+
// The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
|
|
7266
|
+
// Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
|
|
7267
|
+
|
|
7268
|
+
new pivotDefinition.UserCtor();
|
|
7269
|
+
patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
|
|
7270
|
+
}
|
|
7271
|
+
|
|
7272
|
+
function isConstructor(constructor) {
|
|
7273
|
+
return isFunction$1(constructor) && isObject(constructor.prototype);
|
|
7274
|
+
}
|
|
7275
|
+
|
|
7276
|
+
function getOrCreateDefinitionForConstructor(constructor) {
|
|
7277
|
+
if (!isConstructor(constructor)) {
|
|
7278
|
+
throw new TypeError('The referenced constructor is not a constructor.');
|
|
7279
|
+
}
|
|
7280
|
+
|
|
7281
|
+
var definition = definitionForConstructor.get(constructor);
|
|
7282
|
+
|
|
7283
|
+
if (!isUndefined$1(definition)) {
|
|
7284
|
+
return definition;
|
|
7285
|
+
}
|
|
7286
|
+
|
|
7287
|
+
return createDefinitionRecord(constructor);
|
|
7288
|
+
}
|
|
7289
|
+
|
|
7290
|
+
var _window2 = window,
|
|
7291
|
+
nativeRegistry = _window2.customElements;
|
|
7292
|
+
var nativeDefine = nativeRegistry.define,
|
|
7293
|
+
nativeWhenDefined = nativeRegistry.whenDefined,
|
|
7294
|
+
nativeGet = nativeRegistry.get; // patch for the global registry define mechanism
|
|
7295
|
+
|
|
7296
|
+
CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
|
|
7297
|
+
if (options && options.extends) {
|
|
7298
|
+
// TODO [#2983]: should we support `extends`?
|
|
7299
|
+
throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
|
|
7300
|
+
}
|
|
7301
|
+
|
|
7302
|
+
if (globalDefinitionsByTag.has(tagName)) {
|
|
7303
|
+
throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': the name \"".concat(tagName, "\" has already been used with this registry"));
|
|
7304
|
+
}
|
|
7305
|
+
|
|
7306
|
+
if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
|
|
7307
|
+
throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry");
|
|
7308
|
+
}
|
|
7309
|
+
|
|
7310
|
+
var definition = getOrCreateDefinitionForConstructor(constructor);
|
|
7311
|
+
registeredUserCtors.add(constructor);
|
|
7312
|
+
var PivotCtor = pivotCtorByTag.get(tagName);
|
|
7313
|
+
|
|
7314
|
+
if (isUndefined$1(PivotCtor)) {
|
|
7315
|
+
PivotCtor = createPivotingClass(tagName, definition); // Register a pivoting class which will handle global registry initializations
|
|
7316
|
+
|
|
7317
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
7318
|
+
} // Only cache after nativeDefine has been called, because if it throws an error
|
|
7319
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
7320
|
+
|
|
7321
|
+
|
|
7322
|
+
definitionForConstructor.set(constructor, definition);
|
|
7323
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
7324
|
+
globalDefinitionsByTag.set(tagName, definition);
|
|
7325
|
+
globalDefinitionsByClass.set(constructor, definition); // For globally defined custom elements, the definition associated
|
|
7326
|
+
// to the UserCtor has a back-pointer to PivotCtor in case the user
|
|
7327
|
+
// new the UserCtor, so we know how to create the underlying element.
|
|
7328
|
+
|
|
7329
|
+
definition.PivotCtor = PivotCtor; // Upgrade any elements created in this scope before customElements.define
|
|
7330
|
+
// was called, which should be exhibited by the following steps:
|
|
7331
|
+
// 1) LWC registers a tagName for an LWC component.
|
|
7332
|
+
// 2) Element with same tagName is created with document.createElement()
|
|
7333
|
+
// and inserted into DOM.
|
|
7334
|
+
// 3) customElements.define() is called with tagName and non-LWC constructor.
|
|
7335
|
+
// This requires immediate upgrade when the new global tagName is defined.
|
|
7336
|
+
|
|
7337
|
+
var awaiting = awaitingUpgrade.get(tagName);
|
|
7338
|
+
|
|
7339
|
+
if (!isUndefined$1(awaiting)) {
|
|
7340
|
+
awaitingUpgrade.delete(tagName);
|
|
7341
|
+
|
|
7342
|
+
var _iterator6 = _createForOfIteratorHelper(awaiting),
|
|
7343
|
+
_step6;
|
|
7344
|
+
|
|
7345
|
+
try {
|
|
7346
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
7347
|
+
var element = _step6.value;
|
|
7348
|
+
var registeredDefinition = pendingRegistryForElement.get(element); // At this point, registeredDefinition should never be undefined because awaitingUpgrade
|
|
7349
|
+
// is only populated when we haven't run internalUpgrade yet, and we only populate
|
|
7350
|
+
// pendingRegistryForElement when internalUpgrade hasn't run yet.
|
|
7351
|
+
// But just to be safe, we check.
|
|
7352
|
+
|
|
7353
|
+
if (!isUndefined$1(registeredDefinition)) {
|
|
7354
|
+
pendingRegistryForElement.delete(element);
|
|
7355
|
+
internalUpgrade(element, registeredDefinition, definition);
|
|
7356
|
+
}
|
|
7357
|
+
}
|
|
7358
|
+
} catch (err) {
|
|
7359
|
+
_iterator6.e(err);
|
|
7360
|
+
} finally {
|
|
7361
|
+
_iterator6.f();
|
|
7362
|
+
}
|
|
7363
|
+
}
|
|
7364
|
+
};
|
|
7365
|
+
|
|
7366
|
+
CustomElementRegistry.prototype.get = function get(tagName) {
|
|
7367
|
+
var NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
7368
|
+
|
|
7369
|
+
if (!isUndefined$1(NativeCtor)) {
|
|
7370
|
+
var definition = globalDefinitionsByTag.get(tagName);
|
|
7371
|
+
|
|
7372
|
+
if (!isUndefined$1(definition)) {
|
|
7373
|
+
return definition.UserCtor; // defined by the patched custom elements registry
|
|
7374
|
+
} // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
7375
|
+
|
|
7376
|
+
|
|
7377
|
+
return NativeCtor; // return the pivot constructor or constructor that existed before patching
|
|
7378
|
+
}
|
|
7379
|
+
};
|
|
7380
|
+
|
|
7381
|
+
CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
|
|
7382
|
+
return nativeWhenDefined.call(nativeRegistry, tagName).then(function (NativeCtor) {
|
|
7383
|
+
var definition = globalDefinitionsByTag.get(tagName);
|
|
7384
|
+
|
|
7385
|
+
if (!isUndefined$1(definition)) {
|
|
7386
|
+
return definition.UserCtor;
|
|
7387
|
+
} // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
7388
|
+
// In this case, the custom element must have been defined before the registry patches
|
|
7389
|
+
// were applied. So return the non-pivot constructor
|
|
7390
|
+
|
|
7391
|
+
|
|
7392
|
+
if (isUndefined$1(NativeCtor)) {
|
|
7393
|
+
// Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
|
|
7394
|
+
// We can patch the correct behavior using customElements.get()
|
|
7395
|
+
return nativeGet.call(nativeRegistry, tagName);
|
|
7396
|
+
}
|
|
7397
|
+
|
|
7398
|
+
return NativeCtor;
|
|
7399
|
+
});
|
|
7400
|
+
}; // This constructor is invoked when we call `new pivotDefinition.UserCtor()`
|
|
7401
|
+
// @ts-ignore
|
|
7402
|
+
|
|
7403
|
+
|
|
7404
|
+
window.HTMLElement = function HTMLElement() {
|
|
7405
|
+
// Upgrading case: the pivoting class constructor was run by the browser's
|
|
7406
|
+
// native custom elements and we're in the process of running the
|
|
7407
|
+
// "constructor-call trick" on the natively constructed instance, so just
|
|
7408
|
+
// return that here.
|
|
7409
|
+
// This code path is also called when LWC `new`s a PivotCtor.
|
|
7410
|
+
var instance = upgradingInstance;
|
|
7411
|
+
|
|
7412
|
+
if (!isUndefined$1(instance)) {
|
|
7413
|
+
upgradingInstance = undefined;
|
|
7414
|
+
return instance;
|
|
7415
|
+
} // Construction case: we need to construct the pivoting instance and return it.
|
|
7416
|
+
// This is possible when the user register it via global registry and instantiate
|
|
7417
|
+
// it via `new Ctor()`.
|
|
7418
|
+
|
|
7419
|
+
|
|
7420
|
+
var constructor = this.constructor;
|
|
7421
|
+
var definition = globalDefinitionsByClass.get(constructor);
|
|
7422
|
+
|
|
7423
|
+
if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
|
|
7424
|
+
// This code path is hit if someone `new`s a class that extends `HTMLElement` without
|
|
7425
|
+
// doing `customElements.define()` first. This matches native browser behavior:
|
|
7426
|
+
// https://stackoverflow.com/a/61883392
|
|
7427
|
+
throw new TypeError('Illegal constructor');
|
|
7428
|
+
} // This constructor is ONLY invoked when it is the user instantiating
|
|
7429
|
+
// an element via new Ctor while Ctor is a registered global constructor.
|
|
7430
|
+
|
|
7431
|
+
|
|
7432
|
+
var PivotCtor = definition.PivotCtor,
|
|
7433
|
+
UserCtor = definition.UserCtor;
|
|
7434
|
+
return new PivotCtor(UserCtor);
|
|
7435
|
+
};
|
|
7436
|
+
|
|
7437
|
+
HTMLElement.prototype = NativeHTMLElement.prototype;
|
|
7438
|
+
/**
|
|
7439
|
+
* Create a new PivotConstructor for the given tagName, which is capable of being constructed
|
|
7440
|
+
* with a UserConstructor defining the behavior. Passing in the UserConstructor here
|
|
7441
|
+
* is a hint that can be used when registering a custom element with the global custom elements
|
|
7442
|
+
* registry for the first time, which provides certain optimizations. It also marks the UserConstructor
|
|
7443
|
+
* as "safe" to be used when passed in to a PivotConstructor.
|
|
7444
|
+
*
|
|
7445
|
+
* @param tagName - element tag name
|
|
7446
|
+
* @param UserCtor - userland custom element constructor
|
|
7447
|
+
* @returns a new custom element constructor
|
|
7448
|
+
*/
|
|
7449
|
+
|
|
7450
|
+
return function createPivotConstructor(tagName, UserCtor) {
|
|
7451
|
+
tagName = StringToLowerCase.call(tagName);
|
|
7452
|
+
var PivotCtor = pivotCtorByTag.get(tagName);
|
|
7453
|
+
|
|
7454
|
+
if (isUndefined$1(PivotCtor)) {
|
|
7455
|
+
var definition = getOrCreateDefinitionForConstructor(UserCtor);
|
|
7456
|
+
PivotCtor = createPivotingClass(tagName, definition); // Register a pivoting class as a global custom element
|
|
7457
|
+
|
|
7458
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
7459
|
+
definition.PivotCtor = PivotCtor; // Only cache after nativeDefine has been called, because if it throws an error
|
|
7460
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
7461
|
+
|
|
7462
|
+
definitionForConstructor.set(UserCtor, definition);
|
|
7463
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
7464
|
+
} // Register a UserConstructor as "safe" to be used within a PivotConstructor
|
|
7465
|
+
|
|
7466
|
+
|
|
7467
|
+
registeredUserCtors.add(UserCtor);
|
|
7468
|
+
return PivotCtor;
|
|
7469
|
+
};
|
|
7470
|
+
}
|
|
7471
|
+
/*
|
|
7472
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7473
|
+
* All rights reserved.
|
|
7474
|
+
* SPDX-License-Identifier: MIT
|
|
7475
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7476
|
+
*/
|
|
7477
|
+
|
|
7478
|
+
|
|
7479
|
+
var createScopedConstructor;
|
|
7480
|
+
var CachedHTMLElement; // We only call `createScopedRegistry()` if the browser supports custom elements and
|
|
7481
|
+
// ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
|
|
7482
|
+
// or we're in a legacy browser.
|
|
7483
|
+
|
|
7484
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
7485
|
+
if (hasCustomElements) {
|
|
7486
|
+
// If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
|
|
7487
|
+
// It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
|
|
7488
|
+
//
|
|
7489
|
+
// Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
|
|
7490
|
+
//
|
|
7491
|
+
// 1. LWC loads
|
|
7492
|
+
// 2. `const Ctor = class extends HTMLElement {}`
|
|
7493
|
+
// 3. `lwc.createElement(...)` // here we lazily patch
|
|
7494
|
+
// 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
|
|
7495
|
+
//
|
|
7496
|
+
// To reduce the risk of this, it's safer to patch the registry eagerly.
|
|
7497
|
+
createScopedConstructor = createScopedRegistry(); // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
|
|
7498
|
+
// another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
|
|
7499
|
+
// because the HTMLElement prototypes are mixed up.
|
|
7500
|
+
//
|
|
7501
|
+
// The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
|
|
7502
|
+
// with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
|
|
7503
|
+
// the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
|
|
7504
|
+
// Caching avoids this problem.
|
|
7505
|
+
|
|
7506
|
+
CachedHTMLElement = window.HTMLElement;
|
|
7507
|
+
}
|
|
7508
|
+
} // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
|
|
7509
|
+
// In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
|
|
7510
|
+
// multiple times per tag name.
|
|
7511
|
+
|
|
7512
|
+
|
|
7513
|
+
var createUserConstructor = function createUserConstructor(upgradeCallback, _connectedCallback2, _disconnectedCallback2, HTMLElementToExtend) {
|
|
7514
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
7515
|
+
return /*#__PURE__*/function (_HTMLElementToExtend) {
|
|
7516
|
+
_inherits(UserConstructor, _HTMLElementToExtend);
|
|
7517
|
+
|
|
7518
|
+
var _super9 = _createSuper(UserConstructor);
|
|
7519
|
+
|
|
7520
|
+
function UserConstructor() {
|
|
7521
|
+
var _this7;
|
|
7522
|
+
|
|
7523
|
+
_classCallCheck(this, UserConstructor);
|
|
7524
|
+
|
|
7525
|
+
_this7 = _super9.call(this);
|
|
7526
|
+
upgradeCallback(_assertThisInitialized(_this7));
|
|
7527
|
+
return _this7;
|
|
7528
|
+
}
|
|
7529
|
+
|
|
7530
|
+
_createClass(UserConstructor, [{
|
|
7531
|
+
key: "connectedCallback",
|
|
7532
|
+
value: function connectedCallback() {
|
|
7533
|
+
_connectedCallback2(this);
|
|
7534
|
+
}
|
|
7535
|
+
}, {
|
|
7536
|
+
key: "disconnectedCallback",
|
|
7537
|
+
value: function disconnectedCallback() {
|
|
7538
|
+
_disconnectedCallback2(this);
|
|
7539
|
+
}
|
|
7540
|
+
}]);
|
|
7541
|
+
|
|
7542
|
+
return UserConstructor;
|
|
7543
|
+
}(HTMLElementToExtend);
|
|
7544
|
+
};
|
|
7545
|
+
|
|
7546
|
+
function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
7547
|
+
if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
|
|
7548
|
+
// This error should be impossible to hit
|
|
7549
|
+
throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
|
|
7550
|
+
}
|
|
7551
|
+
|
|
7552
|
+
var UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
|
|
7553
|
+
var ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
|
|
7554
|
+
return new ScopedConstructor(UserConstructor);
|
|
7555
|
+
}
|
|
7556
|
+
/*
|
|
7557
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7558
|
+
* All rights reserved.
|
|
7559
|
+
* SPDX-License-Identifier: MIT
|
|
7560
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7561
|
+
*/
|
|
7562
|
+
|
|
7563
|
+
/**
|
|
7564
|
+
* We have three modes for creating custom elements:
|
|
7565
|
+
*
|
|
7566
|
+
* 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
|
|
7567
|
+
* 2. "Vanilla" custom elements registry. This system actually still allows us to have two LWC components with the
|
|
7568
|
+
* same tag name, via a simple trick: every custom element constructor we define in the registry is basically
|
|
7569
|
+
* the same. It's essentially a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its
|
|
7570
|
+
* constructor, which allows us to have completely customized functionality for different components.
|
|
7571
|
+
* 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
|
|
7572
|
+
* elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
|
|
7573
|
+
* between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
|
|
7574
|
+
* because it must patch the global `customElements` and `HTMLElement` objects.
|
|
7575
|
+
*/
|
|
7576
|
+
|
|
7577
|
+
|
|
7578
|
+
var createCustomElement;
|
|
7579
|
+
|
|
7580
|
+
if (hasCustomElements) {
|
|
7581
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
7582
|
+
createCustomElement = createCustomElementScoped;
|
|
7583
|
+
} else {
|
|
7584
|
+
// use global custom elements registry (vanilla)
|
|
7585
|
+
createCustomElement = createCustomElementVanilla;
|
|
7586
|
+
}
|
|
7587
|
+
} else {
|
|
7588
|
+
// no registry available here
|
|
7589
|
+
createCustomElement = createCustomElementCompat;
|
|
7590
|
+
}
|
|
6869
7591
|
/*
|
|
6870
7592
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
6871
7593
|
* All rights reserved.
|
|
@@ -6934,7 +7656,7 @@
|
|
|
6934
7656
|
function isNull(obj) {
|
|
6935
7657
|
return obj === null;
|
|
6936
7658
|
}
|
|
6937
|
-
/** version: 2.
|
|
7659
|
+
/** version: 2.26.0 */
|
|
6938
7660
|
|
|
6939
7661
|
/*
|
|
6940
7662
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6944,87 +7666,6 @@
|
|
|
6944
7666
|
*/
|
|
6945
7667
|
|
|
6946
7668
|
|
|
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
7669
|
function cloneNode(node, deep) {
|
|
7029
7670
|
return node.cloneNode(deep);
|
|
7030
7671
|
}
|
|
@@ -7083,18 +7724,18 @@
|
|
|
7083
7724
|
var wrapperTags = topLevelWrappingMap[getTagName(html)];
|
|
7084
7725
|
|
|
7085
7726
|
if (!isUndefined(wrapperTags)) {
|
|
7086
|
-
var
|
|
7087
|
-
|
|
7727
|
+
var _iterator7 = _createForOfIteratorHelper(wrapperTags),
|
|
7728
|
+
_step7;
|
|
7088
7729
|
|
|
7089
7730
|
try {
|
|
7090
|
-
for (
|
|
7091
|
-
var wrapperTag =
|
|
7731
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
7732
|
+
var wrapperTag = _step7.value;
|
|
7092
7733
|
html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
|
|
7093
7734
|
}
|
|
7094
7735
|
} catch (err) {
|
|
7095
|
-
|
|
7736
|
+
_iterator7.e(err);
|
|
7096
7737
|
} finally {
|
|
7097
|
-
|
|
7738
|
+
_iterator7.f();
|
|
7098
7739
|
}
|
|
7099
7740
|
} // For IE11, the document title must not be undefined, but it can be an empty string
|
|
7100
7741
|
// https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
|
|
@@ -7240,8 +7881,6 @@
|
|
|
7240
7881
|
assert.invariant(elm instanceof HTMLElement, msg);
|
|
7241
7882
|
}
|
|
7242
7883
|
|
|
7243
|
-
var HTMLElementExported = HTMLElementConstructor;
|
|
7244
|
-
exports.HTMLElementExported = HTMLElementExported;
|
|
7245
7884
|
exports.addEventListener = addEventListener;
|
|
7246
7885
|
exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
|
|
7247
7886
|
exports.attachShadow = attachShadow;
|
|
@@ -7300,6 +7939,8 @@
|
|
|
7300
7939
|
{
|
|
7301
7940
|
// insertStyleSheet implementation shares a global cache of stylesheet data
|
|
7302
7941
|
insertStylesheet: insertStylesheet,
|
|
7942
|
+
// relies on a shared global cache
|
|
7943
|
+
createCustomElement: createCustomElement,
|
|
7303
7944
|
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
7304
7945
|
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN)
|
|
7305
7946
|
});
|
|
@@ -7416,35 +8057,39 @@
|
|
|
7416
8057
|
var hydratedCustomElements = new WeakSet();
|
|
7417
8058
|
|
|
7418
8059
|
function buildCustomElementConstructor(Ctor) {
|
|
8060
|
+
var _a;
|
|
8061
|
+
|
|
7419
8062
|
var HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
7420
|
-
|
|
7421
|
-
|
|
8063
|
+
var observedAttributes = HtmlPrototype.observedAttributes;
|
|
8064
|
+
var _attributeChangedCallback = HtmlPrototype.prototype.attributeChangedCallback;
|
|
8065
|
+
return _a = /*#__PURE__*/function (_HTMLElement2) {
|
|
8066
|
+
_inherits(_a, _HTMLElement2);
|
|
7422
8067
|
|
|
7423
|
-
var
|
|
8068
|
+
var _super10 = _createSuper(_a);
|
|
7424
8069
|
|
|
7425
|
-
function
|
|
7426
|
-
var
|
|
8070
|
+
function _a() {
|
|
8071
|
+
var _this8;
|
|
7427
8072
|
|
|
7428
|
-
_classCallCheck(this,
|
|
8073
|
+
_classCallCheck(this, _a);
|
|
7429
8074
|
|
|
7430
|
-
|
|
8075
|
+
_this8 = _super10.call(this);
|
|
7431
8076
|
|
|
7432
|
-
if (
|
|
8077
|
+
if (_this8.isConnected) {
|
|
7433
8078
|
// 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(
|
|
8079
|
+
hydrateComponent(_assertThisInitialized(_this8), Ctor, {});
|
|
8080
|
+
hydratedCustomElements.add(_assertThisInitialized(_this8));
|
|
7436
8081
|
} else {
|
|
7437
|
-
createVM(_assertThisInitialized(
|
|
8082
|
+
createVM(_assertThisInitialized(_this8), Ctor, renderer, {
|
|
7438
8083
|
mode: 'open',
|
|
7439
8084
|
owner: null,
|
|
7440
|
-
tagName:
|
|
8085
|
+
tagName: _this8.tagName
|
|
7441
8086
|
});
|
|
7442
8087
|
}
|
|
7443
8088
|
|
|
7444
|
-
return
|
|
8089
|
+
return _this8;
|
|
7445
8090
|
}
|
|
7446
8091
|
|
|
7447
|
-
_createClass(
|
|
8092
|
+
_createClass(_a, [{
|
|
7448
8093
|
key: "connectedCallback",
|
|
7449
8094
|
value: function connectedCallback() {
|
|
7450
8095
|
if (hydratedCustomElements.has(this)) {
|
|
@@ -7459,10 +8104,15 @@
|
|
|
7459
8104
|
value: function disconnectedCallback() {
|
|
7460
8105
|
disconnectRootElement(this);
|
|
7461
8106
|
}
|
|
8107
|
+
}, {
|
|
8108
|
+
key: "attributeChangedCallback",
|
|
8109
|
+
value: function attributeChangedCallback(name, oldValue, newValue) {
|
|
8110
|
+
_attributeChangedCallback.call(this, name, oldValue, newValue);
|
|
8111
|
+
}
|
|
7462
8112
|
}]);
|
|
7463
8113
|
|
|
7464
|
-
return
|
|
7465
|
-
}(
|
|
8114
|
+
return _a;
|
|
8115
|
+
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement)), _a.observedAttributes = observedAttributes, _a;
|
|
7466
8116
|
}
|
|
7467
8117
|
/*
|
|
7468
8118
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7545,8 +8195,11 @@
|
|
|
7545
8195
|
throw new TypeError("\"createElement\" function expects an \"is\" option with a valid component constructor.");
|
|
7546
8196
|
}
|
|
7547
8197
|
|
|
7548
|
-
var
|
|
7549
|
-
|
|
8198
|
+
var createCustomElement = renderer.createCustomElement; // tagName must be all lowercase, unfortunately, we have legacy code that is
|
|
8199
|
+
// passing `sel` as a camel-case, which makes them invalid custom elements name
|
|
8200
|
+
// the following line guarantees that this does not leaks beyond this point.
|
|
8201
|
+
|
|
8202
|
+
var tagName = StringToLowerCase.call(sel); // the custom element from the registry is expecting an upgrade callback
|
|
7550
8203
|
|
|
7551
8204
|
/**
|
|
7552
8205
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
@@ -7555,9 +8208,9 @@
|
|
|
7555
8208
|
* an upgradable custom element.
|
|
7556
8209
|
*/
|
|
7557
8210
|
|
|
7558
|
-
var
|
|
8211
|
+
var upgradeCallback = function upgradeCallback(elm) {
|
|
7559
8212
|
createVM(elm, Ctor, renderer, {
|
|
7560
|
-
tagName:
|
|
8213
|
+
tagName: tagName,
|
|
7561
8214
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
7562
8215
|
owner: null
|
|
7563
8216
|
});
|
|
@@ -7566,15 +8219,21 @@
|
|
|
7566
8219
|
ConnectingSlot.set(elm, connectRootElement);
|
|
7567
8220
|
DisconnectingSlot.set(elm, disconnectRootElement);
|
|
7568
8221
|
}
|
|
8222
|
+
};
|
|
7569
8223
|
|
|
7570
|
-
|
|
7571
|
-
|
|
8224
|
+
var connectedCallback = function connectedCallback(elm) {
|
|
8225
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8226
|
+
connectRootElement(elm);
|
|
8227
|
+
}
|
|
8228
|
+
};
|
|
7572
8229
|
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
8230
|
+
var disconnectedCallback = function disconnectedCallback(elm) {
|
|
8231
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8232
|
+
disconnectRootElement(elm);
|
|
8233
|
+
}
|
|
8234
|
+
};
|
|
7577
8235
|
|
|
8236
|
+
var element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
7578
8237
|
return element;
|
|
7579
8238
|
}
|
|
7580
8239
|
/*
|
|
@@ -7657,7 +8316,7 @@
|
|
|
7657
8316
|
});
|
|
7658
8317
|
freeze(LightningElement);
|
|
7659
8318
|
seal(LightningElement.prototype);
|
|
7660
|
-
/* version: 2.
|
|
8319
|
+
/* version: 2.26.0 */
|
|
7661
8320
|
|
|
7662
8321
|
exports.LightningElement = LightningElement;
|
|
7663
8322
|
exports.__unstable__ProfilerControl = profilerControl;
|