lwc 2.25.0 → 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 +1103 -533
- package/dist/engine-dom/iife/es2017/engine-dom.js +1103 -533
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +942 -320
- package/dist/engine-dom/iife/es5/engine-dom.js +966 -312
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +895 -225
- package/dist/engine-dom/umd/es2017/engine-dom.js +1103 -533
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +942 -320
- package/dist/engine-dom/umd/es5/engine-dom.js +966 -312
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +895 -225
- package/dist/engine-server/commonjs/es2017/engine-server.js +331 -339
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +331 -339
- 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,
|
|
@@ -470,7 +470,9 @@
|
|
|
470
470
|
ENABLE_NODE_PATCH: null,
|
|
471
471
|
ENABLE_REACTIVE_SETTER: null,
|
|
472
472
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
473
|
-
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null
|
|
473
|
+
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
474
|
+
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
475
|
+
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null
|
|
474
476
|
};
|
|
475
477
|
|
|
476
478
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
@@ -1796,7 +1798,9 @@
|
|
|
1796
1798
|
var LightningElement = function LightningElement() {
|
|
1797
1799
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
1798
1800
|
if (isNull(vmBeingConstructed)) {
|
|
1799
|
-
|
|
1801
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1802
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1803
|
+
throw new TypeError('Illegal constructor');
|
|
1800
1804
|
}
|
|
1801
1805
|
|
|
1802
1806
|
var vm = vmBeingConstructed;
|
|
@@ -2768,33 +2772,21 @@
|
|
|
2768
2772
|
{
|
|
2769
2773
|
// this method should never leak to prod
|
|
2770
2774
|
throw new ReferenceError();
|
|
2771
|
-
}
|
|
2775
|
+
} // tracking active component
|
|
2772
2776
|
}
|
|
2773
2777
|
|
|
2774
2778
|
function swapTemplate(oldTpl, newTpl) {
|
|
2775
2779
|
|
|
2776
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2777
|
-
throw new Error('HMR is not enabled');
|
|
2778
|
-
}
|
|
2779
|
-
|
|
2780
2780
|
return false;
|
|
2781
2781
|
}
|
|
2782
2782
|
|
|
2783
2783
|
function swapComponent(oldComponent, newComponent) {
|
|
2784
2784
|
|
|
2785
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2786
|
-
throw new Error('HMR is not enabled');
|
|
2787
|
-
}
|
|
2788
|
-
|
|
2789
2785
|
return false;
|
|
2790
2786
|
}
|
|
2791
2787
|
|
|
2792
2788
|
function swapStyle(oldStyle, newStyle) {
|
|
2793
2789
|
|
|
2794
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
2795
|
-
throw new Error('HMR is not enabled');
|
|
2796
|
-
}
|
|
2797
|
-
|
|
2798
2790
|
return false;
|
|
2799
2791
|
}
|
|
2800
2792
|
/*
|
|
@@ -3121,7 +3113,17 @@
|
|
|
3121
3113
|
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
3122
3114
|
} else {
|
|
3123
3115
|
|
|
3124
|
-
var isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
3116
|
+
var isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
3117
|
+
|
|
3118
|
+
if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS) {
|
|
3119
|
+
if (!isScopedCss && vm.renderMode === 0
|
|
3120
|
+
/* RenderMode.Light */
|
|
3121
|
+
) {
|
|
3122
|
+
logError('Unscoped CSS is not supported in Light DOM. Please use scoped CSS (*.scoped.css) instead of unscoped CSS (*.css).');
|
|
3123
|
+
continue;
|
|
3124
|
+
}
|
|
3125
|
+
} // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
3126
|
+
|
|
3125
3127
|
|
|
3126
3128
|
var scopeToken = isScopedCss || vm.shadowMode === 1
|
|
3127
3129
|
/* ShadowMode.Synthetic */
|
|
@@ -3210,14 +3212,17 @@
|
|
|
3210
3212
|
/**
|
|
3211
3213
|
* This function returns the host style token for a custom element if it
|
|
3212
3214
|
* exists. Otherwise it returns null.
|
|
3215
|
+
*
|
|
3216
|
+
* A host style token is applied to the component if scoped styles are used.
|
|
3213
3217
|
*/
|
|
3214
3218
|
|
|
3215
3219
|
|
|
3216
3220
|
function getStylesheetTokenHost(vnode) {
|
|
3217
3221
|
var _getComponentInternal = getComponentInternalDef(vnode.ctor),
|
|
3218
|
-
|
|
3222
|
+
template = _getComponentInternal.template;
|
|
3219
3223
|
|
|
3220
|
-
|
|
3224
|
+
var stylesheetToken = template.stylesheetToken;
|
|
3225
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
3221
3226
|
}
|
|
3222
3227
|
|
|
3223
3228
|
function getNearestNativeShadowComponent(vm) {
|
|
@@ -3266,78 +3271,6 @@
|
|
|
3266
3271
|
|
|
3267
3272
|
return null;
|
|
3268
3273
|
}
|
|
3269
|
-
/*
|
|
3270
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
3271
|
-
* All rights reserved.
|
|
3272
|
-
* SPDX-License-Identifier: MIT
|
|
3273
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3274
|
-
*/
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
function checkHasVM(elm) {
|
|
3278
|
-
var hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
3279
|
-
|
|
3280
|
-
return hasVM;
|
|
3281
|
-
}
|
|
3282
|
-
|
|
3283
|
-
function getUpgradableConstructor(tagName, renderer) {
|
|
3284
|
-
var getCustomElement = renderer.getCustomElement,
|
|
3285
|
-
RendererHTMLElement = renderer.HTMLElementExported,
|
|
3286
|
-
defineCustomElement = renderer.defineCustomElement; // Should never get a tag with upper case letter at this point, the compiler should
|
|
3287
|
-
// produce only tags with lowercase letters
|
|
3288
|
-
// But, for backwards compatibility, we will lower case the tagName
|
|
3289
|
-
|
|
3290
|
-
tagName = tagName.toLowerCase();
|
|
3291
|
-
var CE = getCustomElement(tagName);
|
|
3292
|
-
|
|
3293
|
-
if (!isUndefined$1(CE)) {
|
|
3294
|
-
return CE;
|
|
3295
|
-
}
|
|
3296
|
-
/**
|
|
3297
|
-
* LWC Upgradable Element reference to an element that was created
|
|
3298
|
-
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3299
|
-
*/
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
CE = /*#__PURE__*/function (_RendererHTMLElement) {
|
|
3303
|
-
_inherits(LWCUpgradableElement, _RendererHTMLElement);
|
|
3304
|
-
|
|
3305
|
-
var _super5 = _createSuper(LWCUpgradableElement);
|
|
3306
|
-
|
|
3307
|
-
function LWCUpgradableElement(upgradeCallback) {
|
|
3308
|
-
var _this4;
|
|
3309
|
-
|
|
3310
|
-
_classCallCheck(this, LWCUpgradableElement);
|
|
3311
|
-
|
|
3312
|
-
_this4 = _super5.call(this);
|
|
3313
|
-
|
|
3314
|
-
if (isFunction$1(upgradeCallback)) {
|
|
3315
|
-
upgradeCallback(_assertThisInitialized(_this4)); // nothing to do with the result for now
|
|
3316
|
-
}
|
|
3317
|
-
|
|
3318
|
-
return _this4;
|
|
3319
|
-
}
|
|
3320
|
-
|
|
3321
|
-
return _createClass(LWCUpgradableElement);
|
|
3322
|
-
}(RendererHTMLElement);
|
|
3323
|
-
|
|
3324
|
-
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3325
|
-
CE.prototype.connectedCallback = function () {
|
|
3326
|
-
if (checkHasVM(this)) {
|
|
3327
|
-
connectRootElement(this);
|
|
3328
|
-
}
|
|
3329
|
-
};
|
|
3330
|
-
|
|
3331
|
-
CE.prototype.disconnectedCallback = function () {
|
|
3332
|
-
if (checkHasVM(this)) {
|
|
3333
|
-
disconnectRootElement(this);
|
|
3334
|
-
}
|
|
3335
|
-
};
|
|
3336
|
-
}
|
|
3337
|
-
|
|
3338
|
-
defineCustomElement(tagName, CE);
|
|
3339
|
-
return CE;
|
|
3340
|
-
}
|
|
3341
3274
|
/*
|
|
3342
3275
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3343
3276
|
* All rights reserved.
|
|
@@ -3870,7 +3803,7 @@
|
|
|
3870
3803
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3871
3804
|
var sel = vnode.sel,
|
|
3872
3805
|
owner = vnode.owner;
|
|
3873
|
-
var
|
|
3806
|
+
var createCustomElement = renderer.createCustomElement;
|
|
3874
3807
|
/**
|
|
3875
3808
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3876
3809
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -3879,10 +3812,25 @@
|
|
|
3879
3812
|
*/
|
|
3880
3813
|
|
|
3881
3814
|
var vm;
|
|
3882
|
-
|
|
3815
|
+
|
|
3816
|
+
var upgradeCallback = function upgradeCallback(elm) {
|
|
3883
3817
|
// the custom element from the registry is expecting an upgrade callback
|
|
3884
3818
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
3885
|
-
}
|
|
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);
|
|
3886
3834
|
vnode.elm = elm;
|
|
3887
3835
|
vnode.vm = vm;
|
|
3888
3836
|
linkNodeToShadow(elm, owner, renderer);
|
|
@@ -3890,8 +3838,6 @@
|
|
|
3890
3838
|
|
|
3891
3839
|
if (vm) {
|
|
3892
3840
|
allocateChildren(vnode, vm);
|
|
3893
|
-
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
3894
|
-
throw new TypeError("Incorrect Component Constructor");
|
|
3895
3841
|
}
|
|
3896
3842
|
|
|
3897
3843
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
@@ -5866,21 +5812,21 @@
|
|
|
5866
5812
|
var WireContextRegistrationEvent = /*#__PURE__*/function (_CustomEvent) {
|
|
5867
5813
|
_inherits(WireContextRegistrationEvent, _CustomEvent);
|
|
5868
5814
|
|
|
5869
|
-
var
|
|
5815
|
+
var _super5 = _createSuper(WireContextRegistrationEvent);
|
|
5870
5816
|
|
|
5871
5817
|
function WireContextRegistrationEvent(adapterToken, _ref3) {
|
|
5872
|
-
var
|
|
5818
|
+
var _this4;
|
|
5873
5819
|
|
|
5874
5820
|
var setNewContext = _ref3.setNewContext,
|
|
5875
5821
|
setDisconnectedCallback = _ref3.setDisconnectedCallback;
|
|
5876
5822
|
|
|
5877
5823
|
_classCallCheck(this, WireContextRegistrationEvent);
|
|
5878
5824
|
|
|
5879
|
-
|
|
5825
|
+
_this4 = _super5.call(this, adapterToken, {
|
|
5880
5826
|
bubbles: true,
|
|
5881
5827
|
composed: true
|
|
5882
5828
|
});
|
|
5883
|
-
defineProperties(_assertThisInitialized(
|
|
5829
|
+
defineProperties(_assertThisInitialized(_this4), {
|
|
5884
5830
|
setNewContext: {
|
|
5885
5831
|
value: setNewContext
|
|
5886
5832
|
},
|
|
@@ -5888,7 +5834,7 @@
|
|
|
5888
5834
|
value: setDisconnectedCallback
|
|
5889
5835
|
}
|
|
5890
5836
|
});
|
|
5891
|
-
return
|
|
5837
|
+
return _this4;
|
|
5892
5838
|
}
|
|
5893
5839
|
|
|
5894
5840
|
return _createClass(WireContextRegistrationEvent);
|
|
@@ -6527,13 +6473,27 @@
|
|
|
6527
6473
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
6528
6474
|
// are rendered during SSR. This needs to be accounted for when validating.
|
|
6529
6475
|
|
|
6530
|
-
if (scopedToken) {
|
|
6476
|
+
if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
|
|
6531
6477
|
if (!isUndefined$1(className)) {
|
|
6532
|
-
|
|
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, ' ');
|
|
6533
6484
|
} else if (!isUndefined$1(classMap)) {
|
|
6534
|
-
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) : {});
|
|
6535
6486
|
} else {
|
|
6536
|
-
|
|
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
|
+
}
|
|
6537
6497
|
}
|
|
6538
6498
|
}
|
|
6539
6499
|
|
|
@@ -6704,7 +6664,7 @@
|
|
|
6704
6664
|
|
|
6705
6665
|
return ctor;
|
|
6706
6666
|
}
|
|
6707
|
-
/* version: 2.
|
|
6667
|
+
/* version: 2.26.0 */
|
|
6708
6668
|
|
|
6709
6669
|
/*
|
|
6710
6670
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6855,6 +6815,779 @@
|
|
|
6855
6815
|
insertLocalStylesheet(content, target);
|
|
6856
6816
|
}
|
|
6857
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
|
+
}
|
|
6858
7591
|
/*
|
|
6859
7592
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
6860
7593
|
* All rights reserved.
|
|
@@ -6923,7 +7656,7 @@
|
|
|
6923
7656
|
function isNull(obj) {
|
|
6924
7657
|
return obj === null;
|
|
6925
7658
|
}
|
|
6926
|
-
/** version: 2.
|
|
7659
|
+
/** version: 2.26.0 */
|
|
6927
7660
|
|
|
6928
7661
|
/*
|
|
6929
7662
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6933,87 +7666,6 @@
|
|
|
6933
7666
|
*/
|
|
6934
7667
|
|
|
6935
7668
|
|
|
6936
|
-
exports.getCustomElement = void 0;
|
|
6937
|
-
exports.defineCustomElement = void 0;
|
|
6938
|
-
var HTMLElementConstructor;
|
|
6939
|
-
|
|
6940
|
-
function isCustomElementRegistryAvailable() {
|
|
6941
|
-
if (typeof customElements === 'undefined') {
|
|
6942
|
-
return false;
|
|
6943
|
-
}
|
|
6944
|
-
|
|
6945
|
-
try {
|
|
6946
|
-
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
6947
|
-
// _wrapNativeSuper()
|
|
6948
|
-
// This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
|
|
6949
|
-
// get wrapped by babel.
|
|
6950
|
-
var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
|
|
6951
|
-
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
6952
|
-
// which are not equipped to be initialized that way.
|
|
6953
|
-
|
|
6954
|
-
var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
|
|
6955
|
-
_inherits(clazz, _HTMLElementAlias);
|
|
6956
|
-
|
|
6957
|
-
var _super7 = _createSuper(clazz);
|
|
6958
|
-
|
|
6959
|
-
function clazz() {
|
|
6960
|
-
_classCallCheck(this, clazz);
|
|
6961
|
-
|
|
6962
|
-
return _super7.apply(this, arguments);
|
|
6963
|
-
}
|
|
6964
|
-
|
|
6965
|
-
return _createClass(clazz);
|
|
6966
|
-
}(HTMLElementAlias);
|
|
6967
|
-
|
|
6968
|
-
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
6969
|
-
new clazz();
|
|
6970
|
-
return true;
|
|
6971
|
-
} catch (_a) {
|
|
6972
|
-
return false;
|
|
6973
|
-
}
|
|
6974
|
-
}
|
|
6975
|
-
|
|
6976
|
-
if (isCustomElementRegistryAvailable()) {
|
|
6977
|
-
exports.getCustomElement = customElements.get.bind(customElements);
|
|
6978
|
-
exports.defineCustomElement = customElements.define.bind(customElements);
|
|
6979
|
-
HTMLElementConstructor = HTMLElement;
|
|
6980
|
-
} else {
|
|
6981
|
-
var registry = Object.create(null);
|
|
6982
|
-
var reverseRegistry = new WeakMap();
|
|
6983
|
-
|
|
6984
|
-
exports.defineCustomElement = function define(name, ctor) {
|
|
6985
|
-
if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
|
|
6986
|
-
throw new TypeError("Invalid Registration");
|
|
6987
|
-
}
|
|
6988
|
-
|
|
6989
|
-
registry[name] = ctor;
|
|
6990
|
-
reverseRegistry.set(ctor, name);
|
|
6991
|
-
};
|
|
6992
|
-
|
|
6993
|
-
exports.getCustomElement = function get(name) {
|
|
6994
|
-
return registry[name];
|
|
6995
|
-
};
|
|
6996
|
-
|
|
6997
|
-
HTMLElementConstructor = function HTMLElement() {
|
|
6998
|
-
if (!(this instanceof HTMLElement)) {
|
|
6999
|
-
throw new TypeError("Invalid Invocation");
|
|
7000
|
-
}
|
|
7001
|
-
|
|
7002
|
-
var constructor = this.constructor;
|
|
7003
|
-
var name = reverseRegistry.get(constructor);
|
|
7004
|
-
|
|
7005
|
-
if (!name) {
|
|
7006
|
-
throw new TypeError("Invalid Construction");
|
|
7007
|
-
}
|
|
7008
|
-
|
|
7009
|
-
var elm = document.createElement(name);
|
|
7010
|
-
Object.setPrototypeOf(elm, constructor.prototype);
|
|
7011
|
-
return elm;
|
|
7012
|
-
};
|
|
7013
|
-
|
|
7014
|
-
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
7015
|
-
}
|
|
7016
|
-
|
|
7017
7669
|
function cloneNode(node, deep) {
|
|
7018
7670
|
return node.cloneNode(deep);
|
|
7019
7671
|
}
|
|
@@ -7072,18 +7724,18 @@
|
|
|
7072
7724
|
var wrapperTags = topLevelWrappingMap[getTagName(html)];
|
|
7073
7725
|
|
|
7074
7726
|
if (!isUndefined(wrapperTags)) {
|
|
7075
|
-
var
|
|
7076
|
-
|
|
7727
|
+
var _iterator7 = _createForOfIteratorHelper(wrapperTags),
|
|
7728
|
+
_step7;
|
|
7077
7729
|
|
|
7078
7730
|
try {
|
|
7079
|
-
for (
|
|
7080
|
-
var wrapperTag =
|
|
7731
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
7732
|
+
var wrapperTag = _step7.value;
|
|
7081
7733
|
html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
|
|
7082
7734
|
}
|
|
7083
7735
|
} catch (err) {
|
|
7084
|
-
|
|
7736
|
+
_iterator7.e(err);
|
|
7085
7737
|
} finally {
|
|
7086
|
-
|
|
7738
|
+
_iterator7.f();
|
|
7087
7739
|
}
|
|
7088
7740
|
} // For IE11, the document title must not be undefined, but it can be an empty string
|
|
7089
7741
|
// https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
|
|
@@ -7229,8 +7881,6 @@
|
|
|
7229
7881
|
assert.invariant(elm instanceof HTMLElement, msg);
|
|
7230
7882
|
}
|
|
7231
7883
|
|
|
7232
|
-
var HTMLElementExported = HTMLElementConstructor;
|
|
7233
|
-
exports.HTMLElementExported = HTMLElementExported;
|
|
7234
7884
|
exports.addEventListener = addEventListener;
|
|
7235
7885
|
exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
|
|
7236
7886
|
exports.attachShadow = attachShadow;
|
|
@@ -7289,6 +7939,8 @@
|
|
|
7289
7939
|
{
|
|
7290
7940
|
// insertStyleSheet implementation shares a global cache of stylesheet data
|
|
7291
7941
|
insertStylesheet: insertStylesheet,
|
|
7942
|
+
// relies on a shared global cache
|
|
7943
|
+
createCustomElement: createCustomElement,
|
|
7292
7944
|
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
7293
7945
|
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN)
|
|
7294
7946
|
});
|
|
@@ -7405,35 +8057,39 @@
|
|
|
7405
8057
|
var hydratedCustomElements = new WeakSet();
|
|
7406
8058
|
|
|
7407
8059
|
function buildCustomElementConstructor(Ctor) {
|
|
8060
|
+
var _a;
|
|
8061
|
+
|
|
7408
8062
|
var HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
7409
|
-
|
|
7410
|
-
|
|
8063
|
+
var observedAttributes = HtmlPrototype.observedAttributes;
|
|
8064
|
+
var _attributeChangedCallback = HtmlPrototype.prototype.attributeChangedCallback;
|
|
8065
|
+
return _a = /*#__PURE__*/function (_HTMLElement2) {
|
|
8066
|
+
_inherits(_a, _HTMLElement2);
|
|
7411
8067
|
|
|
7412
|
-
var
|
|
8068
|
+
var _super10 = _createSuper(_a);
|
|
7413
8069
|
|
|
7414
|
-
function
|
|
7415
|
-
var
|
|
8070
|
+
function _a() {
|
|
8071
|
+
var _this8;
|
|
7416
8072
|
|
|
7417
|
-
_classCallCheck(this,
|
|
8073
|
+
_classCallCheck(this, _a);
|
|
7418
8074
|
|
|
7419
|
-
|
|
8075
|
+
_this8 = _super10.call(this);
|
|
7420
8076
|
|
|
7421
|
-
if (
|
|
8077
|
+
if (_this8.isConnected) {
|
|
7422
8078
|
// this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
|
|
7423
|
-
hydrateComponent(_assertThisInitialized(
|
|
7424
|
-
hydratedCustomElements.add(_assertThisInitialized(
|
|
8079
|
+
hydrateComponent(_assertThisInitialized(_this8), Ctor, {});
|
|
8080
|
+
hydratedCustomElements.add(_assertThisInitialized(_this8));
|
|
7425
8081
|
} else {
|
|
7426
|
-
createVM(_assertThisInitialized(
|
|
8082
|
+
createVM(_assertThisInitialized(_this8), Ctor, renderer, {
|
|
7427
8083
|
mode: 'open',
|
|
7428
8084
|
owner: null,
|
|
7429
|
-
tagName:
|
|
8085
|
+
tagName: _this8.tagName
|
|
7430
8086
|
});
|
|
7431
8087
|
}
|
|
7432
8088
|
|
|
7433
|
-
return
|
|
8089
|
+
return _this8;
|
|
7434
8090
|
}
|
|
7435
8091
|
|
|
7436
|
-
_createClass(
|
|
8092
|
+
_createClass(_a, [{
|
|
7437
8093
|
key: "connectedCallback",
|
|
7438
8094
|
value: function connectedCallback() {
|
|
7439
8095
|
if (hydratedCustomElements.has(this)) {
|
|
@@ -7448,10 +8104,15 @@
|
|
|
7448
8104
|
value: function disconnectedCallback() {
|
|
7449
8105
|
disconnectRootElement(this);
|
|
7450
8106
|
}
|
|
8107
|
+
}, {
|
|
8108
|
+
key: "attributeChangedCallback",
|
|
8109
|
+
value: function attributeChangedCallback(name, oldValue, newValue) {
|
|
8110
|
+
_attributeChangedCallback.call(this, name, oldValue, newValue);
|
|
8111
|
+
}
|
|
7451
8112
|
}]);
|
|
7452
8113
|
|
|
7453
|
-
return
|
|
7454
|
-
}(
|
|
8114
|
+
return _a;
|
|
8115
|
+
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement)), _a.observedAttributes = observedAttributes, _a;
|
|
7455
8116
|
}
|
|
7456
8117
|
/*
|
|
7457
8118
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7534,8 +8195,11 @@
|
|
|
7534
8195
|
throw new TypeError("\"createElement\" function expects an \"is\" option with a valid component constructor.");
|
|
7535
8196
|
}
|
|
7536
8197
|
|
|
7537
|
-
var
|
|
7538
|
-
|
|
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
|
|
7539
8203
|
|
|
7540
8204
|
/**
|
|
7541
8205
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
@@ -7544,9 +8208,9 @@
|
|
|
7544
8208
|
* an upgradable custom element.
|
|
7545
8209
|
*/
|
|
7546
8210
|
|
|
7547
|
-
var
|
|
8211
|
+
var upgradeCallback = function upgradeCallback(elm) {
|
|
7548
8212
|
createVM(elm, Ctor, renderer, {
|
|
7549
|
-
tagName:
|
|
8213
|
+
tagName: tagName,
|
|
7550
8214
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
7551
8215
|
owner: null
|
|
7552
8216
|
});
|
|
@@ -7555,15 +8219,21 @@
|
|
|
7555
8219
|
ConnectingSlot.set(elm, connectRootElement);
|
|
7556
8220
|
DisconnectingSlot.set(elm, disconnectRootElement);
|
|
7557
8221
|
}
|
|
8222
|
+
};
|
|
7558
8223
|
|
|
7559
|
-
|
|
7560
|
-
|
|
8224
|
+
var connectedCallback = function connectedCallback(elm) {
|
|
8225
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8226
|
+
connectRootElement(elm);
|
|
8227
|
+
}
|
|
8228
|
+
};
|
|
7561
8229
|
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
8230
|
+
var disconnectedCallback = function disconnectedCallback(elm) {
|
|
8231
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8232
|
+
disconnectRootElement(elm);
|
|
8233
|
+
}
|
|
8234
|
+
};
|
|
7566
8235
|
|
|
8236
|
+
var element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
7567
8237
|
return element;
|
|
7568
8238
|
}
|
|
7569
8239
|
/*
|
|
@@ -7646,7 +8316,7 @@
|
|
|
7646
8316
|
});
|
|
7647
8317
|
freeze(LightningElement);
|
|
7648
8318
|
seal(LightningElement.prototype);
|
|
7649
|
-
/* version: 2.
|
|
8319
|
+
/* version: 2.26.0 */
|
|
7650
8320
|
|
|
7651
8321
|
exports.LightningElement = LightningElement;
|
|
7652
8322
|
exports.__unstable__ProfilerControl = profilerControl;
|