lwc 2.35.2 → 2.37.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 +260 -654
- package/dist/engine-dom/iife/es2017/engine-dom.js +260 -654
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +286 -608
- package/dist/engine-dom/iife/es5/engine-dom.js +406 -852
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +450 -778
- package/dist/engine-dom/umd/es2017/engine-dom.js +260 -654
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +286 -608
- package/dist/engine-dom/umd/es5/engine-dom.js +406 -852
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +450 -778
- package/dist/engine-server/commonjs/es2017/engine-server.js +153 -92
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +153 -93
- 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
|
@@ -332,9 +332,9 @@ var LWC = (function (exports) {
|
|
|
332
332
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
333
333
|
*/
|
|
334
334
|
// Increment whenever the LWC template compiler changes
|
|
335
|
-
const LWC_VERSION = "2.
|
|
335
|
+
const LWC_VERSION = "2.37.0";
|
|
336
336
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
337
|
-
/** version: 2.
|
|
337
|
+
/** version: 2.37.0 */
|
|
338
338
|
|
|
339
339
|
/**
|
|
340
340
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -354,10 +354,8 @@ var LWC = (function (exports) {
|
|
|
354
354
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
355
355
|
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
356
356
|
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
357
|
-
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
358
357
|
ENABLE_FROZEN_TEMPLATE: null,
|
|
359
358
|
DISABLE_ARIA_REFLECTION_POLYFILL: null,
|
|
360
|
-
ENABLE_PROGRAMMATIC_STYLESHEETS: null,
|
|
361
359
|
};
|
|
362
360
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
363
361
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -413,7 +411,7 @@ var LWC = (function (exports) {
|
|
|
413
411
|
setFeatureFlag(name, value);
|
|
414
412
|
}
|
|
415
413
|
}
|
|
416
|
-
/** version: 2.
|
|
414
|
+
/** version: 2.37.0 */
|
|
417
415
|
|
|
418
416
|
/**
|
|
419
417
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -477,7 +475,7 @@ var LWC = (function (exports) {
|
|
|
477
475
|
}
|
|
478
476
|
}
|
|
479
477
|
}
|
|
480
|
-
/** version: 2.
|
|
478
|
+
/** version: 2.37.0 */
|
|
481
479
|
|
|
482
480
|
/*
|
|
483
481
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -543,7 +541,6 @@ var LWC = (function (exports) {
|
|
|
543
541
|
* SPDX-License-Identifier: MIT
|
|
544
542
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
545
543
|
*/
|
|
546
|
-
/** Callbacks to invoke when reporting is enabled **/
|
|
547
544
|
const onReportingEnabledCallbacks = [];
|
|
548
545
|
/** The currently assigned reporting dispatcher. */
|
|
549
546
|
let currentDispatcher$1 = noop;
|
|
@@ -601,11 +598,11 @@ var LWC = (function (exports) {
|
|
|
601
598
|
/**
|
|
602
599
|
* Report to the current dispatcher, if there is one.
|
|
603
600
|
* @param reportingEventId
|
|
604
|
-
* @param
|
|
601
|
+
* @param payload - data to report
|
|
605
602
|
*/
|
|
606
|
-
function report(reportingEventId,
|
|
603
|
+
function report(reportingEventId, payload) {
|
|
607
604
|
if (enabled$1) {
|
|
608
|
-
currentDispatcher$1(reportingEventId,
|
|
605
|
+
currentDispatcher$1(reportingEventId, payload);
|
|
609
606
|
}
|
|
610
607
|
}
|
|
611
608
|
|
|
@@ -880,7 +877,7 @@ var LWC = (function (exports) {
|
|
|
880
877
|
// Make a shallow copy of an object but omit the given key
|
|
881
878
|
function cloneAndOmitKey(object, keyToOmit) {
|
|
882
879
|
const result = {};
|
|
883
|
-
for (const key of
|
|
880
|
+
for (const key of keys(object)) {
|
|
884
881
|
if (key !== keyToOmit) {
|
|
885
882
|
result[key] = object[key];
|
|
886
883
|
}
|
|
@@ -890,7 +887,7 @@ var LWC = (function (exports) {
|
|
|
890
887
|
function flattenStylesheets(stylesheets) {
|
|
891
888
|
const list = [];
|
|
892
889
|
for (const stylesheet of stylesheets) {
|
|
893
|
-
if (!
|
|
890
|
+
if (!isArray$1(stylesheet)) {
|
|
894
891
|
list.push(stylesheet);
|
|
895
892
|
}
|
|
896
893
|
else {
|
|
@@ -3167,6 +3164,10 @@ var LWC = (function (exports) {
|
|
|
3167
3164
|
// stylesheets and templates do not have user-meaningful names, but components do
|
|
3168
3165
|
const friendlyName = type === 'component' ? `${type} ${func.name}` : type;
|
|
3169
3166
|
logError(`LWC WARNING: current engine is v${LWC_VERSION}, but ${friendlyName} was compiled with v${version}.\nPlease update your compiled code or LWC engine so that the versions match.\nNo further warnings will appear.`);
|
|
3167
|
+
report(1 /* ReportingEventId.CompilerRuntimeVersionMismatch */, {
|
|
3168
|
+
compilerVersion: version,
|
|
3169
|
+
runtimeVersion: LWC_VERSION,
|
|
3170
|
+
});
|
|
3170
3171
|
}
|
|
3171
3172
|
}
|
|
3172
3173
|
}
|
|
@@ -4902,7 +4903,12 @@ var LWC = (function (exports) {
|
|
|
4902
4903
|
} else if (isVScopedSlotFragment(vnode)) {
|
|
4903
4904
|
slotName = vnode.slotName;
|
|
4904
4905
|
}
|
|
4905
|
-
|
|
4906
|
+
// Can't use toString here because Symbol(1).toString() is 'Symbol(1)'
|
|
4907
|
+
// but elm.setAttribute('slot', Symbol(1)) is an error.
|
|
4908
|
+
// the following line also throws same error for symbols
|
|
4909
|
+
// Similar for Object.create(null)
|
|
4910
|
+
const normalizedSlotName = '' + slotName;
|
|
4911
|
+
const vnodes = cmpSlotsMapping[normalizedSlotName] = cmpSlotsMapping[normalizedSlotName] || [];
|
|
4906
4912
|
ArrayPush$1.call(vnodes, vnode);
|
|
4907
4913
|
}
|
|
4908
4914
|
vm.cmpSlots = {
|
|
@@ -5968,6 +5974,8 @@ var LWC = (function (exports) {
|
|
|
5968
5974
|
Ctor, { tmpl }) {
|
|
5969
5975
|
if (isFunction$1(Ctor)) {
|
|
5970
5976
|
if (process.env.NODE_ENV !== 'production') {
|
|
5977
|
+
// There is no point in running this in production, because the version mismatch check relies
|
|
5978
|
+
// on code comments which are stripped out in production by minifiers
|
|
5971
5979
|
checkVersionMismatch(Ctor, 'component');
|
|
5972
5980
|
}
|
|
5973
5981
|
signedTemplateMap.set(Ctor, tmpl);
|
|
@@ -6232,20 +6240,37 @@ var LWC = (function (exports) {
|
|
|
6232
6240
|
}
|
|
6233
6241
|
// Validate and flatten any stylesheets defined as `static stylesheets`
|
|
6234
6242
|
function computeStylesheets(vm, ctor) {
|
|
6235
|
-
|
|
6236
|
-
|
|
6243
|
+
warnOnStylesheetsMutation(ctor);
|
|
6244
|
+
const {
|
|
6245
|
+
stylesheets
|
|
6246
|
+
} = ctor;
|
|
6247
|
+
if (!isUndefined$1(stylesheets)) {
|
|
6248
|
+
const valid = validateComponentStylesheets(vm, stylesheets);
|
|
6249
|
+
if (valid) {
|
|
6250
|
+
return flattenStylesheets(stylesheets);
|
|
6251
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
6252
|
+
logError(`static stylesheets must be an array of CSS stylesheets. Found invalid stylesheets on <${vm.tagName}>`, vm);
|
|
6253
|
+
}
|
|
6254
|
+
}
|
|
6255
|
+
return null;
|
|
6256
|
+
}
|
|
6257
|
+
function warnOnStylesheetsMutation(ctor) {
|
|
6258
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6259
|
+
let {
|
|
6237
6260
|
stylesheets
|
|
6238
6261
|
} = ctor;
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6262
|
+
defineProperty(ctor, 'stylesheets', {
|
|
6263
|
+
enumerable: true,
|
|
6264
|
+
configurable: true,
|
|
6265
|
+
get() {
|
|
6266
|
+
return stylesheets;
|
|
6267
|
+
},
|
|
6268
|
+
set(newValue) {
|
|
6269
|
+
logWarnOnce(`Dynamically setting the "stylesheets" static property on ${ctor.name} ` + 'will not affect the stylesheets injected.');
|
|
6270
|
+
stylesheets = newValue;
|
|
6245
6271
|
}
|
|
6246
|
-
}
|
|
6272
|
+
});
|
|
6247
6273
|
}
|
|
6248
|
-
return null;
|
|
6249
6274
|
}
|
|
6250
6275
|
function computeShadowMode(vm, renderer) {
|
|
6251
6276
|
const {
|
|
@@ -6618,7 +6643,7 @@ var LWC = (function (exports) {
|
|
|
6618
6643
|
// The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
|
|
6619
6644
|
// These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
|
|
6620
6645
|
// When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
|
|
6621
|
-
// See: https://
|
|
6646
|
+
// See: https://sfdc.co/synthetic-aria
|
|
6622
6647
|
//
|
|
6623
6648
|
// Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
|
|
6624
6649
|
const getElementById = _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
|
|
@@ -6626,7 +6651,7 @@ var LWC = (function (exports) {
|
|
|
6626
6651
|
function isSyntheticShadowRootInstance(rootNode) {
|
|
6627
6652
|
return rootNode !== document && isTrue(rootNode.synthetic);
|
|
6628
6653
|
}
|
|
6629
|
-
function reportViolation(source, target, attrName) {
|
|
6654
|
+
function reportViolation$1(source, target, attrName) {
|
|
6630
6655
|
// The vm is either for the source, the target, or both. Either one or both must be using synthetic
|
|
6631
6656
|
// shadow for a violation to be detected.
|
|
6632
6657
|
let vm = getAssociatedVMIfPresent(source.getRootNode().host);
|
|
@@ -6637,12 +6662,15 @@ var LWC = (function (exports) {
|
|
|
6637
6662
|
// vm should never be undefined here, but just to be safe, bail out and don't report
|
|
6638
6663
|
return;
|
|
6639
6664
|
}
|
|
6640
|
-
report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */,
|
|
6665
|
+
report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, {
|
|
6666
|
+
tagName: vm.tagName,
|
|
6667
|
+
attributeName: attrName,
|
|
6668
|
+
});
|
|
6641
6669
|
if (process.env.NODE_ENV !== 'production') {
|
|
6642
6670
|
// Avoid excessively logging to the console in the case of duplicates.
|
|
6643
6671
|
logWarnOnce(`Element <${source.tagName.toLowerCase()}> uses attribute "${attrName}" to reference element ` +
|
|
6644
6672
|
`<${target.tagName.toLowerCase()}>, which is not in the same shadow root. This will break in native shadow DOM. ` +
|
|
6645
|
-
`For details, see: https://
|
|
6673
|
+
`For details, see: https://sfdc.co/synthetic-aria`, vm);
|
|
6646
6674
|
}
|
|
6647
6675
|
}
|
|
6648
6676
|
function parseIdRefAttributeValue(attrValue) {
|
|
@@ -6669,7 +6697,7 @@ var LWC = (function (exports) {
|
|
|
6669
6697
|
const sourceElement = sourceElements[i];
|
|
6670
6698
|
const sourceRoot = sourceElement.getRootNode();
|
|
6671
6699
|
if (sourceRoot !== root) {
|
|
6672
|
-
reportViolation(sourceElement, elm, idRefAttrName);
|
|
6700
|
+
reportViolation$1(sourceElement, elm, idRefAttrName);
|
|
6673
6701
|
break;
|
|
6674
6702
|
}
|
|
6675
6703
|
}
|
|
@@ -6684,7 +6712,7 @@ var LWC = (function (exports) {
|
|
|
6684
6712
|
const targetRoot = target.getRootNode();
|
|
6685
6713
|
if (targetRoot !== root) {
|
|
6686
6714
|
// target element's shadow root is not the same as ours
|
|
6687
|
-
reportViolation(elm, target, attrName);
|
|
6715
|
+
reportViolation$1(elm, target, attrName);
|
|
6688
6716
|
}
|
|
6689
6717
|
}
|
|
6690
6718
|
}
|
|
@@ -6693,7 +6721,7 @@ var LWC = (function (exports) {
|
|
|
6693
6721
|
let enabled = false;
|
|
6694
6722
|
// We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
|
|
6695
6723
|
// reporting is not enabled. It should also only run once
|
|
6696
|
-
function enableDetection() {
|
|
6724
|
+
function enableDetection$1() {
|
|
6697
6725
|
if (enabled) {
|
|
6698
6726
|
return; // don't double-apply the patches
|
|
6699
6727
|
}
|
|
@@ -6745,12 +6773,110 @@ var LWC = (function (exports) {
|
|
|
6745
6773
|
if (supportsCssEscape() && isSyntheticShadowLoaded()) {
|
|
6746
6774
|
// Always run detection in dev mode, so we can at least print to the console
|
|
6747
6775
|
if (process.env.NODE_ENV !== 'production') {
|
|
6748
|
-
enableDetection();
|
|
6776
|
+
enableDetection$1();
|
|
6749
6777
|
}
|
|
6750
6778
|
else {
|
|
6751
6779
|
// In prod mode, only enable detection if reporting is enabled
|
|
6752
|
-
onReportingEnabled(enableDetection);
|
|
6780
|
+
onReportingEnabled(enableDetection$1);
|
|
6781
|
+
}
|
|
6782
|
+
}
|
|
6783
|
+
|
|
6784
|
+
/*
|
|
6785
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6786
|
+
* All rights reserved.
|
|
6787
|
+
* SPDX-License-Identifier: MIT
|
|
6788
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6789
|
+
*/
|
|
6790
|
+
//
|
|
6791
|
+
// The goal of this code is to detect usages of non-standard reflected ARIA properties. These are caused by
|
|
6792
|
+
// legacy non-standard Element.prototype extensions added by the @lwc/aria-reflection package.
|
|
6793
|
+
//
|
|
6794
|
+
// See the README for @lwc/aria-reflection
|
|
6795
|
+
const NON_STANDARD_ARIA_PROPS = ['ariaActiveDescendant', 'ariaControls', 'ariaDescribedBy', 'ariaDetails', 'ariaErrorMessage', 'ariaFlowTo', 'ariaLabelledBy', 'ariaOwns'];
|
|
6796
|
+
function isLightningElement(elm) {
|
|
6797
|
+
// The former case is for `this.prop` (inside component) and the latter is for `element.prop` (outside component).
|
|
6798
|
+
// In both cases, we apply the non-standard prop even when the global polyfill is disabled, so this is kosher.
|
|
6799
|
+
return elm instanceof LightningElement || elm instanceof BaseBridgeElement;
|
|
6800
|
+
}
|
|
6801
|
+
function findVM(elm) {
|
|
6802
|
+
// If it's a shadow DOM component, then it has a host
|
|
6803
|
+
const {
|
|
6804
|
+
host
|
|
6805
|
+
} = elm.getRootNode();
|
|
6806
|
+
const vm = isUndefined$1(host) ? undefined : getAssociatedVMIfPresent(host);
|
|
6807
|
+
if (!isUndefined$1(vm)) {
|
|
6808
|
+
return vm;
|
|
6809
|
+
}
|
|
6810
|
+
// Else it might be a light DOM component. Walk up the tree trying to find the owner
|
|
6811
|
+
let parentElement = elm;
|
|
6812
|
+
while (!isNull(parentElement = parentElement.parentElement)) {
|
|
6813
|
+
if (isLightningElement(parentElement)) {
|
|
6814
|
+
const vm = getAssociatedVMIfPresent(parentElement);
|
|
6815
|
+
if (!isUndefined$1(vm)) {
|
|
6816
|
+
return vm;
|
|
6817
|
+
}
|
|
6818
|
+
}
|
|
6819
|
+
}
|
|
6820
|
+
// If we return undefined, it's because the element was rendered wholly outside a LightningElement
|
|
6821
|
+
}
|
|
6822
|
+
|
|
6823
|
+
function checkAndReportViolation(elm, prop) {
|
|
6824
|
+
if (!isLightningElement(elm)) {
|
|
6825
|
+
const vm = findVM(elm);
|
|
6826
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6827
|
+
logWarnOnce(`Element <${elm.tagName.toLowerCase()}> ` + (isUndefined$1(vm) ? '' : `owned by <${vm.elm.tagName.toLowerCase()}> `) + `uses non-standard property "${prop}". This will be removed in a future version of LWC. ` + `See https://sfdc.co/deprecated-aria`);
|
|
6828
|
+
}
|
|
6829
|
+
report(2 /* ReportingEventId.NonStandardAriaReflection */, {
|
|
6830
|
+
tagName: vm === null || vm === void 0 ? void 0 : vm.tagName,
|
|
6831
|
+
propertyName: prop
|
|
6832
|
+
});
|
|
6833
|
+
}
|
|
6834
|
+
}
|
|
6835
|
+
function enableDetection() {
|
|
6836
|
+
const {
|
|
6837
|
+
prototype
|
|
6838
|
+
} = Element;
|
|
6839
|
+
for (const prop of NON_STANDARD_ARIA_PROPS) {
|
|
6840
|
+
const descriptor = getOwnPropertyDescriptor$1(prototype, prop);
|
|
6841
|
+
// The descriptor should exist because the @lwc/aria-reflection polyfill has run by now.
|
|
6842
|
+
// This happens automatically because of the ordering of imports.
|
|
6843
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6844
|
+
/* istanbul ignore if */
|
|
6845
|
+
if (isUndefined$1(descriptor) || isUndefined$1(descriptor.get) || isUndefined$1(descriptor.set)) {
|
|
6846
|
+
// should never happen
|
|
6847
|
+
throw new Error('detect-non-standard-aria.ts loaded before @lwc/aria-reflection');
|
|
6848
|
+
}
|
|
6849
|
+
}
|
|
6850
|
+
// @ts-ignore
|
|
6851
|
+
const {
|
|
6852
|
+
get,
|
|
6853
|
+
set
|
|
6854
|
+
} = descriptor;
|
|
6855
|
+
defineProperty(prototype, prop, {
|
|
6856
|
+
get() {
|
|
6857
|
+
checkAndReportViolation(this, prop);
|
|
6858
|
+
return get.call(this);
|
|
6859
|
+
},
|
|
6860
|
+
set(val) {
|
|
6861
|
+
checkAndReportViolation(this, prop);
|
|
6862
|
+
return set.call(this, val);
|
|
6863
|
+
},
|
|
6864
|
+
configurable: true,
|
|
6865
|
+
enumerable: true
|
|
6866
|
+
});
|
|
6867
|
+
}
|
|
6868
|
+
}
|
|
6869
|
+
// No point in running this code if we're not in a browser, or if the global polyfill is not loaded
|
|
6870
|
+
{
|
|
6871
|
+
if (!lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
|
|
6872
|
+
// Always run detection in dev mode, so we can at least print to the console
|
|
6873
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6874
|
+
enableDetection();
|
|
6875
|
+
} else {
|
|
6876
|
+
// In prod mode, only enable detection if reporting is enabled
|
|
6877
|
+
onReportingEnabled(enableDetection);
|
|
6753
6878
|
}
|
|
6879
|
+
}
|
|
6754
6880
|
}
|
|
6755
6881
|
|
|
6756
6882
|
/*
|
|
@@ -7237,12 +7363,13 @@ var LWC = (function (exports) {
|
|
|
7237
7363
|
*/
|
|
7238
7364
|
// See @lwc/engine-core/src/framework/template.ts
|
|
7239
7365
|
const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
|
|
7240
|
-
// Via https://www.npmjs.com/package/object-observer
|
|
7241
|
-
const ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
|
|
7242
7366
|
// Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
|
|
7243
|
-
const
|
|
7367
|
+
const STYLESHEET_PROPS = [
|
|
7244
7368
|
// SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
|
|
7245
7369
|
'$scoped$'];
|
|
7370
|
+
// Via https://www.npmjs.com/package/object-observer
|
|
7371
|
+
const ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
|
|
7372
|
+
let mutationTrackingDisabled = false;
|
|
7246
7373
|
function getOriginalArrayMethod(prop) {
|
|
7247
7374
|
switch (prop) {
|
|
7248
7375
|
case 'pop':
|
|
@@ -7265,7 +7392,20 @@ var LWC = (function (exports) {
|
|
|
7265
7392
|
return ArrayCopyWithin;
|
|
7266
7393
|
}
|
|
7267
7394
|
}
|
|
7268
|
-
|
|
7395
|
+
function reportViolation(type, eventId, prop) {
|
|
7396
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7397
|
+
logWarnOnce(`Mutating the "${prop}" property on a ${type} ` + `is deprecated and will be removed in a future version of LWC. ` + `See: https://sfdc.co/template-mutation`);
|
|
7398
|
+
}
|
|
7399
|
+
report(eventId, {
|
|
7400
|
+
propertyName: prop
|
|
7401
|
+
});
|
|
7402
|
+
}
|
|
7403
|
+
function reportTemplateViolation(prop) {
|
|
7404
|
+
reportViolation('template', 3 /* ReportingEventId.TemplateMutation */, prop);
|
|
7405
|
+
}
|
|
7406
|
+
function reportStylesheetViolation(prop) {
|
|
7407
|
+
reportViolation('stylesheet', 4 /* ReportingEventId.StylesheetMutation */, prop);
|
|
7408
|
+
}
|
|
7269
7409
|
// Warn if the user tries to mutate a stylesheets array, e.g.:
|
|
7270
7410
|
// `tmpl.stylesheets.push(someStylesheetFunction)`
|
|
7271
7411
|
function warnOnArrayMutation(stylesheets) {
|
|
@@ -7274,7 +7414,7 @@ var LWC = (function (exports) {
|
|
|
7274
7414
|
for (const prop of ARRAY_MUTATION_METHODS) {
|
|
7275
7415
|
const originalArrayMethod = getOriginalArrayMethod(prop);
|
|
7276
7416
|
stylesheets[prop] = function arrayMutationWarningWrapper() {
|
|
7277
|
-
|
|
7417
|
+
reportTemplateViolation('stylesheets');
|
|
7278
7418
|
// @ts-ignore
|
|
7279
7419
|
return originalArrayMethod.apply(this, arguments);
|
|
7280
7420
|
};
|
|
@@ -7283,8 +7423,7 @@ var LWC = (function (exports) {
|
|
|
7283
7423
|
// Warn if the user tries to mutate a stylesheet factory function, e.g.:
|
|
7284
7424
|
// `stylesheet.$scoped$ = true`
|
|
7285
7425
|
function warnOnStylesheetFunctionMutation(stylesheet) {
|
|
7286
|
-
|
|
7287
|
-
for (const prop of STYLESHEET_FUNCTION_EXPANDOS) {
|
|
7426
|
+
for (const prop of STYLESHEET_PROPS) {
|
|
7288
7427
|
let value = stylesheet[prop];
|
|
7289
7428
|
defineProperty(stylesheet, prop, {
|
|
7290
7429
|
enumerable: true,
|
|
@@ -7293,14 +7432,14 @@ var LWC = (function (exports) {
|
|
|
7293
7432
|
return value;
|
|
7294
7433
|
},
|
|
7295
7434
|
set(newValue) {
|
|
7296
|
-
|
|
7435
|
+
reportStylesheetViolation(prop);
|
|
7297
7436
|
value = newValue;
|
|
7298
7437
|
}
|
|
7299
7438
|
});
|
|
7300
7439
|
}
|
|
7301
7440
|
}
|
|
7302
7441
|
// Warn on either array or stylesheet (function) mutation, in a deeply-nested array
|
|
7303
|
-
function
|
|
7442
|
+
function trackStylesheetsMutation(stylesheets) {
|
|
7304
7443
|
traverseStylesheets(stylesheets, subStylesheets => {
|
|
7305
7444
|
if (isArray$1(subStylesheets)) {
|
|
7306
7445
|
warnOnArrayMutation(subStylesheets);
|
|
@@ -7327,7 +7466,70 @@ var LWC = (function (exports) {
|
|
|
7327
7466
|
}
|
|
7328
7467
|
}
|
|
7329
7468
|
}
|
|
7469
|
+
function trackMutations(tmpl) {
|
|
7470
|
+
if (!isUndefined$1(tmpl.stylesheets)) {
|
|
7471
|
+
trackStylesheetsMutation(tmpl.stylesheets);
|
|
7472
|
+
}
|
|
7473
|
+
for (const prop of TEMPLATE_PROPS) {
|
|
7474
|
+
let value = tmpl[prop];
|
|
7475
|
+
defineProperty(tmpl, prop, {
|
|
7476
|
+
enumerable: true,
|
|
7477
|
+
configurable: true,
|
|
7478
|
+
get() {
|
|
7479
|
+
return value;
|
|
7480
|
+
},
|
|
7481
|
+
set(newValue) {
|
|
7482
|
+
if (!mutationTrackingDisabled) {
|
|
7483
|
+
reportTemplateViolation(prop);
|
|
7484
|
+
}
|
|
7485
|
+
value = newValue;
|
|
7486
|
+
}
|
|
7487
|
+
});
|
|
7488
|
+
}
|
|
7489
|
+
const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
|
|
7490
|
+
defineProperty(tmpl, 'stylesheetTokens', {
|
|
7491
|
+
enumerable: true,
|
|
7492
|
+
configurable: true,
|
|
7493
|
+
get: originalDescriptor.get,
|
|
7494
|
+
set(value) {
|
|
7495
|
+
reportTemplateViolation('stylesheetTokens');
|
|
7496
|
+
// Avoid logging/reporting twice (for both stylesheetToken and stylesheetTokens)
|
|
7497
|
+
mutationTrackingDisabled = true;
|
|
7498
|
+
originalDescriptor.set.call(this, value);
|
|
7499
|
+
mutationTrackingDisabled = false;
|
|
7500
|
+
}
|
|
7501
|
+
});
|
|
7502
|
+
}
|
|
7503
|
+
function addLegacyStylesheetTokensShim(tmpl) {
|
|
7504
|
+
// When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
|
|
7505
|
+
// is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
|
|
7506
|
+
defineProperty(tmpl, 'stylesheetTokens', {
|
|
7507
|
+
enumerable: true,
|
|
7508
|
+
configurable: true,
|
|
7509
|
+
get() {
|
|
7510
|
+
const {
|
|
7511
|
+
stylesheetToken
|
|
7512
|
+
} = this;
|
|
7513
|
+
if (isUndefined$1(stylesheetToken)) {
|
|
7514
|
+
return stylesheetToken;
|
|
7515
|
+
}
|
|
7516
|
+
// Shim for the old `stylesheetTokens` property
|
|
7517
|
+
// See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
|
|
7518
|
+
return {
|
|
7519
|
+
hostAttribute: `${stylesheetToken}-host`,
|
|
7520
|
+
shadowAttribute: stylesheetToken
|
|
7521
|
+
};
|
|
7522
|
+
},
|
|
7523
|
+
set(value) {
|
|
7524
|
+
// If the value is null or some other exotic object, you would be broken anyway in the past
|
|
7525
|
+
// because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
|
|
7526
|
+
// However it may be undefined in newer versions of LWC, so we need to guard against that case.
|
|
7527
|
+
this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
|
|
7528
|
+
}
|
|
7529
|
+
});
|
|
7530
|
+
}
|
|
7330
7531
|
function freezeTemplate(tmpl) {
|
|
7532
|
+
// TODO [#2782]: remove this flag and delete the legacy behavior
|
|
7331
7533
|
if (lwcRuntimeFlags.ENABLE_FROZEN_TEMPLATE) {
|
|
7332
7534
|
// Deep freeze the template
|
|
7333
7535
|
freeze(tmpl);
|
|
@@ -7335,66 +7537,16 @@ var LWC = (function (exports) {
|
|
|
7335
7537
|
deepFreeze(tmpl.stylesheets);
|
|
7336
7538
|
}
|
|
7337
7539
|
} else {
|
|
7338
|
-
//
|
|
7339
|
-
//
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
enumerable: true,
|
|
7343
|
-
configurable: true,
|
|
7344
|
-
get() {
|
|
7345
|
-
const {
|
|
7346
|
-
stylesheetToken
|
|
7347
|
-
} = this;
|
|
7348
|
-
if (isUndefined$1(stylesheetToken)) {
|
|
7349
|
-
return stylesheetToken;
|
|
7350
|
-
}
|
|
7351
|
-
// Shim for the old `stylesheetTokens` property
|
|
7352
|
-
// See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
|
|
7353
|
-
return {
|
|
7354
|
-
hostAttribute: `${stylesheetToken}-host`,
|
|
7355
|
-
shadowAttribute: stylesheetToken
|
|
7356
|
-
};
|
|
7357
|
-
},
|
|
7358
|
-
set(value) {
|
|
7359
|
-
// If the value is null or some other exotic object, you would be broken anyway in the past
|
|
7360
|
-
// because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
|
|
7361
|
-
// However it may be undefined in newer versions of LWC, so we need to guard against that case.
|
|
7362
|
-
this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
|
|
7363
|
-
}
|
|
7364
|
-
});
|
|
7365
|
-
// When ENABLE_FROZEN_TEMPLATE is false, warn in dev mode whenever someone is mutating the template
|
|
7540
|
+
// template is not frozen - shim, report, and warn
|
|
7541
|
+
// this shim should be applied in both dev and prod
|
|
7542
|
+
addLegacyStylesheetTokensShim(tmpl);
|
|
7543
|
+
// When ENABLE_FROZEN_TEMPLATE is false, we want to warn in dev mode whenever someone is mutating the template
|
|
7366
7544
|
if (process.env.NODE_ENV !== 'production') {
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
defineProperty(tmpl, prop, {
|
|
7373
|
-
enumerable: true,
|
|
7374
|
-
configurable: true,
|
|
7375
|
-
get() {
|
|
7376
|
-
return value;
|
|
7377
|
-
},
|
|
7378
|
-
set(newValue) {
|
|
7379
|
-
if (!mutationWarningsSilenced) {
|
|
7380
|
-
logError(`Dynamically setting the "${prop}" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
|
|
7381
|
-
}
|
|
7382
|
-
value = newValue;
|
|
7383
|
-
}
|
|
7384
|
-
});
|
|
7385
|
-
}
|
|
7386
|
-
const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
|
|
7387
|
-
defineProperty(tmpl, 'stylesheetTokens', {
|
|
7388
|
-
enumerable: true,
|
|
7389
|
-
configurable: true,
|
|
7390
|
-
get: originalDescriptor.get,
|
|
7391
|
-
set(value) {
|
|
7392
|
-
logError(`Dynamically setting the "stylesheetTokens" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
|
|
7393
|
-
// Avoid logging twice (for both stylesheetToken and stylesheetTokens)
|
|
7394
|
-
mutationWarningsSilenced = true;
|
|
7395
|
-
originalDescriptor.set.call(this, value);
|
|
7396
|
-
mutationWarningsSilenced = false;
|
|
7397
|
-
}
|
|
7545
|
+
trackMutations(tmpl);
|
|
7546
|
+
} else {
|
|
7547
|
+
// In prod mode, we only track mutations if reporting is enabled
|
|
7548
|
+
onReportingEnabled(() => {
|
|
7549
|
+
trackMutations(tmpl);
|
|
7398
7550
|
});
|
|
7399
7551
|
}
|
|
7400
7552
|
}
|
|
@@ -7422,7 +7574,7 @@ var LWC = (function (exports) {
|
|
|
7422
7574
|
}
|
|
7423
7575
|
return ctor;
|
|
7424
7576
|
}
|
|
7425
|
-
/* version: 2.
|
|
7577
|
+
/* version: 2.37.0 */
|
|
7426
7578
|
|
|
7427
7579
|
/*
|
|
7428
7580
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7765,545 +7917,6 @@ var LWC = (function (exports) {
|
|
|
7765
7917
|
}
|
|
7766
7918
|
};
|
|
7767
7919
|
|
|
7768
|
-
/*
|
|
7769
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
7770
|
-
* All rights reserved.
|
|
7771
|
-
* SPDX-License-Identifier: MIT
|
|
7772
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7773
|
-
*/
|
|
7774
|
-
/**
|
|
7775
|
-
* Create a scoped registry, i.e. a function that can create custom elements whose tag names
|
|
7776
|
-
* do not conflict with third-party custom elements having the same tag name.
|
|
7777
|
-
*/
|
|
7778
|
-
function createScopedRegistry() {
|
|
7779
|
-
if (!hasCustomElements) {
|
|
7780
|
-
// This code should never be reached, because we don't use the pivot registry if
|
|
7781
|
-
// custom elements are unavailable.
|
|
7782
|
-
throw new Error('Custom elements are not supported in this environment.');
|
|
7783
|
-
}
|
|
7784
|
-
const { HTMLElement: NativeHTMLElement } = window;
|
|
7785
|
-
const { hasAttribute: nativeHasAttribute, setAttribute: nativeSetAttribute, removeAttribute: nativeRemoveAttribute, getAttribute: nativeGetAttribute, } = NativeHTMLElement.prototype;
|
|
7786
|
-
const definitionForElement = new WeakMap();
|
|
7787
|
-
const pendingRegistryForElement = new WeakMap();
|
|
7788
|
-
const definitionForConstructor = new WeakMap();
|
|
7789
|
-
const registeredUserCtors = new WeakSet();
|
|
7790
|
-
const registeredPivotCtors = new WeakSet();
|
|
7791
|
-
const pivotCtorByTag = new Map();
|
|
7792
|
-
const globalDefinitionsByTag = new Map();
|
|
7793
|
-
const globalDefinitionsByClass = new Map();
|
|
7794
|
-
const awaitingUpgrade = new Map();
|
|
7795
|
-
const pendingWhenDefinedCallbacks = new Map();
|
|
7796
|
-
const EMPTY_SET = new Set();
|
|
7797
|
-
function createDefinitionRecord(constructor) {
|
|
7798
|
-
var _a;
|
|
7799
|
-
const { connectedCallback, disconnectedCallback, formAssociatedCallback, formDisabledCallback, formResetCallback, formStateRestoreCallback, adoptedCallback, attributeChangedCallback, } = constructor.prototype;
|
|
7800
|
-
const formAssociated = Boolean(constructor.formAssociated);
|
|
7801
|
-
const observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
|
|
7802
|
-
return {
|
|
7803
|
-
UserCtor: constructor,
|
|
7804
|
-
PivotCtor: undefined,
|
|
7805
|
-
connectedCallback,
|
|
7806
|
-
disconnectedCallback,
|
|
7807
|
-
formAssociatedCallback,
|
|
7808
|
-
formDisabledCallback,
|
|
7809
|
-
formResetCallback,
|
|
7810
|
-
formStateRestoreCallback,
|
|
7811
|
-
adoptedCallback,
|
|
7812
|
-
attributeChangedCallback,
|
|
7813
|
-
observedAttributes,
|
|
7814
|
-
formAssociated,
|
|
7815
|
-
};
|
|
7816
|
-
}
|
|
7817
|
-
// Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
|
|
7818
|
-
// element. Note that the `registeredDefinition` represents the constructor that was used to register during
|
|
7819
|
-
// `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
|
|
7820
|
-
// constructor is invoked with another constructor.
|
|
7821
|
-
function createPivotingClass(tagName, registeredDefinition) {
|
|
7822
|
-
class PivotCtor extends NativeHTMLElement {
|
|
7823
|
-
constructor(UserCtor) {
|
|
7824
|
-
// This constructor can only be invoked by:
|
|
7825
|
-
// a) the browser instantiating an element from parsing or via document.createElement.
|
|
7826
|
-
// b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
|
|
7827
|
-
// b) new UserClass.
|
|
7828
|
-
// When LWC instantiates it, it will pass the upgrading definition as an argument
|
|
7829
|
-
// If the caller signals via UserCtor that this is in fact a controlled
|
|
7830
|
-
// definition, we use that one, otherwise fallback to the global
|
|
7831
|
-
// internal registry.
|
|
7832
|
-
super();
|
|
7833
|
-
const userCtorIsDefined = !isUndefined$1(UserCtor);
|
|
7834
|
-
if (userCtorIsDefined) {
|
|
7835
|
-
if (!isConstructor(UserCtor)) {
|
|
7836
|
-
throw new TypeError(`Failed to create custom element: the provided constructor is not a constructor.`);
|
|
7837
|
-
}
|
|
7838
|
-
if (!registeredUserCtors.has(UserCtor)) {
|
|
7839
|
-
throw new Error(`Failed to create custom element: the provided constructor is unregistered: ${UserCtor.name}.`);
|
|
7840
|
-
}
|
|
7841
|
-
}
|
|
7842
|
-
const definition = userCtorIsDefined
|
|
7843
|
-
? getOrCreateDefinitionForConstructor(UserCtor)
|
|
7844
|
-
: globalDefinitionsByTag.get(tagName);
|
|
7845
|
-
if (!isUndefined$1(definition)) {
|
|
7846
|
-
internalUpgrade(this, registeredDefinition, definition);
|
|
7847
|
-
}
|
|
7848
|
-
else {
|
|
7849
|
-
// This is the case in which there is no global definition, and
|
|
7850
|
-
// it is not handled by LWC (otherwise it will have a valid UserCtor)
|
|
7851
|
-
// so we need to add it to the pending queue just in case it eventually
|
|
7852
|
-
// gets defined in the global registry.
|
|
7853
|
-
pendingRegistryForElement.set(this, registeredDefinition);
|
|
7854
|
-
}
|
|
7855
|
-
}
|
|
7856
|
-
connectedCallback() {
|
|
7857
|
-
var _a;
|
|
7858
|
-
const definition = definitionForElement.get(this);
|
|
7859
|
-
if (!isUndefined$1(definition)) {
|
|
7860
|
-
// Delegate out to user callback
|
|
7861
|
-
(_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7862
|
-
}
|
|
7863
|
-
else {
|
|
7864
|
-
// Register for upgrade when defined (only when connected, so we don't leak)
|
|
7865
|
-
let awaiting = awaitingUpgrade.get(tagName);
|
|
7866
|
-
if (isUndefined$1(awaiting)) {
|
|
7867
|
-
awaitingUpgrade.set(tagName, (awaiting = new Set()));
|
|
7868
|
-
}
|
|
7869
|
-
awaiting.add(this);
|
|
7870
|
-
}
|
|
7871
|
-
}
|
|
7872
|
-
disconnectedCallback() {
|
|
7873
|
-
var _a;
|
|
7874
|
-
const definition = definitionForElement.get(this);
|
|
7875
|
-
if (!isUndefined$1(definition)) {
|
|
7876
|
-
// Delegate out to user callback
|
|
7877
|
-
(_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7878
|
-
}
|
|
7879
|
-
else {
|
|
7880
|
-
// Un-register for upgrade when defined (so we don't leak)
|
|
7881
|
-
const awaiting = awaitingUpgrade.get(tagName);
|
|
7882
|
-
// At this point, awaiting should never be undefined, because connectedCallback
|
|
7883
|
-
// must have been called before disconnectedCallback. But just to be safe, we check
|
|
7884
|
-
if (!isUndefined$1(awaiting)) {
|
|
7885
|
-
awaiting.delete(this);
|
|
7886
|
-
}
|
|
7887
|
-
}
|
|
7888
|
-
}
|
|
7889
|
-
formAssociatedCallback(form) {
|
|
7890
|
-
var _a;
|
|
7891
|
-
const definition = definitionForElement.get(this);
|
|
7892
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formAssociatedCallback) === null || _a === void 0 ? void 0 : _a.call(this, form);
|
|
7893
|
-
}
|
|
7894
|
-
formDisabledCallback(disabled) {
|
|
7895
|
-
var _a;
|
|
7896
|
-
const definition = definitionForElement.get(this);
|
|
7897
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formDisabledCallback) === null || _a === void 0 ? void 0 : _a.call(this, disabled);
|
|
7898
|
-
}
|
|
7899
|
-
formResetCallback() {
|
|
7900
|
-
var _a;
|
|
7901
|
-
const definition = definitionForElement.get(this);
|
|
7902
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formResetCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7903
|
-
}
|
|
7904
|
-
formStateRestoreCallback(state, mode) {
|
|
7905
|
-
var _a;
|
|
7906
|
-
const definition = definitionForElement.get(this);
|
|
7907
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formStateRestoreCallback) === null || _a === void 0 ? void 0 : _a.call(this, state, mode);
|
|
7908
|
-
}
|
|
7909
|
-
adoptedCallback() {
|
|
7910
|
-
var _a;
|
|
7911
|
-
const definition = definitionForElement.get(this);
|
|
7912
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
7913
|
-
}
|
|
7914
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
7915
|
-
var _a;
|
|
7916
|
-
const definition = definitionForElement.get(this);
|
|
7917
|
-
// if both definitions are the same, then the observedAttributes is the same,
|
|
7918
|
-
// but if they are different, only if the runtime definition has the attribute
|
|
7919
|
-
// marked as observed, then it should invoke attributeChangedCallback.
|
|
7920
|
-
if (registeredDefinition === definition ||
|
|
7921
|
-
(definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
|
|
7922
|
-
(_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
|
|
7923
|
-
}
|
|
7924
|
-
}
|
|
7925
|
-
}
|
|
7926
|
-
PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
|
|
7927
|
-
// TODO [#3000]: support case where registeredDefinition is not form-associated, but later definition is.
|
|
7928
|
-
PivotCtor.formAssociated = registeredDefinition.formAssociated;
|
|
7929
|
-
registeredPivotCtors.add(PivotCtor);
|
|
7930
|
-
return PivotCtor;
|
|
7931
|
-
}
|
|
7932
|
-
function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
|
|
7933
|
-
const { observedAttributes, attributeChangedCallback } = pivotDefinition;
|
|
7934
|
-
if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
|
|
7935
|
-
// This instance does not need to observe any attributes, no need to patch
|
|
7936
|
-
return EMPTY_SET;
|
|
7937
|
-
}
|
|
7938
|
-
// Natively, the attributes observed by the registered definition are going to be taken
|
|
7939
|
-
// care of by the browser, only the difference between the two sets has to be taken
|
|
7940
|
-
// care by the patched version.
|
|
7941
|
-
return new Set([...pivotDefinition.observedAttributes].filter((x) => !registeredDefinition.observedAttributes.has(x)));
|
|
7942
|
-
}
|
|
7943
|
-
function throwAsyncError(error) {
|
|
7944
|
-
// Per native custom element behavior, errors thrown in attributeChangedCallback
|
|
7945
|
-
// become unhandled async errors. We use setTimeout() instead of Promise.resolve()
|
|
7946
|
-
// to make it an unhandled error rather than an unhandled rejection.
|
|
7947
|
-
setTimeout(() => {
|
|
7948
|
-
throw error;
|
|
7949
|
-
});
|
|
7950
|
-
}
|
|
7951
|
-
// Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
|
|
7952
|
-
// Why is this necessary? Well basically, you can't change the `observedAttributes` after
|
|
7953
|
-
// a custom element is defined. So with pivots, if two classes share the same tag name,
|
|
7954
|
-
// and the second class observes attributes that aren't observed by the first one,
|
|
7955
|
-
// then those attributes can never be observed by the native `observedAttributes` system.
|
|
7956
|
-
// So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
|
|
7957
|
-
// we only do this when absolutely necessary, though; i.e. because we've determined
|
|
7958
|
-
// that we aren't observing the attributes we need to.
|
|
7959
|
-
function patchAttributes(instance, registeredDefinition, pivotDefinition) {
|
|
7960
|
-
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
7961
|
-
if (newObservedAttributes.size === 0) {
|
|
7962
|
-
return;
|
|
7963
|
-
}
|
|
7964
|
-
const { attributeChangedCallback } = pivotDefinition;
|
|
7965
|
-
// Patch the instance.
|
|
7966
|
-
// Note we use the native `getAttribute` rather than the super's `getAttribute` because
|
|
7967
|
-
// we don't actually want it to be observable that we're calling `getAttribute` from
|
|
7968
|
-
// `setAttribute` and `removeAttribute`.
|
|
7969
|
-
// TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
|
|
7970
|
-
defineProperties(instance, {
|
|
7971
|
-
setAttribute: {
|
|
7972
|
-
value: function setAttribute(name, value) {
|
|
7973
|
-
if (newObservedAttributes.has(name)) {
|
|
7974
|
-
const old = nativeGetAttribute.call(this, name);
|
|
7975
|
-
nativeSetAttribute.call(this, name, value);
|
|
7976
|
-
try {
|
|
7977
|
-
attributeChangedCallback.call(this, name, old, value + '');
|
|
7978
|
-
}
|
|
7979
|
-
catch (error) {
|
|
7980
|
-
throwAsyncError(error);
|
|
7981
|
-
}
|
|
7982
|
-
}
|
|
7983
|
-
else {
|
|
7984
|
-
nativeSetAttribute.call(this, name, value);
|
|
7985
|
-
}
|
|
7986
|
-
},
|
|
7987
|
-
writable: true,
|
|
7988
|
-
enumerable: true,
|
|
7989
|
-
configurable: true,
|
|
7990
|
-
},
|
|
7991
|
-
removeAttribute: {
|
|
7992
|
-
value: function removeAttribute(name) {
|
|
7993
|
-
if (newObservedAttributes.has(name)) {
|
|
7994
|
-
const old = nativeGetAttribute.call(this, name);
|
|
7995
|
-
nativeRemoveAttribute.call(this, name);
|
|
7996
|
-
try {
|
|
7997
|
-
attributeChangedCallback.call(this, name, old, null);
|
|
7998
|
-
}
|
|
7999
|
-
catch (error) {
|
|
8000
|
-
throwAsyncError(error);
|
|
8001
|
-
}
|
|
8002
|
-
}
|
|
8003
|
-
else {
|
|
8004
|
-
nativeRemoveAttribute.call(this, name);
|
|
8005
|
-
}
|
|
8006
|
-
},
|
|
8007
|
-
writable: true,
|
|
8008
|
-
enumerable: true,
|
|
8009
|
-
configurable: true,
|
|
8010
|
-
},
|
|
8011
|
-
});
|
|
8012
|
-
}
|
|
8013
|
-
function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
8014
|
-
// The below case patches observed attributes for the case where the HTML element is upgraded
|
|
8015
|
-
// from a pre-existing one in the DOM.
|
|
8016
|
-
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
8017
|
-
if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
|
|
8018
|
-
return;
|
|
8019
|
-
}
|
|
8020
|
-
const { attributeChangedCallback } = pivotDefinition;
|
|
8021
|
-
// Approximate observedAttributes from the user class, but only for the new observed attributes
|
|
8022
|
-
newObservedAttributes.forEach((name) => {
|
|
8023
|
-
if (nativeHasAttribute.call(instance, name)) {
|
|
8024
|
-
const newValue = nativeGetAttribute.call(instance, name);
|
|
8025
|
-
attributeChangedCallback.call(instance, name, null, newValue);
|
|
8026
|
-
}
|
|
8027
|
-
});
|
|
8028
|
-
}
|
|
8029
|
-
// User extends this HTMLElement, which returns the CE being upgraded
|
|
8030
|
-
let upgradingInstance;
|
|
8031
|
-
// Helper to upgrade an instance with a CE definition using "constructor call trick"
|
|
8032
|
-
function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
8033
|
-
setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
|
|
8034
|
-
definitionForElement.set(instance, pivotDefinition);
|
|
8035
|
-
// attributes patches when needed
|
|
8036
|
-
if (pivotDefinition !== registeredDefinition) {
|
|
8037
|
-
patchAttributes(instance, registeredDefinition, pivotDefinition);
|
|
8038
|
-
}
|
|
8039
|
-
// Tricking the construction path to believe that a new instance is being created,
|
|
8040
|
-
// that way it will execute the super initialization mechanism but the HTMLElement
|
|
8041
|
-
// constructor will reuse the instance by returning the upgradingInstance.
|
|
8042
|
-
// This is by far the most important piece of the puzzle
|
|
8043
|
-
upgradingInstance = instance;
|
|
8044
|
-
// By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
|
|
8045
|
-
// The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
|
|
8046
|
-
// Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
|
|
8047
|
-
new pivotDefinition.UserCtor();
|
|
8048
|
-
patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
|
|
8049
|
-
}
|
|
8050
|
-
function isConstructor(constructor) {
|
|
8051
|
-
return isFunction$1(constructor) && isObject(constructor.prototype);
|
|
8052
|
-
}
|
|
8053
|
-
function getOrCreateDefinitionForConstructor(constructor) {
|
|
8054
|
-
if (!isConstructor(constructor)) {
|
|
8055
|
-
throw new TypeError('The referenced constructor is not a constructor.');
|
|
8056
|
-
}
|
|
8057
|
-
const definition = definitionForConstructor.get(constructor);
|
|
8058
|
-
if (!isUndefined$1(definition)) {
|
|
8059
|
-
return definition;
|
|
8060
|
-
}
|
|
8061
|
-
return createDefinitionRecord(constructor);
|
|
8062
|
-
}
|
|
8063
|
-
// Defer a `whenDefined()` callback until an externally-visible custom element is defined
|
|
8064
|
-
function createPendingWhenDefinedCallback(tagName) {
|
|
8065
|
-
return new Promise((resolve) => {
|
|
8066
|
-
let resolvers = pendingWhenDefinedCallbacks.get(tagName);
|
|
8067
|
-
if (isUndefined$1(resolvers)) {
|
|
8068
|
-
resolvers = [];
|
|
8069
|
-
pendingWhenDefinedCallbacks.set(tagName, resolvers);
|
|
8070
|
-
}
|
|
8071
|
-
resolvers.push(resolve);
|
|
8072
|
-
});
|
|
8073
|
-
}
|
|
8074
|
-
// Call any pending `whenDefined()` callbacks
|
|
8075
|
-
function flushPendingWhenDefinedCallbacks(tagName, ctor) {
|
|
8076
|
-
const resolvers = pendingWhenDefinedCallbacks.get(tagName);
|
|
8077
|
-
if (!isUndefined$1(resolvers)) {
|
|
8078
|
-
for (const resolver of resolvers) {
|
|
8079
|
-
resolver(ctor);
|
|
8080
|
-
}
|
|
8081
|
-
}
|
|
8082
|
-
pendingWhenDefinedCallbacks.delete(tagName);
|
|
8083
|
-
}
|
|
8084
|
-
const { customElements: nativeRegistry } = window;
|
|
8085
|
-
const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
|
|
8086
|
-
// patch for the global registry define mechanism
|
|
8087
|
-
CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
|
|
8088
|
-
if (options && options.extends) {
|
|
8089
|
-
// TODO [#2983]: should we support `extends`?
|
|
8090
|
-
throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
|
|
8091
|
-
}
|
|
8092
|
-
if (globalDefinitionsByTag.has(tagName)) {
|
|
8093
|
-
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`);
|
|
8094
|
-
}
|
|
8095
|
-
if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
|
|
8096
|
-
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`);
|
|
8097
|
-
}
|
|
8098
|
-
const definition = getOrCreateDefinitionForConstructor(constructor);
|
|
8099
|
-
registeredUserCtors.add(constructor);
|
|
8100
|
-
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
8101
|
-
if (isUndefined$1(PivotCtor)) {
|
|
8102
|
-
PivotCtor = createPivotingClass(tagName, definition);
|
|
8103
|
-
// Register a pivoting class which will handle global registry initializations
|
|
8104
|
-
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
8105
|
-
}
|
|
8106
|
-
// Only cache after nativeDefine has been called, because if it throws an error
|
|
8107
|
-
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
8108
|
-
definitionForConstructor.set(constructor, definition);
|
|
8109
|
-
pivotCtorByTag.set(tagName, PivotCtor);
|
|
8110
|
-
globalDefinitionsByTag.set(tagName, definition);
|
|
8111
|
-
globalDefinitionsByClass.set(constructor, definition);
|
|
8112
|
-
// For globally defined custom elements, the definition associated
|
|
8113
|
-
// to the UserCtor has a back-pointer to PivotCtor in case the user
|
|
8114
|
-
// new the UserCtor, so we know how to create the underlying element.
|
|
8115
|
-
definition.PivotCtor = PivotCtor;
|
|
8116
|
-
// Upgrade any elements created in this scope before customElements.define
|
|
8117
|
-
// was called, which should be exhibited by the following steps:
|
|
8118
|
-
// 1) LWC registers a tagName for an LWC component.
|
|
8119
|
-
// 2) Element with same tagName is created with document.createElement()
|
|
8120
|
-
// and inserted into DOM.
|
|
8121
|
-
// 3) customElements.define() is called with tagName and non-LWC constructor.
|
|
8122
|
-
// This requires immediate upgrade when the new global tagName is defined.
|
|
8123
|
-
const awaiting = awaitingUpgrade.get(tagName);
|
|
8124
|
-
if (!isUndefined$1(awaiting)) {
|
|
8125
|
-
awaitingUpgrade.delete(tagName);
|
|
8126
|
-
for (const element of awaiting) {
|
|
8127
|
-
const registeredDefinition = pendingRegistryForElement.get(element);
|
|
8128
|
-
// At this point, registeredDefinition should never be undefined because awaitingUpgrade
|
|
8129
|
-
// is only populated when we haven't run internalUpgrade yet, and we only populate
|
|
8130
|
-
// pendingRegistryForElement when internalUpgrade hasn't run yet.
|
|
8131
|
-
// But just to be safe, we check.
|
|
8132
|
-
if (!isUndefined$1(registeredDefinition)) {
|
|
8133
|
-
pendingRegistryForElement.delete(element);
|
|
8134
|
-
internalUpgrade(element, registeredDefinition, definition);
|
|
8135
|
-
}
|
|
8136
|
-
}
|
|
8137
|
-
}
|
|
8138
|
-
// If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
|
|
8139
|
-
flushPendingWhenDefinedCallbacks(tagName, constructor);
|
|
8140
|
-
};
|
|
8141
|
-
CustomElementRegistry.prototype.get = function get(tagName) {
|
|
8142
|
-
const NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
8143
|
-
if (!isUndefined$1(NativeCtor)) {
|
|
8144
|
-
const definition = globalDefinitionsByTag.get(tagName);
|
|
8145
|
-
if (!isUndefined$1(definition)) {
|
|
8146
|
-
return definition.UserCtor; // defined by the patched custom elements registry
|
|
8147
|
-
}
|
|
8148
|
-
if (registeredPivotCtors.has(NativeCtor)) {
|
|
8149
|
-
return undefined; // pivot constructors should not be observable, return undefined
|
|
8150
|
-
}
|
|
8151
|
-
return NativeCtor; // constructor that existed before patching
|
|
8152
|
-
}
|
|
8153
|
-
};
|
|
8154
|
-
CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
|
|
8155
|
-
return nativeWhenDefined.call(nativeRegistry, tagName).then((NativeCtor) => {
|
|
8156
|
-
const definition = globalDefinitionsByTag.get(tagName);
|
|
8157
|
-
if (!isUndefined$1(definition)) {
|
|
8158
|
-
return definition.UserCtor;
|
|
8159
|
-
}
|
|
8160
|
-
// In this case, the custom element must have been defined before the registry patches
|
|
8161
|
-
// were applied. So return the non-pivot constructor
|
|
8162
|
-
if (isUndefined$1(NativeCtor)) {
|
|
8163
|
-
// Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
|
|
8164
|
-
// We can patch the correct behavior using customElements.get()
|
|
8165
|
-
NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
8166
|
-
}
|
|
8167
|
-
if (registeredPivotCtors.has(NativeCtor)) {
|
|
8168
|
-
// Pivot constructors should not be observable. Wait to resolve the promise
|
|
8169
|
-
// if a constructor is ever defined in userland
|
|
8170
|
-
return createPendingWhenDefinedCallback(tagName);
|
|
8171
|
-
}
|
|
8172
|
-
return NativeCtor;
|
|
8173
|
-
});
|
|
8174
|
-
};
|
|
8175
|
-
// This constructor is invoked when we call `new pivotDefinition.UserCtor()`
|
|
8176
|
-
// @ts-ignore
|
|
8177
|
-
window.HTMLElement = function HTMLElement() {
|
|
8178
|
-
// Upgrading case: the pivoting class constructor was run by the browser's
|
|
8179
|
-
// native custom elements and we're in the process of running the
|
|
8180
|
-
// "constructor-call trick" on the natively constructed instance, so just
|
|
8181
|
-
// return that here.
|
|
8182
|
-
// This code path is also called when LWC `new`s a PivotCtor.
|
|
8183
|
-
const instance = upgradingInstance;
|
|
8184
|
-
if (!isUndefined$1(instance)) {
|
|
8185
|
-
upgradingInstance = undefined;
|
|
8186
|
-
return instance;
|
|
8187
|
-
}
|
|
8188
|
-
// Construction case: we need to construct the pivoting instance and return it.
|
|
8189
|
-
// This is possible when the user register it via global registry and instantiate
|
|
8190
|
-
// it via `new Ctor()`.
|
|
8191
|
-
const { constructor } = this;
|
|
8192
|
-
const definition = globalDefinitionsByClass.get(constructor);
|
|
8193
|
-
if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
|
|
8194
|
-
// This code path is hit if someone `new`s a class that extends `HTMLElement` without
|
|
8195
|
-
// doing `customElements.define()` first. This matches native browser behavior:
|
|
8196
|
-
// https://stackoverflow.com/a/61883392
|
|
8197
|
-
throw new TypeError('Illegal constructor');
|
|
8198
|
-
}
|
|
8199
|
-
// This constructor is ONLY invoked when it is the user instantiating
|
|
8200
|
-
// an element via new Ctor while Ctor is a registered global constructor.
|
|
8201
|
-
const { PivotCtor, UserCtor } = definition;
|
|
8202
|
-
return new PivotCtor(UserCtor);
|
|
8203
|
-
};
|
|
8204
|
-
HTMLElement.prototype = NativeHTMLElement.prototype;
|
|
8205
|
-
/**
|
|
8206
|
-
* Create a new PivotConstructor for the given tagName, which is capable of being constructed
|
|
8207
|
-
* with a UserConstructor defining the behavior. Passing in the UserConstructor here
|
|
8208
|
-
* is a hint that can be used when registering a custom element with the global custom elements
|
|
8209
|
-
* registry for the first time, which provides certain optimizations. It also marks the UserConstructor
|
|
8210
|
-
* as "safe" to be used when passed in to a PivotConstructor.
|
|
8211
|
-
*
|
|
8212
|
-
* @param tagName - element tag name
|
|
8213
|
-
* @param UserCtor - userland custom element constructor
|
|
8214
|
-
* @returns a new custom element constructor
|
|
8215
|
-
*/
|
|
8216
|
-
return function createPivotConstructor(tagName, UserCtor) {
|
|
8217
|
-
tagName = StringToLowerCase.call(tagName);
|
|
8218
|
-
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
8219
|
-
if (isUndefined$1(PivotCtor)) {
|
|
8220
|
-
const definition = getOrCreateDefinitionForConstructor(UserCtor);
|
|
8221
|
-
PivotCtor = createPivotingClass(tagName, definition);
|
|
8222
|
-
// Register a pivoting class as a global custom element
|
|
8223
|
-
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
8224
|
-
definition.PivotCtor = PivotCtor;
|
|
8225
|
-
// Only cache after nativeDefine has been called, because if it throws an error
|
|
8226
|
-
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
8227
|
-
definitionForConstructor.set(UserCtor, definition);
|
|
8228
|
-
pivotCtorByTag.set(tagName, PivotCtor);
|
|
8229
|
-
}
|
|
8230
|
-
// Register a UserConstructor as "safe" to be used within a PivotConstructor
|
|
8231
|
-
registeredUserCtors.add(UserCtor);
|
|
8232
|
-
return PivotCtor;
|
|
8233
|
-
};
|
|
8234
|
-
}
|
|
8235
|
-
|
|
8236
|
-
/*
|
|
8237
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
8238
|
-
* All rights reserved.
|
|
8239
|
-
* SPDX-License-Identifier: MIT
|
|
8240
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8241
|
-
*/
|
|
8242
|
-
let createScopedConstructor;
|
|
8243
|
-
let CachedHTMLElement;
|
|
8244
|
-
// We only call `createScopedRegistry()` if the browser supports custom elements and
|
|
8245
|
-
// ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
|
|
8246
|
-
// or we're in a legacy browser.
|
|
8247
|
-
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
8248
|
-
if (hasCustomElements) {
|
|
8249
|
-
// If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
|
|
8250
|
-
// It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
|
|
8251
|
-
//
|
|
8252
|
-
// Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
|
|
8253
|
-
//
|
|
8254
|
-
// 1. LWC loads
|
|
8255
|
-
// 2. `const Ctor = class extends HTMLElement {}`
|
|
8256
|
-
// 3. `lwc.createElement(...)` // here we lazily patch
|
|
8257
|
-
// 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
|
|
8258
|
-
//
|
|
8259
|
-
// To reduce the risk of this, it's safer to patch the registry eagerly.
|
|
8260
|
-
createScopedConstructor = createScopedRegistry();
|
|
8261
|
-
// It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
|
|
8262
|
-
// another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
|
|
8263
|
-
// because the HTMLElement prototypes are mixed up.
|
|
8264
|
-
//
|
|
8265
|
-
// The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
|
|
8266
|
-
// with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
|
|
8267
|
-
// the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
|
|
8268
|
-
// Caching avoids this problem.
|
|
8269
|
-
CachedHTMLElement = window.HTMLElement;
|
|
8270
|
-
}
|
|
8271
|
-
}
|
|
8272
|
-
// Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
|
|
8273
|
-
// In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
|
|
8274
|
-
// multiple times per tag name.
|
|
8275
|
-
const createUserConstructor = (HTMLElementToExtend, upgradeCallback, connectedCallback, disconnectedCallback) => {
|
|
8276
|
-
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
8277
|
-
return class UserConstructor extends HTMLElementToExtend {
|
|
8278
|
-
constructor() {
|
|
8279
|
-
super();
|
|
8280
|
-
upgradeCallback(this);
|
|
8281
|
-
}
|
|
8282
|
-
// Note that there is no need to do the "avoid defining connectedCallback/disconnectedCallback" optimization
|
|
8283
|
-
// here, because in create-scoped-registry.ts, the registered class will always have these callbacks anyway.
|
|
8284
|
-
// See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
|
|
8285
|
-
connectedCallback() {
|
|
8286
|
-
if (!isUndefined$1(connectedCallback)) {
|
|
8287
|
-
connectedCallback(this);
|
|
8288
|
-
}
|
|
8289
|
-
}
|
|
8290
|
-
disconnectedCallback() {
|
|
8291
|
-
if (!isUndefined$1(disconnectedCallback)) {
|
|
8292
|
-
disconnectedCallback(this);
|
|
8293
|
-
}
|
|
8294
|
-
}
|
|
8295
|
-
};
|
|
8296
|
-
};
|
|
8297
|
-
function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
8298
|
-
if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
|
|
8299
|
-
// This error should be impossible to hit
|
|
8300
|
-
throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
|
|
8301
|
-
}
|
|
8302
|
-
const UserConstructor = createUserConstructor(CachedHTMLElement, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
8303
|
-
const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
|
|
8304
|
-
return new ScopedConstructor(UserConstructor);
|
|
8305
|
-
}
|
|
8306
|
-
|
|
8307
7920
|
/*
|
|
8308
7921
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
8309
7922
|
* All rights reserved.
|
|
@@ -8311,29 +7924,22 @@ var LWC = (function (exports) {
|
|
|
8311
7924
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8312
7925
|
*/
|
|
8313
7926
|
/**
|
|
8314
|
-
* We have
|
|
7927
|
+
* We have two modes for creating custom elements:
|
|
8315
7928
|
*
|
|
8316
7929
|
* 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
|
|
8317
7930
|
* 2. "Upgradable constructor" custom element. This allows us to have two LWC components with the same tag name,
|
|
8318
7931
|
* via a trick: every custom element constructor we define in the registry is basically the same. It's essentially
|
|
8319
7932
|
* a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its constructor ("upgradable
|
|
8320
7933
|
* constructor"), which allows us to have completely customized functionality for different components.
|
|
8321
|
-
* 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
|
|
8322
|
-
* elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
|
|
8323
|
-
* between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
|
|
8324
|
-
* because it must patch the global `customElements` and `HTMLElement` objects.
|
|
8325
7934
|
*/
|
|
8326
7935
|
let createCustomElement;
|
|
8327
7936
|
if (hasCustomElements) {
|
|
8328
|
-
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
8329
|
-
createCustomElement = createCustomElementScoped;
|
|
8330
|
-
} else {
|
|
8331
7937
|
// use the global registry, with an upgradable constructor for the defined custom element
|
|
8332
7938
|
createCustomElement = createCustomElementUsingUpgradableConstructor;
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
|
|
7939
|
+
}
|
|
7940
|
+
else {
|
|
7941
|
+
// no registry available here
|
|
7942
|
+
createCustomElement = createCustomElementCompat;
|
|
8337
7943
|
}
|
|
8338
7944
|
|
|
8339
7945
|
/*
|
|
@@ -8396,7 +8002,7 @@ var LWC = (function (exports) {
|
|
|
8396
8002
|
function isNull(obj) {
|
|
8397
8003
|
return obj === null;
|
|
8398
8004
|
}
|
|
8399
|
-
/** version: 2.
|
|
8005
|
+
/** version: 2.37.0 */
|
|
8400
8006
|
|
|
8401
8007
|
/*
|
|
8402
8008
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8957,7 +8563,7 @@ var LWC = (function (exports) {
|
|
|
8957
8563
|
});
|
|
8958
8564
|
freeze(LightningElement);
|
|
8959
8565
|
seal(LightningElement.prototype);
|
|
8960
|
-
/* version: 2.
|
|
8566
|
+
/* version: 2.37.0 */
|
|
8961
8567
|
|
|
8962
8568
|
exports.LightningElement = LightningElement;
|
|
8963
8569
|
exports.__unstable__ProfilerControl = profilerControl;
|