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