lwc 2.25.1 → 2.26.1
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 +890 -411
- package/dist/engine-dom/iife/es2017/engine-dom.js +890 -411
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +736 -205
- package/dist/engine-dom/iife/es5/engine-dom.js +959 -311
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +888 -224
- package/dist/engine-dom/umd/es2017/engine-dom.js +890 -411
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +736 -205
- package/dist/engine-dom/umd/es5/engine-dom.js +959 -311
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +888 -224
- package/dist/engine-server/commonjs/es2017/engine-server.js +138 -227
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +138 -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 +8 -8
|
@@ -122,6 +122,7 @@ var LWC = (function (exports) {
|
|
|
122
122
|
var _Array$prototype = Array.prototype,
|
|
123
123
|
ArrayCopyWithin = _Array$prototype.copyWithin,
|
|
124
124
|
ArrayFill = _Array$prototype.fill,
|
|
125
|
+
ArrayFilter = _Array$prototype.filter,
|
|
125
126
|
ArrayIndexOf = _Array$prototype.indexOf,
|
|
126
127
|
ArrayJoin = _Array$prototype.join,
|
|
127
128
|
ArrayMap = _Array$prototype.map,
|
|
@@ -365,9 +366,9 @@ var LWC = (function (exports) {
|
|
|
365
366
|
// Increment whenever the LWC template compiler changes
|
|
366
367
|
|
|
367
368
|
|
|
368
|
-
var LWC_VERSION = "2.
|
|
369
|
+
var LWC_VERSION = "2.26.1";
|
|
369
370
|
var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
370
|
-
/** version: 2.
|
|
371
|
+
/** version: 2.26.1 */
|
|
371
372
|
|
|
372
373
|
/**
|
|
373
374
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -461,7 +462,7 @@ var LWC = (function (exports) {
|
|
|
461
462
|
patch$1(propName);
|
|
462
463
|
}
|
|
463
464
|
}
|
|
464
|
-
/** version: 2.
|
|
465
|
+
/** version: 2.26.1 */
|
|
465
466
|
|
|
466
467
|
/**
|
|
467
468
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -479,7 +480,6 @@ var LWC = (function (exports) {
|
|
|
479
480
|
DUMMY_TEST_FLAG: null,
|
|
480
481
|
ENABLE_ELEMENT_PATCH: null,
|
|
481
482
|
ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
|
|
482
|
-
ENABLE_HMR: null,
|
|
483
483
|
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
484
484
|
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
485
485
|
ENABLE_MIXED_SHADOW_MODE: null,
|
|
@@ -489,7 +489,8 @@ var LWC = (function (exports) {
|
|
|
489
489
|
ENABLE_REACTIVE_SETTER: null,
|
|
490
490
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
491
491
|
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
492
|
-
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null
|
|
492
|
+
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
493
|
+
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null
|
|
493
494
|
};
|
|
494
495
|
|
|
495
496
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
@@ -555,7 +556,7 @@ var LWC = (function (exports) {
|
|
|
555
556
|
setFeatureFlag(name, value);
|
|
556
557
|
}
|
|
557
558
|
}
|
|
558
|
-
/** version: 2.
|
|
559
|
+
/** version: 2.26.1 */
|
|
559
560
|
|
|
560
561
|
/*
|
|
561
562
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -2423,7 +2424,9 @@ var LWC = (function (exports) {
|
|
|
2423
2424
|
var LightningElement = function LightningElement() {
|
|
2424
2425
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
2425
2426
|
if (isNull(vmBeingConstructed)) {
|
|
2426
|
-
|
|
2427
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
2428
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
2429
|
+
throw new TypeError('Illegal constructor');
|
|
2427
2430
|
}
|
|
2428
2431
|
|
|
2429
2432
|
var vm = vmBeingConstructed;
|
|
@@ -3787,13 +3790,11 @@ var LWC = (function (exports) {
|
|
|
3787
3790
|
throw new ReferenceError();
|
|
3788
3791
|
}
|
|
3789
3792
|
|
|
3790
|
-
|
|
3791
|
-
var visited = new Set();
|
|
3793
|
+
var visited = new Set();
|
|
3792
3794
|
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
}
|
|
3795
|
+
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
|
3796
|
+
visited.add(tpl);
|
|
3797
|
+
tpl = swappedTemplateMap.get(tpl);
|
|
3797
3798
|
}
|
|
3798
3799
|
|
|
3799
3800
|
return tpl;
|
|
@@ -3805,13 +3806,11 @@ var LWC = (function (exports) {
|
|
|
3805
3806
|
throw new ReferenceError();
|
|
3806
3807
|
}
|
|
3807
3808
|
|
|
3808
|
-
|
|
3809
|
-
var visited = new Set();
|
|
3809
|
+
var visited = new Set();
|
|
3810
3810
|
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
}
|
|
3811
|
+
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
|
3812
|
+
visited.add(Ctor);
|
|
3813
|
+
Ctor = swappedComponentMap.get(Ctor);
|
|
3815
3814
|
}
|
|
3816
3815
|
|
|
3817
3816
|
return Ctor;
|
|
@@ -3823,13 +3822,11 @@ var LWC = (function (exports) {
|
|
|
3823
3822
|
throw new ReferenceError();
|
|
3824
3823
|
}
|
|
3825
3824
|
|
|
3826
|
-
|
|
3827
|
-
var visited = new Set();
|
|
3825
|
+
var visited = new Set();
|
|
3828
3826
|
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
}
|
|
3827
|
+
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
|
3828
|
+
visited.add(style);
|
|
3829
|
+
style = swappedStyleMap.get(style);
|
|
3833
3830
|
}
|
|
3834
3831
|
|
|
3835
3832
|
return style;
|
|
@@ -3839,56 +3836,54 @@ var LWC = (function (exports) {
|
|
|
3839
3836
|
if (process.env.NODE_ENV === 'production') {
|
|
3840
3837
|
// this method should never leak to prod
|
|
3841
3838
|
throw new ReferenceError();
|
|
3842
|
-
}
|
|
3839
|
+
} // tracking active component
|
|
3843
3840
|
|
|
3844
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3845
|
-
// tracking active component
|
|
3846
|
-
var Ctor = vm.def.ctor;
|
|
3847
|
-
var componentVMs = activeComponents.get(Ctor);
|
|
3848
3841
|
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
activeComponents.set(Ctor, componentVMs);
|
|
3852
|
-
} // this will allow us to keep track of the hot components
|
|
3842
|
+
var Ctor = vm.def.ctor;
|
|
3843
|
+
var componentVMs = activeComponents.get(Ctor);
|
|
3853
3844
|
|
|
3845
|
+
if (isUndefined$1(componentVMs)) {
|
|
3846
|
+
componentVMs = new Set();
|
|
3847
|
+
activeComponents.set(Ctor, componentVMs);
|
|
3848
|
+
} // this will allow us to keep track of the hot components
|
|
3854
3849
|
|
|
3855
|
-
componentVMs.add(vm); // tracking active template
|
|
3856
3850
|
|
|
3857
|
-
|
|
3851
|
+
componentVMs.add(vm); // tracking active template
|
|
3858
3852
|
|
|
3859
|
-
|
|
3860
|
-
var templateVMs = activeTemplates.get(tpl);
|
|
3853
|
+
var tpl = vm.cmpTemplate;
|
|
3861
3854
|
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
activeTemplates.set(tpl, templateVMs);
|
|
3865
|
-
} // this will allow us to keep track of the templates that are
|
|
3866
|
-
// being used by a hot component
|
|
3855
|
+
if (tpl) {
|
|
3856
|
+
var templateVMs = activeTemplates.get(tpl);
|
|
3867
3857
|
|
|
3858
|
+
if (isUndefined$1(templateVMs)) {
|
|
3859
|
+
templateVMs = new Set();
|
|
3860
|
+
activeTemplates.set(tpl, templateVMs);
|
|
3861
|
+
} // this will allow us to keep track of the templates that are
|
|
3862
|
+
// being used by a hot component
|
|
3868
3863
|
|
|
3869
|
-
templateVMs.add(vm); // tracking active styles associated to template
|
|
3870
3864
|
|
|
3871
|
-
|
|
3865
|
+
templateVMs.add(vm); // tracking active styles associated to template
|
|
3872
3866
|
|
|
3873
|
-
|
|
3874
|
-
flattenStylesheets(stylesheets).forEach(function (stylesheet) {
|
|
3875
|
-
// this is necessary because we don't hold the list of styles
|
|
3876
|
-
// in the vm, we only hold the selected (already swapped template)
|
|
3877
|
-
// but the styles attached to the template might not be the actual
|
|
3878
|
-
// active ones, but the swapped versions of those.
|
|
3879
|
-
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3880
|
-
var stylesheetVMs = activeStyles.get(stylesheet);
|
|
3867
|
+
var stylesheets = tpl.stylesheets;
|
|
3881
3868
|
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3869
|
+
if (!isUndefined$1(stylesheets)) {
|
|
3870
|
+
flattenStylesheets(stylesheets).forEach(function (stylesheet) {
|
|
3871
|
+
// this is necessary because we don't hold the list of styles
|
|
3872
|
+
// in the vm, we only hold the selected (already swapped template)
|
|
3873
|
+
// but the styles attached to the template might not be the actual
|
|
3874
|
+
// active ones, but the swapped versions of those.
|
|
3875
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3876
|
+
var stylesheetVMs = activeStyles.get(stylesheet);
|
|
3887
3877
|
|
|
3878
|
+
if (isUndefined$1(stylesheetVMs)) {
|
|
3879
|
+
stylesheetVMs = new Set();
|
|
3880
|
+
activeStyles.set(stylesheet, stylesheetVMs);
|
|
3881
|
+
} // this will allow us to keep track of the stylesheet that are
|
|
3882
|
+
// being used by a hot component
|
|
3888
3883
|
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
}
|
|
3884
|
+
|
|
3885
|
+
stylesheetVMs.add(vm);
|
|
3886
|
+
});
|
|
3892
3887
|
}
|
|
3893
3888
|
}
|
|
3894
3889
|
}
|
|
@@ -3897,42 +3892,40 @@ var LWC = (function (exports) {
|
|
|
3897
3892
|
if (process.env.NODE_ENV === 'production') {
|
|
3898
3893
|
// this method should never leak to prod
|
|
3899
3894
|
throw new ReferenceError();
|
|
3900
|
-
}
|
|
3895
|
+
} // tracking inactive component
|
|
3901
3896
|
|
|
3902
|
-
if (lwcRuntimeFlags.ENABLE_HMR) {
|
|
3903
|
-
// tracking inactive component
|
|
3904
|
-
var Ctor = vm.def.ctor;
|
|
3905
|
-
var list = activeComponents.get(Ctor);
|
|
3906
3897
|
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
list.delete(vm);
|
|
3910
|
-
} // removing inactive template
|
|
3898
|
+
var Ctor = vm.def.ctor;
|
|
3899
|
+
var list = activeComponents.get(Ctor);
|
|
3911
3900
|
|
|
3901
|
+
if (!isUndefined$1(list)) {
|
|
3902
|
+
// deleting the vm from the set to avoid leaking memory
|
|
3903
|
+
list.delete(vm);
|
|
3904
|
+
} // removing inactive template
|
|
3912
3905
|
|
|
3913
|
-
var tpl = vm.cmpTemplate;
|
|
3914
3906
|
|
|
3915
|
-
|
|
3916
|
-
list = activeTemplates.get(tpl);
|
|
3907
|
+
var tpl = vm.cmpTemplate;
|
|
3917
3908
|
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
list.delete(vm);
|
|
3921
|
-
} // removing active styles associated to template
|
|
3909
|
+
if (tpl) {
|
|
3910
|
+
list = activeTemplates.get(tpl);
|
|
3922
3911
|
|
|
3912
|
+
if (!isUndefined$1(list)) {
|
|
3913
|
+
// deleting the vm from the set to avoid leaking memory
|
|
3914
|
+
list.delete(vm);
|
|
3915
|
+
} // removing active styles associated to template
|
|
3923
3916
|
|
|
3924
|
-
var styles = tpl.stylesheets;
|
|
3925
3917
|
|
|
3926
|
-
|
|
3927
|
-
flattenStylesheets(styles).forEach(function (style) {
|
|
3928
|
-
list = activeStyles.get(style);
|
|
3918
|
+
var styles = tpl.stylesheets;
|
|
3929
3919
|
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3920
|
+
if (!isUndefined$1(styles)) {
|
|
3921
|
+
flattenStylesheets(styles).forEach(function (style) {
|
|
3922
|
+
list = activeStyles.get(style);
|
|
3923
|
+
|
|
3924
|
+
if (!isUndefined$1(list)) {
|
|
3925
|
+
// deleting the vm from the set to avoid leaking memory
|
|
3926
|
+
list.delete(vm);
|
|
3927
|
+
}
|
|
3928
|
+
});
|
|
3936
3929
|
}
|
|
3937
3930
|
}
|
|
3938
3931
|
}
|
|
@@ -3947,10 +3940,6 @@ var LWC = (function (exports) {
|
|
|
3947
3940
|
}
|
|
3948
3941
|
}
|
|
3949
3942
|
|
|
3950
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3951
|
-
throw new Error('HMR is not enabled');
|
|
3952
|
-
}
|
|
3953
|
-
|
|
3954
3943
|
return false;
|
|
3955
3944
|
}
|
|
3956
3945
|
|
|
@@ -3964,10 +3953,6 @@ var LWC = (function (exports) {
|
|
|
3964
3953
|
}
|
|
3965
3954
|
}
|
|
3966
3955
|
|
|
3967
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3968
|
-
throw new Error('HMR is not enabled');
|
|
3969
|
-
}
|
|
3970
|
-
|
|
3971
3956
|
return false;
|
|
3972
3957
|
}
|
|
3973
3958
|
|
|
@@ -3979,10 +3964,6 @@ var LWC = (function (exports) {
|
|
|
3979
3964
|
return rehydrateHotStyle(oldStyle);
|
|
3980
3965
|
}
|
|
3981
3966
|
|
|
3982
|
-
if (!lwcRuntimeFlags.ENABLE_HMR) {
|
|
3983
|
-
throw new Error('HMR is not enabled');
|
|
3984
|
-
}
|
|
3985
|
-
|
|
3986
3967
|
return false;
|
|
3987
3968
|
}
|
|
3988
3969
|
/*
|
|
@@ -4448,14 +4429,17 @@ var LWC = (function (exports) {
|
|
|
4448
4429
|
/**
|
|
4449
4430
|
* This function returns the host style token for a custom element if it
|
|
4450
4431
|
* exists. Otherwise it returns null.
|
|
4432
|
+
*
|
|
4433
|
+
* A host style token is applied to the component if scoped styles are used.
|
|
4451
4434
|
*/
|
|
4452
4435
|
|
|
4453
4436
|
|
|
4454
4437
|
function getStylesheetTokenHost(vnode) {
|
|
4455
4438
|
var _getComponentInternal = getComponentInternalDef(vnode.ctor),
|
|
4456
|
-
|
|
4439
|
+
template = _getComponentInternal.template;
|
|
4457
4440
|
|
|
4458
|
-
|
|
4441
|
+
var stylesheetToken = template.stylesheetToken;
|
|
4442
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
4459
4443
|
}
|
|
4460
4444
|
|
|
4461
4445
|
function getNearestNativeShadowComponent(vm) {
|
|
@@ -4504,84 +4488,6 @@ var LWC = (function (exports) {
|
|
|
4504
4488
|
|
|
4505
4489
|
return null;
|
|
4506
4490
|
}
|
|
4507
|
-
/*
|
|
4508
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
4509
|
-
* All rights reserved.
|
|
4510
|
-
* SPDX-License-Identifier: MIT
|
|
4511
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4512
|
-
*/
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
function checkHasVM(elm) {
|
|
4516
|
-
var hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
4517
|
-
|
|
4518
|
-
if (process.env.NODE_ENV !== 'production' && !hasVM) {
|
|
4519
|
-
// Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
|
|
4520
|
-
// we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
|
|
4521
|
-
logError("VM for tag name \"".concat(elm.tagName.toLowerCase(), "\" is undefined. ") + "This indicates that an element was created with this tag name, " + "which is already reserved by an LWC component. Use lwc.createElement " + "instead to create elements.");
|
|
4522
|
-
}
|
|
4523
|
-
|
|
4524
|
-
return hasVM;
|
|
4525
|
-
}
|
|
4526
|
-
|
|
4527
|
-
function getUpgradableConstructor(tagName, renderer) {
|
|
4528
|
-
var getCustomElement = renderer.getCustomElement,
|
|
4529
|
-
RendererHTMLElement = renderer.HTMLElementExported,
|
|
4530
|
-
defineCustomElement = renderer.defineCustomElement; // Should never get a tag with upper case letter at this point, the compiler should
|
|
4531
|
-
// produce only tags with lowercase letters
|
|
4532
|
-
// But, for backwards compatibility, we will lower case the tagName
|
|
4533
|
-
|
|
4534
|
-
tagName = tagName.toLowerCase();
|
|
4535
|
-
var CE = getCustomElement(tagName);
|
|
4536
|
-
|
|
4537
|
-
if (!isUndefined$1(CE)) {
|
|
4538
|
-
return CE;
|
|
4539
|
-
}
|
|
4540
|
-
/**
|
|
4541
|
-
* LWC Upgradable Element reference to an element that was created
|
|
4542
|
-
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
4543
|
-
*/
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
CE = /*#__PURE__*/function (_RendererHTMLElement) {
|
|
4547
|
-
_inherits(LWCUpgradableElement, _RendererHTMLElement);
|
|
4548
|
-
|
|
4549
|
-
var _super5 = _createSuper(LWCUpgradableElement);
|
|
4550
|
-
|
|
4551
|
-
function LWCUpgradableElement(upgradeCallback) {
|
|
4552
|
-
var _this4;
|
|
4553
|
-
|
|
4554
|
-
_classCallCheck(this, LWCUpgradableElement);
|
|
4555
|
-
|
|
4556
|
-
_this4 = _super5.call(this);
|
|
4557
|
-
|
|
4558
|
-
if (isFunction$1(upgradeCallback)) {
|
|
4559
|
-
upgradeCallback(_assertThisInitialized(_this4)); // nothing to do with the result for now
|
|
4560
|
-
}
|
|
4561
|
-
|
|
4562
|
-
return _this4;
|
|
4563
|
-
}
|
|
4564
|
-
|
|
4565
|
-
return _createClass(LWCUpgradableElement);
|
|
4566
|
-
}(RendererHTMLElement);
|
|
4567
|
-
|
|
4568
|
-
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4569
|
-
CE.prototype.connectedCallback = function () {
|
|
4570
|
-
if (checkHasVM(this)) {
|
|
4571
|
-
connectRootElement(this);
|
|
4572
|
-
}
|
|
4573
|
-
};
|
|
4574
|
-
|
|
4575
|
-
CE.prototype.disconnectedCallback = function () {
|
|
4576
|
-
if (checkHasVM(this)) {
|
|
4577
|
-
disconnectRootElement(this);
|
|
4578
|
-
}
|
|
4579
|
-
};
|
|
4580
|
-
}
|
|
4581
|
-
|
|
4582
|
-
defineCustomElement(tagName, CE);
|
|
4583
|
-
return CE;
|
|
4584
|
-
}
|
|
4585
4491
|
/*
|
|
4586
4492
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4587
4493
|
* All rights reserved.
|
|
@@ -5141,7 +5047,7 @@ var LWC = (function (exports) {
|
|
|
5141
5047
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
5142
5048
|
var sel = vnode.sel,
|
|
5143
5049
|
owner = vnode.owner;
|
|
5144
|
-
var
|
|
5050
|
+
var createCustomElement = renderer.createCustomElement;
|
|
5145
5051
|
/**
|
|
5146
5052
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
5147
5053
|
* with a callback as the first argument, we could implement a more advanced
|
|
@@ -5150,10 +5056,30 @@ var LWC = (function (exports) {
|
|
|
5150
5056
|
*/
|
|
5151
5057
|
|
|
5152
5058
|
var vm;
|
|
5153
|
-
|
|
5059
|
+
|
|
5060
|
+
var upgradeCallback = function upgradeCallback(elm) {
|
|
5154
5061
|
// the custom element from the registry is expecting an upgrade callback
|
|
5155
5062
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
5156
|
-
}
|
|
5063
|
+
};
|
|
5064
|
+
|
|
5065
|
+
var connectedCallback = function connectedCallback(elm) {
|
|
5066
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
5067
|
+
connectRootElement(elm);
|
|
5068
|
+
}
|
|
5069
|
+
};
|
|
5070
|
+
|
|
5071
|
+
var disconnectedCallback = function disconnectedCallback(elm) {
|
|
5072
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
5073
|
+
disconnectRootElement(elm);
|
|
5074
|
+
}
|
|
5075
|
+
}; // Should never get a tag with upper case letter at this point; the compiler
|
|
5076
|
+
// should produce only tags with lowercase letters. However, the Java
|
|
5077
|
+
// compiler may generate tagnames with uppercase letters so - for backwards
|
|
5078
|
+
// compatibility, we lower case the tagname here.
|
|
5079
|
+
|
|
5080
|
+
|
|
5081
|
+
var normalizedTagname = sel.toLowerCase();
|
|
5082
|
+
var elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
5157
5083
|
vnode.elm = elm;
|
|
5158
5084
|
vnode.vm = vm;
|
|
5159
5085
|
linkNodeToShadow(elm, owner, renderer);
|
|
@@ -5161,8 +5087,6 @@ var LWC = (function (exports) {
|
|
|
5161
5087
|
|
|
5162
5088
|
if (vm) {
|
|
5163
5089
|
allocateChildren(vnode, vm);
|
|
5164
|
-
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
5165
|
-
throw new TypeError("Incorrect Component Constructor");
|
|
5166
5090
|
}
|
|
5167
5091
|
|
|
5168
5092
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
@@ -7506,21 +7430,21 @@ var LWC = (function (exports) {
|
|
|
7506
7430
|
var WireContextRegistrationEvent = /*#__PURE__*/function (_CustomEvent) {
|
|
7507
7431
|
_inherits(WireContextRegistrationEvent, _CustomEvent);
|
|
7508
7432
|
|
|
7509
|
-
var
|
|
7433
|
+
var _super5 = _createSuper(WireContextRegistrationEvent);
|
|
7510
7434
|
|
|
7511
7435
|
function WireContextRegistrationEvent(adapterToken, _ref3) {
|
|
7512
|
-
var
|
|
7436
|
+
var _this4;
|
|
7513
7437
|
|
|
7514
7438
|
var setNewContext = _ref3.setNewContext,
|
|
7515
7439
|
setDisconnectedCallback = _ref3.setDisconnectedCallback;
|
|
7516
7440
|
|
|
7517
7441
|
_classCallCheck(this, WireContextRegistrationEvent);
|
|
7518
7442
|
|
|
7519
|
-
|
|
7443
|
+
_this4 = _super5.call(this, adapterToken, {
|
|
7520
7444
|
bubbles: true,
|
|
7521
7445
|
composed: true
|
|
7522
7446
|
});
|
|
7523
|
-
defineProperties(_assertThisInitialized(
|
|
7447
|
+
defineProperties(_assertThisInitialized(_this4), {
|
|
7524
7448
|
setNewContext: {
|
|
7525
7449
|
value: setNewContext
|
|
7526
7450
|
},
|
|
@@ -7528,7 +7452,7 @@ var LWC = (function (exports) {
|
|
|
7528
7452
|
value: setDisconnectedCallback
|
|
7529
7453
|
}
|
|
7530
7454
|
});
|
|
7531
|
-
return
|
|
7455
|
+
return _this4;
|
|
7532
7456
|
}
|
|
7533
7457
|
|
|
7534
7458
|
return _createClass(WireContextRegistrationEvent);
|
|
@@ -8229,13 +8153,27 @@ var LWC = (function (exports) {
|
|
|
8229
8153
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
8230
8154
|
// are rendered during SSR. This needs to be accounted for when validating.
|
|
8231
8155
|
|
|
8232
|
-
if (scopedToken) {
|
|
8156
|
+
if (!isNull(scopedToken) || !isNull(stylesheetTokenHost)) {
|
|
8233
8157
|
if (!isUndefined$1(className)) {
|
|
8234
|
-
|
|
8158
|
+
// The order of the className should be scopedToken className stylesheetTokenHost
|
|
8159
|
+
var classTokens = [scopedToken, className, stylesheetTokenHost];
|
|
8160
|
+
var classNames = ArrayFilter.call(classTokens, function (token) {
|
|
8161
|
+
return !isNull(token);
|
|
8162
|
+
});
|
|
8163
|
+
className = ArrayJoin.call(classNames, ' ');
|
|
8235
8164
|
} else if (!isUndefined$1(classMap)) {
|
|
8236
|
-
classMap = Object.assign(Object.assign(Object.assign({}, classMap), _defineProperty({}, scopedToken, true)), isNull(stylesheetTokenHost) ?
|
|
8165
|
+
classMap = Object.assign(Object.assign(Object.assign({}, classMap), !isNull(scopedToken) ? _defineProperty({}, scopedToken, true) : {}), !isNull(stylesheetTokenHost) ? _defineProperty({}, stylesheetTokenHost, true) : {});
|
|
8237
8166
|
} else {
|
|
8238
|
-
|
|
8167
|
+
// The order of the className should be scopedToken stylesheetTokenHost
|
|
8168
|
+
var _classTokens = [scopedToken, stylesheetTokenHost];
|
|
8169
|
+
|
|
8170
|
+
var _classNames = ArrayFilter.call(_classTokens, function (token) {
|
|
8171
|
+
return !isNull(token);
|
|
8172
|
+
});
|
|
8173
|
+
|
|
8174
|
+
if (_classNames.length) {
|
|
8175
|
+
className = ArrayJoin.call(_classNames, ' ');
|
|
8176
|
+
}
|
|
8239
8177
|
}
|
|
8240
8178
|
}
|
|
8241
8179
|
|
|
@@ -8551,7 +8489,7 @@ var LWC = (function (exports) {
|
|
|
8551
8489
|
|
|
8552
8490
|
return ctor;
|
|
8553
8491
|
}
|
|
8554
|
-
/* version: 2.
|
|
8492
|
+
/* version: 2.26.1 */
|
|
8555
8493
|
|
|
8556
8494
|
/*
|
|
8557
8495
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8711,6 +8649,779 @@ var LWC = (function (exports) {
|
|
|
8711
8649
|
insertLocalStylesheet(content, target);
|
|
8712
8650
|
}
|
|
8713
8651
|
}
|
|
8652
|
+
/*
|
|
8653
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
8654
|
+
* All rights reserved.
|
|
8655
|
+
* SPDX-License-Identifier: MIT
|
|
8656
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8657
|
+
*/
|
|
8658
|
+
|
|
8659
|
+
|
|
8660
|
+
function isCustomElementRegistryAvailable() {
|
|
8661
|
+
if (typeof customElements === 'undefined') {
|
|
8662
|
+
return false;
|
|
8663
|
+
}
|
|
8664
|
+
|
|
8665
|
+
try {
|
|
8666
|
+
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
8667
|
+
// _wrapNativeSuper()
|
|
8668
|
+
// This is a problem because LWCUpgradableElement extends renderer.HTMLElement which does not
|
|
8669
|
+
// get wrapped by babel.
|
|
8670
|
+
var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
|
|
8671
|
+
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
8672
|
+
// which are not equipped to be initialized that way.
|
|
8673
|
+
|
|
8674
|
+
var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
|
|
8675
|
+
_inherits(clazz, _HTMLElementAlias);
|
|
8676
|
+
|
|
8677
|
+
var _super6 = _createSuper(clazz);
|
|
8678
|
+
|
|
8679
|
+
function clazz() {
|
|
8680
|
+
_classCallCheck(this, clazz);
|
|
8681
|
+
|
|
8682
|
+
return _super6.apply(this, arguments);
|
|
8683
|
+
}
|
|
8684
|
+
|
|
8685
|
+
return _createClass(clazz);
|
|
8686
|
+
}(HTMLElementAlias);
|
|
8687
|
+
|
|
8688
|
+
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
8689
|
+
new clazz();
|
|
8690
|
+
return true;
|
|
8691
|
+
} catch (_a) {
|
|
8692
|
+
return false;
|
|
8693
|
+
}
|
|
8694
|
+
}
|
|
8695
|
+
|
|
8696
|
+
var hasCustomElements = isCustomElementRegistryAvailable();
|
|
8697
|
+
/*
|
|
8698
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8699
|
+
* All rights reserved.
|
|
8700
|
+
* SPDX-License-Identifier: MIT
|
|
8701
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8702
|
+
*/
|
|
8703
|
+
// Creates a custom element for compat (legacy) browser environments
|
|
8704
|
+
|
|
8705
|
+
var createCustomElementCompat = function createCustomElementCompat(tagName, upgradeCallback) {
|
|
8706
|
+
var elm = document.createElement(tagName);
|
|
8707
|
+
upgradeCallback(elm); // nothing to do with the result for now
|
|
8708
|
+
|
|
8709
|
+
return elm;
|
|
8710
|
+
};
|
|
8711
|
+
/*
|
|
8712
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8713
|
+
* All rights reserved.
|
|
8714
|
+
* SPDX-License-Identifier: MIT
|
|
8715
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8716
|
+
*/
|
|
8717
|
+
|
|
8718
|
+
|
|
8719
|
+
var cachedConstructors = new Map();
|
|
8720
|
+
var elementsUpgradedOutsideLWC = new WeakSet();
|
|
8721
|
+
var elementBeingUpgradedByLWC = false; // Creates a constructor that is intended to be used as a vanilla custom element, except that the upgradeCallback is
|
|
8722
|
+
// passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
|
|
8723
|
+
// Another benefit is that only LWC can create components that actually do anything – if you do
|
|
8724
|
+
// `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
|
|
8725
|
+
// This class should be created once per tag name.
|
|
8726
|
+
|
|
8727
|
+
var createUpgradableConstructor = function createUpgradableConstructor(_connectedCallback, _disconnectedCallback) {
|
|
8728
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
8729
|
+
return /*#__PURE__*/function (_HTMLElement) {
|
|
8730
|
+
_inherits(UpgradableConstructor, _HTMLElement);
|
|
8731
|
+
|
|
8732
|
+
var _super7 = _createSuper(UpgradableConstructor);
|
|
8733
|
+
|
|
8734
|
+
function UpgradableConstructor(upgradeCallback) {
|
|
8735
|
+
var _this5;
|
|
8736
|
+
|
|
8737
|
+
_classCallCheck(this, UpgradableConstructor);
|
|
8738
|
+
|
|
8739
|
+
_this5 = _super7.call(this); // If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
|
|
8740
|
+
// then elementBeingUpgraded will be false
|
|
8741
|
+
|
|
8742
|
+
if (elementBeingUpgradedByLWC) {
|
|
8743
|
+
upgradeCallback(_assertThisInitialized(_this5));
|
|
8744
|
+
} else {
|
|
8745
|
+
// keep track of elements that were not created by lwc.createElement,
|
|
8746
|
+
// so we can ignore their lifecycle hooks
|
|
8747
|
+
elementsUpgradedOutsideLWC.add(_assertThisInitialized(_this5)); // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
|
|
8748
|
+
// Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
|
|
8749
|
+
}
|
|
8750
|
+
|
|
8751
|
+
return _this5;
|
|
8752
|
+
}
|
|
8753
|
+
|
|
8754
|
+
_createClass(UpgradableConstructor, [{
|
|
8755
|
+
key: "connectedCallback",
|
|
8756
|
+
value: function connectedCallback() {
|
|
8757
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
8758
|
+
_connectedCallback(this);
|
|
8759
|
+
}
|
|
8760
|
+
}
|
|
8761
|
+
}, {
|
|
8762
|
+
key: "disconnectedCallback",
|
|
8763
|
+
value: function disconnectedCallback() {
|
|
8764
|
+
if (!elementsUpgradedOutsideLWC.has(this)) {
|
|
8765
|
+
_disconnectedCallback(this);
|
|
8766
|
+
}
|
|
8767
|
+
}
|
|
8768
|
+
}]);
|
|
8769
|
+
|
|
8770
|
+
return UpgradableConstructor;
|
|
8771
|
+
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
|
|
8772
|
+
};
|
|
8773
|
+
|
|
8774
|
+
var createCustomElementVanilla = function createCustomElementVanilla(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
8775
|
+
// use global custom elements registry
|
|
8776
|
+
var UpgradableConstructor = cachedConstructors.get(tagName);
|
|
8777
|
+
|
|
8778
|
+
if (isUndefined$1(UpgradableConstructor)) {
|
|
8779
|
+
if (!isUndefined$1(customElements.get(tagName))) {
|
|
8780
|
+
throw new Error("Unexpected tag name \"".concat(tagName, "\". This name is a registered custom element, preventing LWC to upgrade the element."));
|
|
8781
|
+
}
|
|
8782
|
+
|
|
8783
|
+
UpgradableConstructor = createUpgradableConstructor(connectedCallback, disconnectedCallback);
|
|
8784
|
+
customElements.define(tagName, UpgradableConstructor);
|
|
8785
|
+
cachedConstructors.set(tagName, UpgradableConstructor);
|
|
8786
|
+
}
|
|
8787
|
+
|
|
8788
|
+
elementBeingUpgradedByLWC = true;
|
|
8789
|
+
|
|
8790
|
+
try {
|
|
8791
|
+
return new UpgradableConstructor(upgradeCallback);
|
|
8792
|
+
} finally {
|
|
8793
|
+
elementBeingUpgradedByLWC = false;
|
|
8794
|
+
}
|
|
8795
|
+
};
|
|
8796
|
+
/*
|
|
8797
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
8798
|
+
* All rights reserved.
|
|
8799
|
+
* SPDX-License-Identifier: MIT
|
|
8800
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8801
|
+
*/
|
|
8802
|
+
|
|
8803
|
+
/**
|
|
8804
|
+
* Create a scoped registry, i.e. a function that can create custom elements whose tag names
|
|
8805
|
+
* do not conflict with vanilla custom elements having the same tag name.
|
|
8806
|
+
*/
|
|
8807
|
+
|
|
8808
|
+
|
|
8809
|
+
function createScopedRegistry() {
|
|
8810
|
+
if (!hasCustomElements) {
|
|
8811
|
+
// This code should never be reached, because we don't use the pivot registry if
|
|
8812
|
+
// custom elements are unavailable.
|
|
8813
|
+
throw new Error('Custom elements are not supported in this environment.');
|
|
8814
|
+
}
|
|
8815
|
+
|
|
8816
|
+
var _window = window,
|
|
8817
|
+
NativeHTMLElement = _window.HTMLElement;
|
|
8818
|
+
var _NativeHTMLElement$pr = NativeHTMLElement.prototype,
|
|
8819
|
+
nativeHasAttribute = _NativeHTMLElement$pr.hasAttribute,
|
|
8820
|
+
nativeSetAttribute = _NativeHTMLElement$pr.setAttribute,
|
|
8821
|
+
nativeRemoveAttribute = _NativeHTMLElement$pr.removeAttribute,
|
|
8822
|
+
nativeGetAttribute = _NativeHTMLElement$pr.getAttribute;
|
|
8823
|
+
var definitionForElement = new WeakMap();
|
|
8824
|
+
var pendingRegistryForElement = new WeakMap();
|
|
8825
|
+
var definitionForConstructor = new WeakMap();
|
|
8826
|
+
var registeredUserCtors = new WeakSet();
|
|
8827
|
+
var pivotCtorByTag = new Map();
|
|
8828
|
+
var globalDefinitionsByTag = new Map();
|
|
8829
|
+
var globalDefinitionsByClass = new Map();
|
|
8830
|
+
var awaitingUpgrade = new Map();
|
|
8831
|
+
var EMPTY_SET = new Set();
|
|
8832
|
+
|
|
8833
|
+
function createDefinitionRecord(constructor) {
|
|
8834
|
+
var _a;
|
|
8835
|
+
|
|
8836
|
+
var _constructor$prototyp = constructor.prototype,
|
|
8837
|
+
connectedCallback = _constructor$prototyp.connectedCallback,
|
|
8838
|
+
disconnectedCallback = _constructor$prototyp.disconnectedCallback,
|
|
8839
|
+
adoptedCallback = _constructor$prototyp.adoptedCallback,
|
|
8840
|
+
attributeChangedCallback = _constructor$prototyp.attributeChangedCallback;
|
|
8841
|
+
var observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
|
|
8842
|
+
return {
|
|
8843
|
+
UserCtor: constructor,
|
|
8844
|
+
PivotCtor: undefined,
|
|
8845
|
+
connectedCallback: connectedCallback,
|
|
8846
|
+
disconnectedCallback: disconnectedCallback,
|
|
8847
|
+
adoptedCallback: adoptedCallback,
|
|
8848
|
+
attributeChangedCallback: attributeChangedCallback,
|
|
8849
|
+
observedAttributes: observedAttributes
|
|
8850
|
+
};
|
|
8851
|
+
} // Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
|
|
8852
|
+
// element. Note that the `registeredDefinition` represents the constructor that was used to register during
|
|
8853
|
+
// `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
|
|
8854
|
+
// constructor is invoked with another constructor.
|
|
8855
|
+
|
|
8856
|
+
|
|
8857
|
+
function createPivotingClass(tagName, registeredDefinition) {
|
|
8858
|
+
var PivotCtor = /*#__PURE__*/function (_NativeHTMLElement) {
|
|
8859
|
+
_inherits(PivotCtor, _NativeHTMLElement);
|
|
8860
|
+
|
|
8861
|
+
var _super8 = _createSuper(PivotCtor);
|
|
8862
|
+
|
|
8863
|
+
function PivotCtor(UserCtor) {
|
|
8864
|
+
var _this6;
|
|
8865
|
+
|
|
8866
|
+
_classCallCheck(this, PivotCtor);
|
|
8867
|
+
|
|
8868
|
+
// This constructor can only be invoked by:
|
|
8869
|
+
// a) the browser instantiating an element from parsing or via document.createElement.
|
|
8870
|
+
// b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
|
|
8871
|
+
// b) new UserClass.
|
|
8872
|
+
// When LWC instantiates it, it will pass the upgrading definition as an argument
|
|
8873
|
+
// If the caller signals via UserCtor that this is in fact a controlled
|
|
8874
|
+
// definition, we use that one, otherwise fallback to the global
|
|
8875
|
+
// internal registry.
|
|
8876
|
+
_this6 = _super8.call(this);
|
|
8877
|
+
var userCtorIsDefined = !isUndefined$1(UserCtor);
|
|
8878
|
+
|
|
8879
|
+
if (userCtorIsDefined) {
|
|
8880
|
+
if (!isConstructor(UserCtor)) {
|
|
8881
|
+
throw new TypeError("Failed to create custom element: the provided constructor is not a constructor.");
|
|
8882
|
+
}
|
|
8883
|
+
|
|
8884
|
+
if (!registeredUserCtors.has(UserCtor)) {
|
|
8885
|
+
throw new Error("Failed to create custom element: the provided constructor is unregistered: ".concat(UserCtor.name, "."));
|
|
8886
|
+
}
|
|
8887
|
+
}
|
|
8888
|
+
|
|
8889
|
+
var definition = userCtorIsDefined ? getOrCreateDefinitionForConstructor(UserCtor) : globalDefinitionsByTag.get(tagName);
|
|
8890
|
+
|
|
8891
|
+
if (!isUndefined$1(definition)) {
|
|
8892
|
+
internalUpgrade(_assertThisInitialized(_this6), registeredDefinition, definition);
|
|
8893
|
+
} else {
|
|
8894
|
+
// This is the case in which there is no global definition, and
|
|
8895
|
+
// it is not handled by LWC (otherwise it will have a valid UserCtor)
|
|
8896
|
+
// so we need to add it to the pending queue just in case it eventually
|
|
8897
|
+
// gets defined in the global registry.
|
|
8898
|
+
pendingRegistryForElement.set(_assertThisInitialized(_this6), registeredDefinition);
|
|
8899
|
+
}
|
|
8900
|
+
|
|
8901
|
+
return _this6;
|
|
8902
|
+
}
|
|
8903
|
+
|
|
8904
|
+
_createClass(PivotCtor, [{
|
|
8905
|
+
key: "connectedCallback",
|
|
8906
|
+
value: function connectedCallback() {
|
|
8907
|
+
var _a;
|
|
8908
|
+
|
|
8909
|
+
var definition = definitionForElement.get(this);
|
|
8910
|
+
|
|
8911
|
+
if (!isUndefined$1(definition)) {
|
|
8912
|
+
// Delegate out to user callback
|
|
8913
|
+
(_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
8914
|
+
} else {
|
|
8915
|
+
// Register for upgrade when defined (only when connected, so we don't leak)
|
|
8916
|
+
var awaiting = awaitingUpgrade.get(tagName);
|
|
8917
|
+
|
|
8918
|
+
if (isUndefined$1(awaiting)) {
|
|
8919
|
+
awaitingUpgrade.set(tagName, awaiting = new Set());
|
|
8920
|
+
}
|
|
8921
|
+
|
|
8922
|
+
awaiting.add(this);
|
|
8923
|
+
}
|
|
8924
|
+
}
|
|
8925
|
+
}, {
|
|
8926
|
+
key: "disconnectedCallback",
|
|
8927
|
+
value: function disconnectedCallback() {
|
|
8928
|
+
var _a;
|
|
8929
|
+
|
|
8930
|
+
var definition = definitionForElement.get(this);
|
|
8931
|
+
|
|
8932
|
+
if (!isUndefined$1(definition)) {
|
|
8933
|
+
// Delegate out to user callback
|
|
8934
|
+
(_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
8935
|
+
} else {
|
|
8936
|
+
// Un-register for upgrade when defined (so we don't leak)
|
|
8937
|
+
var awaiting = awaitingUpgrade.get(tagName); // At this point, awaiting should never be undefined, because connectedCallback
|
|
8938
|
+
// must have been called before disconnectedCallback. But just to be safe, we check
|
|
8939
|
+
|
|
8940
|
+
if (!isUndefined$1(awaiting)) {
|
|
8941
|
+
awaiting.delete(this);
|
|
8942
|
+
}
|
|
8943
|
+
}
|
|
8944
|
+
}
|
|
8945
|
+
}, {
|
|
8946
|
+
key: "adoptedCallback",
|
|
8947
|
+
value: function adoptedCallback() {
|
|
8948
|
+
var _a;
|
|
8949
|
+
|
|
8950
|
+
var definition = definitionForElement.get(this);
|
|
8951
|
+
(_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
8952
|
+
}
|
|
8953
|
+
}, {
|
|
8954
|
+
key: "attributeChangedCallback",
|
|
8955
|
+
value: function attributeChangedCallback(name, oldValue, newValue) {
|
|
8956
|
+
var _a;
|
|
8957
|
+
|
|
8958
|
+
var definition = definitionForElement.get(this); // if both definitions are the same, then the observedAttributes is the same,
|
|
8959
|
+
// but if they are different, only if the runtime definition has the attribute
|
|
8960
|
+
// marked as observed, then it should invoke attributeChangedCallback.
|
|
8961
|
+
|
|
8962
|
+
if (registeredDefinition === definition || (definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
|
|
8963
|
+
(_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
|
|
8964
|
+
}
|
|
8965
|
+
}
|
|
8966
|
+
}]);
|
|
8967
|
+
|
|
8968
|
+
return PivotCtor;
|
|
8969
|
+
}(NativeHTMLElement);
|
|
8970
|
+
|
|
8971
|
+
PivotCtor.observedAttributes = _toConsumableArray(registeredDefinition.observedAttributes);
|
|
8972
|
+
return PivotCtor;
|
|
8973
|
+
}
|
|
8974
|
+
|
|
8975
|
+
function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
|
|
8976
|
+
var observedAttributes = pivotDefinition.observedAttributes,
|
|
8977
|
+
attributeChangedCallback = pivotDefinition.attributeChangedCallback;
|
|
8978
|
+
|
|
8979
|
+
if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
|
|
8980
|
+
// This instance does not need to observe any attributes, no need to patch
|
|
8981
|
+
return EMPTY_SET;
|
|
8982
|
+
} // Natively, the attributes observed by the registered definition are going to be taken
|
|
8983
|
+
// care of by the browser, only the difference between the two sets has to be taken
|
|
8984
|
+
// care by the patched version.
|
|
8985
|
+
|
|
8986
|
+
|
|
8987
|
+
return new Set(_toConsumableArray(pivotDefinition.observedAttributes).filter(function (x) {
|
|
8988
|
+
return !registeredDefinition.observedAttributes.has(x);
|
|
8989
|
+
}));
|
|
8990
|
+
}
|
|
8991
|
+
|
|
8992
|
+
function throwAsyncError(error) {
|
|
8993
|
+
// Per native custom element behavior, errors thrown in attributeChangedCallback
|
|
8994
|
+
// become unhandled async errors. We use setTimeout() instead of Promise.resolve()
|
|
8995
|
+
// to make it an unhandled error rather than an unhandled rejection.
|
|
8996
|
+
setTimeout(function () {
|
|
8997
|
+
throw error;
|
|
8998
|
+
});
|
|
8999
|
+
} // Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
|
|
9000
|
+
// Why is this necessary? Well basically, you can't change the `observedAttributes` after
|
|
9001
|
+
// a custom element is defined. So with pivots, if two classes share the same tag name,
|
|
9002
|
+
// and the second class observes attributes that aren't observed by the first one,
|
|
9003
|
+
// then those attributes can never be observed by the native `observedAttributes` system.
|
|
9004
|
+
// So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
|
|
9005
|
+
// we only do this when absolutely necessary, though; i.e. because we've determined
|
|
9006
|
+
// that we aren't observing the attributes we need to.
|
|
9007
|
+
|
|
9008
|
+
|
|
9009
|
+
function patchAttributes(instance, registeredDefinition, pivotDefinition) {
|
|
9010
|
+
var newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
9011
|
+
|
|
9012
|
+
if (newObservedAttributes.size === 0) {
|
|
9013
|
+
return;
|
|
9014
|
+
}
|
|
9015
|
+
|
|
9016
|
+
var attributeChangedCallback = pivotDefinition.attributeChangedCallback; // Patch the instance.
|
|
9017
|
+
// Note we use the native `getAttribute` rather than the super's `getAttribute` because
|
|
9018
|
+
// we don't actually want it to be observable that we're calling `getAttribute` from
|
|
9019
|
+
// `setAttribute` and `removeAttribute`.
|
|
9020
|
+
// TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
|
|
9021
|
+
|
|
9022
|
+
defineProperties(instance, {
|
|
9023
|
+
setAttribute: {
|
|
9024
|
+
value: function setAttribute(name, value) {
|
|
9025
|
+
if (newObservedAttributes.has(name)) {
|
|
9026
|
+
var old = nativeGetAttribute.call(this, name);
|
|
9027
|
+
nativeSetAttribute.call(this, name, value);
|
|
9028
|
+
|
|
9029
|
+
try {
|
|
9030
|
+
attributeChangedCallback.call(this, name, old, value + '');
|
|
9031
|
+
} catch (error) {
|
|
9032
|
+
throwAsyncError(error);
|
|
9033
|
+
}
|
|
9034
|
+
} else {
|
|
9035
|
+
nativeSetAttribute.call(this, name, value);
|
|
9036
|
+
}
|
|
9037
|
+
},
|
|
9038
|
+
writable: true,
|
|
9039
|
+
enumerable: true,
|
|
9040
|
+
configurable: true
|
|
9041
|
+
},
|
|
9042
|
+
removeAttribute: {
|
|
9043
|
+
value: function removeAttribute(name) {
|
|
9044
|
+
if (newObservedAttributes.has(name)) {
|
|
9045
|
+
var old = nativeGetAttribute.call(this, name);
|
|
9046
|
+
nativeRemoveAttribute.call(this, name);
|
|
9047
|
+
|
|
9048
|
+
try {
|
|
9049
|
+
attributeChangedCallback.call(this, name, old, null);
|
|
9050
|
+
} catch (error) {
|
|
9051
|
+
throwAsyncError(error);
|
|
9052
|
+
}
|
|
9053
|
+
} else {
|
|
9054
|
+
nativeRemoveAttribute.call(this, name);
|
|
9055
|
+
}
|
|
9056
|
+
},
|
|
9057
|
+
writable: true,
|
|
9058
|
+
enumerable: true,
|
|
9059
|
+
configurable: true
|
|
9060
|
+
}
|
|
9061
|
+
});
|
|
9062
|
+
}
|
|
9063
|
+
|
|
9064
|
+
function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
9065
|
+
// The below case patches observed attributes for the case where the HTML element is upgraded
|
|
9066
|
+
// from a pre-existing one in the DOM.
|
|
9067
|
+
var newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
9068
|
+
|
|
9069
|
+
if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
|
|
9070
|
+
return;
|
|
9071
|
+
}
|
|
9072
|
+
|
|
9073
|
+
var attributeChangedCallback = pivotDefinition.attributeChangedCallback; // Approximate observedAttributes from the user class, but only for the new observed attributes
|
|
9074
|
+
|
|
9075
|
+
newObservedAttributes.forEach(function (name) {
|
|
9076
|
+
if (nativeHasAttribute.call(instance, name)) {
|
|
9077
|
+
var newValue = nativeGetAttribute.call(instance, name);
|
|
9078
|
+
attributeChangedCallback.call(instance, name, null, newValue);
|
|
9079
|
+
}
|
|
9080
|
+
});
|
|
9081
|
+
} // User extends this HTMLElement, which returns the CE being upgraded
|
|
9082
|
+
|
|
9083
|
+
|
|
9084
|
+
var upgradingInstance; // Helper to upgrade an instance with a CE definition using "constructor call trick"
|
|
9085
|
+
|
|
9086
|
+
function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
9087
|
+
setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
|
|
9088
|
+
definitionForElement.set(instance, pivotDefinition); // attributes patches when needed
|
|
9089
|
+
|
|
9090
|
+
if (pivotDefinition !== registeredDefinition) {
|
|
9091
|
+
patchAttributes(instance, registeredDefinition, pivotDefinition);
|
|
9092
|
+
} // Tricking the construction path to believe that a new instance is being created,
|
|
9093
|
+
// that way it will execute the super initialization mechanism but the HTMLElement
|
|
9094
|
+
// constructor will reuse the instance by returning the upgradingInstance.
|
|
9095
|
+
// This is by far the most important piece of the puzzle
|
|
9096
|
+
|
|
9097
|
+
|
|
9098
|
+
upgradingInstance = instance; // By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
|
|
9099
|
+
// The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
|
|
9100
|
+
// Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
|
|
9101
|
+
|
|
9102
|
+
new pivotDefinition.UserCtor();
|
|
9103
|
+
patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
|
|
9104
|
+
}
|
|
9105
|
+
|
|
9106
|
+
function isConstructor(constructor) {
|
|
9107
|
+
return isFunction$1(constructor) && isObject(constructor.prototype);
|
|
9108
|
+
}
|
|
9109
|
+
|
|
9110
|
+
function getOrCreateDefinitionForConstructor(constructor) {
|
|
9111
|
+
if (!isConstructor(constructor)) {
|
|
9112
|
+
throw new TypeError('The referenced constructor is not a constructor.');
|
|
9113
|
+
}
|
|
9114
|
+
|
|
9115
|
+
var definition = definitionForConstructor.get(constructor);
|
|
9116
|
+
|
|
9117
|
+
if (!isUndefined$1(definition)) {
|
|
9118
|
+
return definition;
|
|
9119
|
+
}
|
|
9120
|
+
|
|
9121
|
+
return createDefinitionRecord(constructor);
|
|
9122
|
+
}
|
|
9123
|
+
|
|
9124
|
+
var _window2 = window,
|
|
9125
|
+
nativeRegistry = _window2.customElements;
|
|
9126
|
+
var nativeDefine = nativeRegistry.define,
|
|
9127
|
+
nativeWhenDefined = nativeRegistry.whenDefined,
|
|
9128
|
+
nativeGet = nativeRegistry.get; // patch for the global registry define mechanism
|
|
9129
|
+
|
|
9130
|
+
CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
|
|
9131
|
+
if (options && options.extends) {
|
|
9132
|
+
// TODO [#2983]: should we support `extends`?
|
|
9133
|
+
throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
|
|
9134
|
+
}
|
|
9135
|
+
|
|
9136
|
+
if (globalDefinitionsByTag.has(tagName)) {
|
|
9137
|
+
throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': the name \"".concat(tagName, "\" has already been used with this registry"));
|
|
9138
|
+
}
|
|
9139
|
+
|
|
9140
|
+
if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
|
|
9141
|
+
throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry");
|
|
9142
|
+
}
|
|
9143
|
+
|
|
9144
|
+
var definition = getOrCreateDefinitionForConstructor(constructor);
|
|
9145
|
+
registeredUserCtors.add(constructor);
|
|
9146
|
+
var PivotCtor = pivotCtorByTag.get(tagName);
|
|
9147
|
+
|
|
9148
|
+
if (isUndefined$1(PivotCtor)) {
|
|
9149
|
+
PivotCtor = createPivotingClass(tagName, definition); // Register a pivoting class which will handle global registry initializations
|
|
9150
|
+
|
|
9151
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
9152
|
+
} // Only cache after nativeDefine has been called, because if it throws an error
|
|
9153
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
9154
|
+
|
|
9155
|
+
|
|
9156
|
+
definitionForConstructor.set(constructor, definition);
|
|
9157
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
9158
|
+
globalDefinitionsByTag.set(tagName, definition);
|
|
9159
|
+
globalDefinitionsByClass.set(constructor, definition); // For globally defined custom elements, the definition associated
|
|
9160
|
+
// to the UserCtor has a back-pointer to PivotCtor in case the user
|
|
9161
|
+
// new the UserCtor, so we know how to create the underlying element.
|
|
9162
|
+
|
|
9163
|
+
definition.PivotCtor = PivotCtor; // Upgrade any elements created in this scope before customElements.define
|
|
9164
|
+
// was called, which should be exhibited by the following steps:
|
|
9165
|
+
// 1) LWC registers a tagName for an LWC component.
|
|
9166
|
+
// 2) Element with same tagName is created with document.createElement()
|
|
9167
|
+
// and inserted into DOM.
|
|
9168
|
+
// 3) customElements.define() is called with tagName and non-LWC constructor.
|
|
9169
|
+
// This requires immediate upgrade when the new global tagName is defined.
|
|
9170
|
+
|
|
9171
|
+
var awaiting = awaitingUpgrade.get(tagName);
|
|
9172
|
+
|
|
9173
|
+
if (!isUndefined$1(awaiting)) {
|
|
9174
|
+
awaitingUpgrade.delete(tagName);
|
|
9175
|
+
|
|
9176
|
+
var _iterator6 = _createForOfIteratorHelper(awaiting),
|
|
9177
|
+
_step6;
|
|
9178
|
+
|
|
9179
|
+
try {
|
|
9180
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
9181
|
+
var element = _step6.value;
|
|
9182
|
+
var registeredDefinition = pendingRegistryForElement.get(element); // At this point, registeredDefinition should never be undefined because awaitingUpgrade
|
|
9183
|
+
// is only populated when we haven't run internalUpgrade yet, and we only populate
|
|
9184
|
+
// pendingRegistryForElement when internalUpgrade hasn't run yet.
|
|
9185
|
+
// But just to be safe, we check.
|
|
9186
|
+
|
|
9187
|
+
if (!isUndefined$1(registeredDefinition)) {
|
|
9188
|
+
pendingRegistryForElement.delete(element);
|
|
9189
|
+
internalUpgrade(element, registeredDefinition, definition);
|
|
9190
|
+
}
|
|
9191
|
+
}
|
|
9192
|
+
} catch (err) {
|
|
9193
|
+
_iterator6.e(err);
|
|
9194
|
+
} finally {
|
|
9195
|
+
_iterator6.f();
|
|
9196
|
+
}
|
|
9197
|
+
}
|
|
9198
|
+
};
|
|
9199
|
+
|
|
9200
|
+
CustomElementRegistry.prototype.get = function get(tagName) {
|
|
9201
|
+
var NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
9202
|
+
|
|
9203
|
+
if (!isUndefined$1(NativeCtor)) {
|
|
9204
|
+
var definition = globalDefinitionsByTag.get(tagName);
|
|
9205
|
+
|
|
9206
|
+
if (!isUndefined$1(definition)) {
|
|
9207
|
+
return definition.UserCtor; // defined by the patched custom elements registry
|
|
9208
|
+
} // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
9209
|
+
|
|
9210
|
+
|
|
9211
|
+
return NativeCtor; // return the pivot constructor or constructor that existed before patching
|
|
9212
|
+
}
|
|
9213
|
+
};
|
|
9214
|
+
|
|
9215
|
+
CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
|
|
9216
|
+
return nativeWhenDefined.call(nativeRegistry, tagName).then(function (NativeCtor) {
|
|
9217
|
+
var definition = globalDefinitionsByTag.get(tagName);
|
|
9218
|
+
|
|
9219
|
+
if (!isUndefined$1(definition)) {
|
|
9220
|
+
return definition.UserCtor;
|
|
9221
|
+
} // TODO [#3073]: return undefined rather than the pivot constructor (NativeCtor)
|
|
9222
|
+
// In this case, the custom element must have been defined before the registry patches
|
|
9223
|
+
// were applied. So return the non-pivot constructor
|
|
9224
|
+
|
|
9225
|
+
|
|
9226
|
+
if (isUndefined$1(NativeCtor)) {
|
|
9227
|
+
// Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
|
|
9228
|
+
// We can patch the correct behavior using customElements.get()
|
|
9229
|
+
return nativeGet.call(nativeRegistry, tagName);
|
|
9230
|
+
}
|
|
9231
|
+
|
|
9232
|
+
return NativeCtor;
|
|
9233
|
+
});
|
|
9234
|
+
}; // This constructor is invoked when we call `new pivotDefinition.UserCtor()`
|
|
9235
|
+
// @ts-ignore
|
|
9236
|
+
|
|
9237
|
+
|
|
9238
|
+
window.HTMLElement = function HTMLElement() {
|
|
9239
|
+
// Upgrading case: the pivoting class constructor was run by the browser's
|
|
9240
|
+
// native custom elements and we're in the process of running the
|
|
9241
|
+
// "constructor-call trick" on the natively constructed instance, so just
|
|
9242
|
+
// return that here.
|
|
9243
|
+
// This code path is also called when LWC `new`s a PivotCtor.
|
|
9244
|
+
var instance = upgradingInstance;
|
|
9245
|
+
|
|
9246
|
+
if (!isUndefined$1(instance)) {
|
|
9247
|
+
upgradingInstance = undefined;
|
|
9248
|
+
return instance;
|
|
9249
|
+
} // Construction case: we need to construct the pivoting instance and return it.
|
|
9250
|
+
// This is possible when the user register it via global registry and instantiate
|
|
9251
|
+
// it via `new Ctor()`.
|
|
9252
|
+
|
|
9253
|
+
|
|
9254
|
+
var constructor = this.constructor;
|
|
9255
|
+
var definition = globalDefinitionsByClass.get(constructor);
|
|
9256
|
+
|
|
9257
|
+
if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
|
|
9258
|
+
// This code path is hit if someone `new`s a class that extends `HTMLElement` without
|
|
9259
|
+
// doing `customElements.define()` first. This matches native browser behavior:
|
|
9260
|
+
// https://stackoverflow.com/a/61883392
|
|
9261
|
+
throw new TypeError('Illegal constructor');
|
|
9262
|
+
} // This constructor is ONLY invoked when it is the user instantiating
|
|
9263
|
+
// an element via new Ctor while Ctor is a registered global constructor.
|
|
9264
|
+
|
|
9265
|
+
|
|
9266
|
+
var PivotCtor = definition.PivotCtor,
|
|
9267
|
+
UserCtor = definition.UserCtor;
|
|
9268
|
+
return new PivotCtor(UserCtor);
|
|
9269
|
+
};
|
|
9270
|
+
|
|
9271
|
+
HTMLElement.prototype = NativeHTMLElement.prototype;
|
|
9272
|
+
/**
|
|
9273
|
+
* Create a new PivotConstructor for the given tagName, which is capable of being constructed
|
|
9274
|
+
* with a UserConstructor defining the behavior. Passing in the UserConstructor here
|
|
9275
|
+
* is a hint that can be used when registering a custom element with the global custom elements
|
|
9276
|
+
* registry for the first time, which provides certain optimizations. It also marks the UserConstructor
|
|
9277
|
+
* as "safe" to be used when passed in to a PivotConstructor.
|
|
9278
|
+
*
|
|
9279
|
+
* @param tagName - element tag name
|
|
9280
|
+
* @param UserCtor - userland custom element constructor
|
|
9281
|
+
* @returns a new custom element constructor
|
|
9282
|
+
*/
|
|
9283
|
+
|
|
9284
|
+
return function createPivotConstructor(tagName, UserCtor) {
|
|
9285
|
+
tagName = StringToLowerCase.call(tagName);
|
|
9286
|
+
var PivotCtor = pivotCtorByTag.get(tagName);
|
|
9287
|
+
|
|
9288
|
+
if (isUndefined$1(PivotCtor)) {
|
|
9289
|
+
var definition = getOrCreateDefinitionForConstructor(UserCtor);
|
|
9290
|
+
PivotCtor = createPivotingClass(tagName, definition); // Register a pivoting class as a global custom element
|
|
9291
|
+
|
|
9292
|
+
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
9293
|
+
definition.PivotCtor = PivotCtor; // Only cache after nativeDefine has been called, because if it throws an error
|
|
9294
|
+
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
9295
|
+
|
|
9296
|
+
definitionForConstructor.set(UserCtor, definition);
|
|
9297
|
+
pivotCtorByTag.set(tagName, PivotCtor);
|
|
9298
|
+
} // Register a UserConstructor as "safe" to be used within a PivotConstructor
|
|
9299
|
+
|
|
9300
|
+
|
|
9301
|
+
registeredUserCtors.add(UserCtor);
|
|
9302
|
+
return PivotCtor;
|
|
9303
|
+
};
|
|
9304
|
+
}
|
|
9305
|
+
/*
|
|
9306
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
9307
|
+
* All rights reserved.
|
|
9308
|
+
* SPDX-License-Identifier: MIT
|
|
9309
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
9310
|
+
*/
|
|
9311
|
+
|
|
9312
|
+
|
|
9313
|
+
var createScopedConstructor;
|
|
9314
|
+
var CachedHTMLElement; // We only call `createScopedRegistry()` if the browser supports custom elements and
|
|
9315
|
+
// ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
|
|
9316
|
+
// or we're in a legacy browser.
|
|
9317
|
+
|
|
9318
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
9319
|
+
if (hasCustomElements) {
|
|
9320
|
+
// If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
|
|
9321
|
+
// It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
|
|
9322
|
+
//
|
|
9323
|
+
// Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
|
|
9324
|
+
//
|
|
9325
|
+
// 1. LWC loads
|
|
9326
|
+
// 2. `const Ctor = class extends HTMLElement {}`
|
|
9327
|
+
// 3. `lwc.createElement(...)` // here we lazily patch
|
|
9328
|
+
// 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
|
|
9329
|
+
//
|
|
9330
|
+
// To reduce the risk of this, it's safer to patch the registry eagerly.
|
|
9331
|
+
createScopedConstructor = createScopedRegistry(); // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
|
|
9332
|
+
// another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
|
|
9333
|
+
// because the HTMLElement prototypes are mixed up.
|
|
9334
|
+
//
|
|
9335
|
+
// The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
|
|
9336
|
+
// with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
|
|
9337
|
+
// the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
|
|
9338
|
+
// Caching avoids this problem.
|
|
9339
|
+
|
|
9340
|
+
CachedHTMLElement = window.HTMLElement;
|
|
9341
|
+
}
|
|
9342
|
+
} // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
|
|
9343
|
+
// In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
|
|
9344
|
+
// multiple times per tag name.
|
|
9345
|
+
|
|
9346
|
+
|
|
9347
|
+
var createUserConstructor = function createUserConstructor(upgradeCallback, _connectedCallback2, _disconnectedCallback2, HTMLElementToExtend) {
|
|
9348
|
+
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
9349
|
+
return /*#__PURE__*/function (_HTMLElementToExtend) {
|
|
9350
|
+
_inherits(UserConstructor, _HTMLElementToExtend);
|
|
9351
|
+
|
|
9352
|
+
var _super9 = _createSuper(UserConstructor);
|
|
9353
|
+
|
|
9354
|
+
function UserConstructor() {
|
|
9355
|
+
var _this7;
|
|
9356
|
+
|
|
9357
|
+
_classCallCheck(this, UserConstructor);
|
|
9358
|
+
|
|
9359
|
+
_this7 = _super9.call(this);
|
|
9360
|
+
upgradeCallback(_assertThisInitialized(_this7));
|
|
9361
|
+
return _this7;
|
|
9362
|
+
}
|
|
9363
|
+
|
|
9364
|
+
_createClass(UserConstructor, [{
|
|
9365
|
+
key: "connectedCallback",
|
|
9366
|
+
value: function connectedCallback() {
|
|
9367
|
+
_connectedCallback2(this);
|
|
9368
|
+
}
|
|
9369
|
+
}, {
|
|
9370
|
+
key: "disconnectedCallback",
|
|
9371
|
+
value: function disconnectedCallback() {
|
|
9372
|
+
_disconnectedCallback2(this);
|
|
9373
|
+
}
|
|
9374
|
+
}]);
|
|
9375
|
+
|
|
9376
|
+
return UserConstructor;
|
|
9377
|
+
}(HTMLElementToExtend);
|
|
9378
|
+
};
|
|
9379
|
+
|
|
9380
|
+
function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
9381
|
+
if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
|
|
9382
|
+
// This error should be impossible to hit
|
|
9383
|
+
throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
|
|
9384
|
+
}
|
|
9385
|
+
|
|
9386
|
+
var UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
|
|
9387
|
+
var ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
|
|
9388
|
+
return new ScopedConstructor(UserConstructor);
|
|
9389
|
+
}
|
|
9390
|
+
/*
|
|
9391
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
9392
|
+
* All rights reserved.
|
|
9393
|
+
* SPDX-License-Identifier: MIT
|
|
9394
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
9395
|
+
*/
|
|
9396
|
+
|
|
9397
|
+
/**
|
|
9398
|
+
* We have three modes for creating custom elements:
|
|
9399
|
+
*
|
|
9400
|
+
* 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
|
|
9401
|
+
* 2. "Vanilla" custom elements registry. This system actually still allows us to have two LWC components with the
|
|
9402
|
+
* same tag name, via a simple trick: every custom element constructor we define in the registry is basically
|
|
9403
|
+
* the same. It's essentially a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its
|
|
9404
|
+
* constructor, which allows us to have completely customized functionality for different components.
|
|
9405
|
+
* 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
|
|
9406
|
+
* elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
|
|
9407
|
+
* between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
|
|
9408
|
+
* because it must patch the global `customElements` and `HTMLElement` objects.
|
|
9409
|
+
*/
|
|
9410
|
+
|
|
9411
|
+
|
|
9412
|
+
var createCustomElement;
|
|
9413
|
+
|
|
9414
|
+
if (hasCustomElements) {
|
|
9415
|
+
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
9416
|
+
createCustomElement = createCustomElementScoped;
|
|
9417
|
+
} else {
|
|
9418
|
+
// use global custom elements registry (vanilla)
|
|
9419
|
+
createCustomElement = createCustomElementVanilla;
|
|
9420
|
+
}
|
|
9421
|
+
} else {
|
|
9422
|
+
// no registry available here
|
|
9423
|
+
createCustomElement = createCustomElementCompat;
|
|
9424
|
+
}
|
|
8714
9425
|
/*
|
|
8715
9426
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
8716
9427
|
* All rights reserved.
|
|
@@ -8779,7 +9490,7 @@ var LWC = (function (exports) {
|
|
|
8779
9490
|
function isNull(obj) {
|
|
8780
9491
|
return obj === null;
|
|
8781
9492
|
}
|
|
8782
|
-
/** version: 2.
|
|
9493
|
+
/** version: 2.26.1 */
|
|
8783
9494
|
|
|
8784
9495
|
/*
|
|
8785
9496
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8789,87 +9500,6 @@ var LWC = (function (exports) {
|
|
|
8789
9500
|
*/
|
|
8790
9501
|
|
|
8791
9502
|
|
|
8792
|
-
exports.getCustomElement = void 0;
|
|
8793
|
-
exports.defineCustomElement = void 0;
|
|
8794
|
-
var HTMLElementConstructor;
|
|
8795
|
-
|
|
8796
|
-
function isCustomElementRegistryAvailable() {
|
|
8797
|
-
if (typeof customElements === 'undefined') {
|
|
8798
|
-
return false;
|
|
8799
|
-
}
|
|
8800
|
-
|
|
8801
|
-
try {
|
|
8802
|
-
// dereference HTMLElement global because babel wraps globals in compat mode with a
|
|
8803
|
-
// _wrapNativeSuper()
|
|
8804
|
-
// This is a problem because LWCUpgradableElement extends renderer.HTMLElementExported which does not
|
|
8805
|
-
// get wrapped by babel.
|
|
8806
|
-
var HTMLElementAlias = HTMLElement; // In case we use compat mode with a modern browser, the compat mode transformation
|
|
8807
|
-
// invokes the DOM api with an .apply() or .call() to initialize any DOM api sub-classing,
|
|
8808
|
-
// which are not equipped to be initialized that way.
|
|
8809
|
-
|
|
8810
|
-
var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
|
|
8811
|
-
_inherits(clazz, _HTMLElementAlias);
|
|
8812
|
-
|
|
8813
|
-
var _super7 = _createSuper(clazz);
|
|
8814
|
-
|
|
8815
|
-
function clazz() {
|
|
8816
|
-
_classCallCheck(this, clazz);
|
|
8817
|
-
|
|
8818
|
-
return _super7.apply(this, arguments);
|
|
8819
|
-
}
|
|
8820
|
-
|
|
8821
|
-
return _createClass(clazz);
|
|
8822
|
-
}(HTMLElementAlias);
|
|
8823
|
-
|
|
8824
|
-
customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
|
8825
|
-
new clazz();
|
|
8826
|
-
return true;
|
|
8827
|
-
} catch (_a) {
|
|
8828
|
-
return false;
|
|
8829
|
-
}
|
|
8830
|
-
}
|
|
8831
|
-
|
|
8832
|
-
if (isCustomElementRegistryAvailable()) {
|
|
8833
|
-
exports.getCustomElement = customElements.get.bind(customElements);
|
|
8834
|
-
exports.defineCustomElement = customElements.define.bind(customElements);
|
|
8835
|
-
HTMLElementConstructor = HTMLElement;
|
|
8836
|
-
} else {
|
|
8837
|
-
var registry = Object.create(null);
|
|
8838
|
-
var reverseRegistry = new WeakMap();
|
|
8839
|
-
|
|
8840
|
-
exports.defineCustomElement = function define(name, ctor) {
|
|
8841
|
-
if (name !== String.prototype.toLowerCase.call(name) || registry[name]) {
|
|
8842
|
-
throw new TypeError("Invalid Registration");
|
|
8843
|
-
}
|
|
8844
|
-
|
|
8845
|
-
registry[name] = ctor;
|
|
8846
|
-
reverseRegistry.set(ctor, name);
|
|
8847
|
-
};
|
|
8848
|
-
|
|
8849
|
-
exports.getCustomElement = function get(name) {
|
|
8850
|
-
return registry[name];
|
|
8851
|
-
};
|
|
8852
|
-
|
|
8853
|
-
HTMLElementConstructor = function HTMLElement() {
|
|
8854
|
-
if (!(this instanceof HTMLElement)) {
|
|
8855
|
-
throw new TypeError("Invalid Invocation");
|
|
8856
|
-
}
|
|
8857
|
-
|
|
8858
|
-
var constructor = this.constructor;
|
|
8859
|
-
var name = reverseRegistry.get(constructor);
|
|
8860
|
-
|
|
8861
|
-
if (!name) {
|
|
8862
|
-
throw new TypeError("Invalid Construction");
|
|
8863
|
-
}
|
|
8864
|
-
|
|
8865
|
-
var elm = document.createElement(name);
|
|
8866
|
-
Object.setPrototypeOf(elm, constructor.prototype);
|
|
8867
|
-
return elm;
|
|
8868
|
-
};
|
|
8869
|
-
|
|
8870
|
-
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
8871
|
-
}
|
|
8872
|
-
|
|
8873
9503
|
function cloneNode(node, deep) {
|
|
8874
9504
|
return node.cloneNode(deep);
|
|
8875
9505
|
}
|
|
@@ -8928,18 +9558,18 @@ var LWC = (function (exports) {
|
|
|
8928
9558
|
var wrapperTags = topLevelWrappingMap[getTagName(html)];
|
|
8929
9559
|
|
|
8930
9560
|
if (!isUndefined(wrapperTags)) {
|
|
8931
|
-
var
|
|
8932
|
-
|
|
9561
|
+
var _iterator7 = _createForOfIteratorHelper(wrapperTags),
|
|
9562
|
+
_step7;
|
|
8933
9563
|
|
|
8934
9564
|
try {
|
|
8935
|
-
for (
|
|
8936
|
-
var wrapperTag =
|
|
9565
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
9566
|
+
var wrapperTag = _step7.value;
|
|
8937
9567
|
html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
|
|
8938
9568
|
}
|
|
8939
9569
|
} catch (err) {
|
|
8940
|
-
|
|
9570
|
+
_iterator7.e(err);
|
|
8941
9571
|
} finally {
|
|
8942
|
-
|
|
9572
|
+
_iterator7.f();
|
|
8943
9573
|
}
|
|
8944
9574
|
} // For IE11, the document title must not be undefined, but it can be an empty string
|
|
8945
9575
|
// https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
|
|
@@ -9085,8 +9715,6 @@ var LWC = (function (exports) {
|
|
|
9085
9715
|
assert.invariant(elm instanceof HTMLElement, msg);
|
|
9086
9716
|
}
|
|
9087
9717
|
|
|
9088
|
-
var HTMLElementExported = HTMLElementConstructor;
|
|
9089
|
-
exports.HTMLElementExported = HTMLElementExported;
|
|
9090
9718
|
exports.addEventListener = addEventListener;
|
|
9091
9719
|
exports.assertInstanceOfHTMLElement = assertInstanceOfHTMLElement;
|
|
9092
9720
|
exports.attachShadow = attachShadow;
|
|
@@ -9145,6 +9773,8 @@ var LWC = (function (exports) {
|
|
|
9145
9773
|
{
|
|
9146
9774
|
// insertStyleSheet implementation shares a global cache of stylesheet data
|
|
9147
9775
|
insertStylesheet: insertStylesheet,
|
|
9776
|
+
// relies on a shared global cache
|
|
9777
|
+
createCustomElement: createCustomElement,
|
|
9148
9778
|
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
9149
9779
|
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN)
|
|
9150
9780
|
});
|
|
@@ -9265,35 +9895,39 @@ var LWC = (function (exports) {
|
|
|
9265
9895
|
var hydratedCustomElements = new WeakSet();
|
|
9266
9896
|
|
|
9267
9897
|
function buildCustomElementConstructor(Ctor) {
|
|
9898
|
+
var _a;
|
|
9899
|
+
|
|
9268
9900
|
var HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
9269
|
-
|
|
9270
|
-
|
|
9901
|
+
var observedAttributes = HtmlPrototype.observedAttributes;
|
|
9902
|
+
var _attributeChangedCallback = HtmlPrototype.prototype.attributeChangedCallback;
|
|
9903
|
+
return _a = /*#__PURE__*/function (_HTMLElement2) {
|
|
9904
|
+
_inherits(_a, _HTMLElement2);
|
|
9271
9905
|
|
|
9272
|
-
var
|
|
9906
|
+
var _super10 = _createSuper(_a);
|
|
9273
9907
|
|
|
9274
|
-
function
|
|
9275
|
-
var
|
|
9908
|
+
function _a() {
|
|
9909
|
+
var _this8;
|
|
9276
9910
|
|
|
9277
|
-
_classCallCheck(this,
|
|
9911
|
+
_classCallCheck(this, _a);
|
|
9278
9912
|
|
|
9279
|
-
|
|
9913
|
+
_this8 = _super10.call(this);
|
|
9280
9914
|
|
|
9281
|
-
if (
|
|
9915
|
+
if (_this8.isConnected) {
|
|
9282
9916
|
// this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
|
|
9283
|
-
hydrateComponent(_assertThisInitialized(
|
|
9284
|
-
hydratedCustomElements.add(_assertThisInitialized(
|
|
9917
|
+
hydrateComponent(_assertThisInitialized(_this8), Ctor, {});
|
|
9918
|
+
hydratedCustomElements.add(_assertThisInitialized(_this8));
|
|
9285
9919
|
} else {
|
|
9286
|
-
createVM(_assertThisInitialized(
|
|
9920
|
+
createVM(_assertThisInitialized(_this8), Ctor, renderer, {
|
|
9287
9921
|
mode: 'open',
|
|
9288
9922
|
owner: null,
|
|
9289
|
-
tagName:
|
|
9923
|
+
tagName: _this8.tagName
|
|
9290
9924
|
});
|
|
9291
9925
|
}
|
|
9292
9926
|
|
|
9293
|
-
return
|
|
9927
|
+
return _this8;
|
|
9294
9928
|
}
|
|
9295
9929
|
|
|
9296
|
-
_createClass(
|
|
9930
|
+
_createClass(_a, [{
|
|
9297
9931
|
key: "connectedCallback",
|
|
9298
9932
|
value: function connectedCallback() {
|
|
9299
9933
|
if (hydratedCustomElements.has(this)) {
|
|
@@ -9308,10 +9942,15 @@ var LWC = (function (exports) {
|
|
|
9308
9942
|
value: function disconnectedCallback() {
|
|
9309
9943
|
disconnectRootElement(this);
|
|
9310
9944
|
}
|
|
9945
|
+
}, {
|
|
9946
|
+
key: "attributeChangedCallback",
|
|
9947
|
+
value: function attributeChangedCallback(name, oldValue, newValue) {
|
|
9948
|
+
_attributeChangedCallback.call(this, name, oldValue, newValue);
|
|
9949
|
+
}
|
|
9311
9950
|
}]);
|
|
9312
9951
|
|
|
9313
|
-
return
|
|
9314
|
-
}(
|
|
9952
|
+
return _a;
|
|
9953
|
+
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement)), _a.observedAttributes = observedAttributes, _a;
|
|
9315
9954
|
}
|
|
9316
9955
|
/*
|
|
9317
9956
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -9397,8 +10036,11 @@ var LWC = (function (exports) {
|
|
|
9397
10036
|
throw new TypeError("\"createElement\" function expects an \"is\" option with a valid component constructor.");
|
|
9398
10037
|
}
|
|
9399
10038
|
|
|
9400
|
-
var
|
|
9401
|
-
|
|
10039
|
+
var createCustomElement = renderer.createCustomElement; // tagName must be all lowercase, unfortunately, we have legacy code that is
|
|
10040
|
+
// passing `sel` as a camel-case, which makes them invalid custom elements name
|
|
10041
|
+
// the following line guarantees that this does not leaks beyond this point.
|
|
10042
|
+
|
|
10043
|
+
var tagName = StringToLowerCase.call(sel); // the custom element from the registry is expecting an upgrade callback
|
|
9402
10044
|
|
|
9403
10045
|
/**
|
|
9404
10046
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
@@ -9407,9 +10049,9 @@ var LWC = (function (exports) {
|
|
|
9407
10049
|
* an upgradable custom element.
|
|
9408
10050
|
*/
|
|
9409
10051
|
|
|
9410
|
-
var
|
|
10052
|
+
var upgradeCallback = function upgradeCallback(elm) {
|
|
9411
10053
|
createVM(elm, Ctor, renderer, {
|
|
9412
|
-
tagName:
|
|
10054
|
+
tagName: tagName,
|
|
9413
10055
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
9414
10056
|
owner: null
|
|
9415
10057
|
});
|
|
@@ -9418,15 +10060,21 @@ var LWC = (function (exports) {
|
|
|
9418
10060
|
ConnectingSlot.set(elm, connectRootElement);
|
|
9419
10061
|
DisconnectingSlot.set(elm, disconnectRootElement);
|
|
9420
10062
|
}
|
|
10063
|
+
};
|
|
9421
10064
|
|
|
9422
|
-
|
|
9423
|
-
|
|
10065
|
+
var connectedCallback = function connectedCallback(elm) {
|
|
10066
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
10067
|
+
connectRootElement(elm);
|
|
10068
|
+
}
|
|
10069
|
+
};
|
|
9424
10070
|
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
|
|
10071
|
+
var disconnectedCallback = function disconnectedCallback(elm) {
|
|
10072
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
10073
|
+
disconnectRootElement(elm);
|
|
10074
|
+
}
|
|
10075
|
+
};
|
|
9429
10076
|
|
|
10077
|
+
var element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
9430
10078
|
return element;
|
|
9431
10079
|
}
|
|
9432
10080
|
/*
|
|
@@ -9509,7 +10157,7 @@ var LWC = (function (exports) {
|
|
|
9509
10157
|
});
|
|
9510
10158
|
freeze(LightningElement);
|
|
9511
10159
|
seal(LightningElement.prototype);
|
|
9512
|
-
/* version: 2.
|
|
10160
|
+
/* version: 2.26.1 */
|
|
9513
10161
|
|
|
9514
10162
|
exports.LightningElement = LightningElement;
|
|
9515
10163
|
exports.__unstable__ProfilerControl = profilerControl;
|