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