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