lwc 2.36.0 → 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 +26 -576
- package/dist/engine-dom/iife/es2017/engine-dom.js +26 -576
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +18 -568
- package/dist/engine-dom/iife/es5/engine-dom.js +38 -654
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +30 -646
- package/dist/engine-dom/umd/es2017/engine-dom.js +26 -576
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +18 -568
- package/dist/engine-dom/umd/es5/engine-dom.js +38 -654
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +30 -646
- package/dist/engine-server/commonjs/es2017/engine-server.js +38 -24
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +38 -25
- 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
|
@@ -329,9 +329,9 @@ function htmlAttributeToProperty(attrName) {
|
|
|
329
329
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
330
330
|
*/
|
|
331
331
|
// Increment whenever the LWC template compiler changes
|
|
332
|
-
const LWC_VERSION = "2.
|
|
332
|
+
const LWC_VERSION = "2.37.0";
|
|
333
333
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
334
|
-
/** version: 2.
|
|
334
|
+
/** version: 2.37.0 */
|
|
335
335
|
|
|
336
336
|
/**
|
|
337
337
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -351,10 +351,8 @@ const features = {
|
|
|
351
351
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
352
352
|
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
353
353
|
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
354
|
-
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
355
354
|
ENABLE_FROZEN_TEMPLATE: null,
|
|
356
355
|
DISABLE_ARIA_REFLECTION_POLYFILL: null,
|
|
357
|
-
ENABLE_PROGRAMMATIC_STYLESHEETS: null,
|
|
358
356
|
};
|
|
359
357
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
360
358
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -410,7 +408,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
410
408
|
setFeatureFlag(name, value);
|
|
411
409
|
}
|
|
412
410
|
}
|
|
413
|
-
/** version: 2.
|
|
411
|
+
/** version: 2.37.0 */
|
|
414
412
|
|
|
415
413
|
/**
|
|
416
414
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -474,7 +472,7 @@ function applyAriaReflection(prototype = Element.prototype) {
|
|
|
474
472
|
}
|
|
475
473
|
}
|
|
476
474
|
}
|
|
477
|
-
/** version: 2.
|
|
475
|
+
/** version: 2.37.0 */
|
|
478
476
|
|
|
479
477
|
/*
|
|
480
478
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6239,18 +6237,16 @@ function validateComponentStylesheets(vm, stylesheets) {
|
|
|
6239
6237
|
}
|
|
6240
6238
|
// Validate and flatten any stylesheets defined as `static stylesheets`
|
|
6241
6239
|
function computeStylesheets(vm, ctor) {
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
logError(`static stylesheets must be an array of CSS stylesheets. Found invalid stylesheets on <${vm.tagName}>`, vm);
|
|
6253
|
-
}
|
|
6240
|
+
warnOnStylesheetsMutation(ctor);
|
|
6241
|
+
const {
|
|
6242
|
+
stylesheets
|
|
6243
|
+
} = ctor;
|
|
6244
|
+
if (!isUndefined$1(stylesheets)) {
|
|
6245
|
+
const valid = validateComponentStylesheets(vm, stylesheets);
|
|
6246
|
+
if (valid) {
|
|
6247
|
+
return flattenStylesheets(stylesheets);
|
|
6248
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
6249
|
+
logError(`static stylesheets must be an array of CSS stylesheets. Found invalid stylesheets on <${vm.tagName}>`, vm);
|
|
6254
6250
|
}
|
|
6255
6251
|
}
|
|
6256
6252
|
return null;
|
|
@@ -6644,7 +6640,7 @@ function forceRehydration(vm) {
|
|
|
6644
6640
|
// The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
|
|
6645
6641
|
// These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
|
|
6646
6642
|
// When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
|
|
6647
|
-
// See: https://
|
|
6643
|
+
// See: https://sfdc.co/synthetic-aria
|
|
6648
6644
|
//
|
|
6649
6645
|
// Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
|
|
6650
6646
|
const getElementById = _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
|
|
@@ -6671,7 +6667,7 @@ function reportViolation$1(source, target, attrName) {
|
|
|
6671
6667
|
// Avoid excessively logging to the console in the case of duplicates.
|
|
6672
6668
|
logWarnOnce(`Element <${source.tagName.toLowerCase()}> uses attribute "${attrName}" to reference element ` +
|
|
6673
6669
|
`<${target.tagName.toLowerCase()}>, which is not in the same shadow root. This will break in native shadow DOM. ` +
|
|
6674
|
-
`For details, see: https://
|
|
6670
|
+
`For details, see: https://sfdc.co/synthetic-aria`, vm);
|
|
6675
6671
|
}
|
|
6676
6672
|
}
|
|
6677
6673
|
function parseIdRefAttributeValue(attrValue) {
|
|
@@ -6825,7 +6821,7 @@ function checkAndReportViolation(elm, prop) {
|
|
|
6825
6821
|
if (!isLightningElement(elm)) {
|
|
6826
6822
|
const vm = findVM(elm);
|
|
6827
6823
|
if (process.env.NODE_ENV !== 'production') {
|
|
6828
|
-
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://
|
|
6824
|
+
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`);
|
|
6829
6825
|
}
|
|
6830
6826
|
report(2 /* ReportingEventId.NonStandardAriaReflection */, {
|
|
6831
6827
|
tagName: vm === null || vm === void 0 ? void 0 : vm.tagName,
|
|
@@ -7395,7 +7391,7 @@ function getOriginalArrayMethod(prop) {
|
|
|
7395
7391
|
}
|
|
7396
7392
|
function reportViolation(type, eventId, prop) {
|
|
7397
7393
|
if (process.env.NODE_ENV !== 'production') {
|
|
7398
|
-
logWarnOnce(`Mutating the "${prop}" property on a ${type} ` + `is deprecated and will be removed in a future version of LWC. ` + `See: https://
|
|
7394
|
+
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`);
|
|
7399
7395
|
}
|
|
7400
7396
|
report(eventId, {
|
|
7401
7397
|
propertyName: prop
|
|
@@ -7575,7 +7571,7 @@ function getComponentConstructor(elm) {
|
|
|
7575
7571
|
}
|
|
7576
7572
|
return ctor;
|
|
7577
7573
|
}
|
|
7578
|
-
/* version: 2.
|
|
7574
|
+
/* version: 2.37.0 */
|
|
7579
7575
|
|
|
7580
7576
|
/*
|
|
7581
7577
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7918,545 +7914,6 @@ const createCustomElementUsingUpgradableConstructor = (tagName, upgradeCallback,
|
|
|
7918
7914
|
}
|
|
7919
7915
|
};
|
|
7920
7916
|
|
|
7921
|
-
/*
|
|
7922
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
7923
|
-
* All rights reserved.
|
|
7924
|
-
* SPDX-License-Identifier: MIT
|
|
7925
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7926
|
-
*/
|
|
7927
|
-
/**
|
|
7928
|
-
* Create a scoped registry, i.e. a function that can create custom elements whose tag names
|
|
7929
|
-
* do not conflict with third-party custom elements having the same tag name.
|
|
7930
|
-
*/
|
|
7931
|
-
function createScopedRegistry() {
|
|
7932
|
-
if (!hasCustomElements) {
|
|
7933
|
-
// This code should never be reached, because we don't use the pivot registry if
|
|
7934
|
-
// custom elements are unavailable.
|
|
7935
|
-
throw new Error('Custom elements are not supported in this environment.');
|
|
7936
|
-
}
|
|
7937
|
-
const { HTMLElement: NativeHTMLElement } = window;
|
|
7938
|
-
const { hasAttribute: nativeHasAttribute, setAttribute: nativeSetAttribute, removeAttribute: nativeRemoveAttribute, getAttribute: nativeGetAttribute, } = NativeHTMLElement.prototype;
|
|
7939
|
-
const definitionForElement = new WeakMap();
|
|
7940
|
-
const pendingRegistryForElement = new WeakMap();
|
|
7941
|
-
const definitionForConstructor = new WeakMap();
|
|
7942
|
-
const registeredUserCtors = new WeakSet();
|
|
7943
|
-
const registeredPivotCtors = new WeakSet();
|
|
7944
|
-
const pivotCtorByTag = new Map();
|
|
7945
|
-
const globalDefinitionsByTag = new Map();
|
|
7946
|
-
const globalDefinitionsByClass = new Map();
|
|
7947
|
-
const awaitingUpgrade = new Map();
|
|
7948
|
-
const pendingWhenDefinedCallbacks = new Map();
|
|
7949
|
-
const EMPTY_SET = new Set();
|
|
7950
|
-
function createDefinitionRecord(constructor) {
|
|
7951
|
-
var _a;
|
|
7952
|
-
const { connectedCallback, disconnectedCallback, formAssociatedCallback, formDisabledCallback, formResetCallback, formStateRestoreCallback, adoptedCallback, attributeChangedCallback, } = constructor.prototype;
|
|
7953
|
-
const formAssociated = Boolean(constructor.formAssociated);
|
|
7954
|
-
const observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
|
|
7955
|
-
return {
|
|
7956
|
-
UserCtor: constructor,
|
|
7957
|
-
PivotCtor: undefined,
|
|
7958
|
-
connectedCallback,
|
|
7959
|
-
disconnectedCallback,
|
|
7960
|
-
formAssociatedCallback,
|
|
7961
|
-
formDisabledCallback,
|
|
7962
|
-
formResetCallback,
|
|
7963
|
-
formStateRestoreCallback,
|
|
7964
|
-
adoptedCallback,
|
|
7965
|
-
attributeChangedCallback,
|
|
7966
|
-
observedAttributes,
|
|
7967
|
-
formAssociated,
|
|
7968
|
-
};
|
|
7969
|
-
}
|
|
7970
|
-
// Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
|
|
7971
|
-
// element. Note that the `registeredDefinition` represents the constructor that was used to register during
|
|
7972
|
-
// `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
|
|
7973
|
-
// constructor is invoked with another constructor.
|
|
7974
|
-
function createPivotingClass(tagName, registeredDefinition) {
|
|
7975
|
-
class PivotCtor extends NativeHTMLElement {
|
|
7976
|
-
constructor(UserCtor) {
|
|
7977
|
-
// This constructor can only be invoked by:
|
|
7978
|
-
// a) the browser instantiating an element from parsing or via document.createElement.
|
|
7979
|
-
// b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
|
|
7980
|
-
// b) new UserClass.
|
|
7981
|
-
// When LWC instantiates it, it will pass the upgrading definition as an argument
|
|
7982
|
-
// If the caller signals via UserCtor that this is in fact a controlled
|
|
7983
|
-
// definition, we use that one, otherwise fallback to the global
|
|
7984
|
-
// internal registry.
|
|
7985
|
-
super();
|
|
7986
|
-
const userCtorIsDefined = !isUndefined$1(UserCtor);
|
|
7987
|
-
if (userCtorIsDefined) {
|
|
7988
|
-
if (!isConstructor(UserCtor)) {
|
|
7989
|
-
throw new TypeError(`Failed to create custom element: the provided constructor is not a constructor.`);
|
|
7990
|
-
}
|
|
7991
|
-
if (!registeredUserCtors.has(UserCtor)) {
|
|
7992
|
-
throw new Error(`Failed to create custom element: the provided constructor is unregistered: ${UserCtor.name}.`);
|
|
7993
|
-
}
|
|
7994
|
-
}
|
|
7995
|
-
const definition = userCtorIsDefined
|
|
7996
|
-
? getOrCreateDefinitionForConstructor(UserCtor)
|
|
7997
|
-
: globalDefinitionsByTag.get(tagName);
|
|
7998
|
-
if (!isUndefined$1(definition)) {
|
|
7999
|
-
internalUpgrade(this, registeredDefinition, definition);
|
|
8000
|
-
}
|
|
8001
|
-
else {
|
|
8002
|
-
// This is the case in which there is no global definition, and
|
|
8003
|
-
// it is not handled by LWC (otherwise it will have a valid UserCtor)
|
|
8004
|
-
// so we need to add it to the pending queue just in case it eventually
|
|
8005
|
-
// gets defined in the global registry.
|
|
8006
|
-
pendingRegistryForElement.set(this, registeredDefinition);
|
|
8007
|
-
}
|
|
8008
|
-
}
|
|
8009
|
-
connectedCallback() {
|
|
8010
|
-
var _a;
|
|
8011
|
-
const definition = definitionForElement.get(this);
|
|
8012
|
-
if (!isUndefined$1(definition)) {
|
|
8013
|
-
// Delegate out to user callback
|
|
8014
|
-
(_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
8015
|
-
}
|
|
8016
|
-
else {
|
|
8017
|
-
// Register for upgrade when defined (only when connected, so we don't leak)
|
|
8018
|
-
let awaiting = awaitingUpgrade.get(tagName);
|
|
8019
|
-
if (isUndefined$1(awaiting)) {
|
|
8020
|
-
awaitingUpgrade.set(tagName, (awaiting = new Set()));
|
|
8021
|
-
}
|
|
8022
|
-
awaiting.add(this);
|
|
8023
|
-
}
|
|
8024
|
-
}
|
|
8025
|
-
disconnectedCallback() {
|
|
8026
|
-
var _a;
|
|
8027
|
-
const definition = definitionForElement.get(this);
|
|
8028
|
-
if (!isUndefined$1(definition)) {
|
|
8029
|
-
// Delegate out to user callback
|
|
8030
|
-
(_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
8031
|
-
}
|
|
8032
|
-
else {
|
|
8033
|
-
// Un-register for upgrade when defined (so we don't leak)
|
|
8034
|
-
const awaiting = awaitingUpgrade.get(tagName);
|
|
8035
|
-
// At this point, awaiting should never be undefined, because connectedCallback
|
|
8036
|
-
// must have been called before disconnectedCallback. But just to be safe, we check
|
|
8037
|
-
if (!isUndefined$1(awaiting)) {
|
|
8038
|
-
awaiting.delete(this);
|
|
8039
|
-
}
|
|
8040
|
-
}
|
|
8041
|
-
}
|
|
8042
|
-
formAssociatedCallback(form) {
|
|
8043
|
-
var _a;
|
|
8044
|
-
const definition = definitionForElement.get(this);
|
|
8045
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formAssociatedCallback) === null || _a === void 0 ? void 0 : _a.call(this, form);
|
|
8046
|
-
}
|
|
8047
|
-
formDisabledCallback(disabled) {
|
|
8048
|
-
var _a;
|
|
8049
|
-
const definition = definitionForElement.get(this);
|
|
8050
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formDisabledCallback) === null || _a === void 0 ? void 0 : _a.call(this, disabled);
|
|
8051
|
-
}
|
|
8052
|
-
formResetCallback() {
|
|
8053
|
-
var _a;
|
|
8054
|
-
const definition = definitionForElement.get(this);
|
|
8055
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formResetCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
8056
|
-
}
|
|
8057
|
-
formStateRestoreCallback(state, mode) {
|
|
8058
|
-
var _a;
|
|
8059
|
-
const definition = definitionForElement.get(this);
|
|
8060
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formStateRestoreCallback) === null || _a === void 0 ? void 0 : _a.call(this, state, mode);
|
|
8061
|
-
}
|
|
8062
|
-
adoptedCallback() {
|
|
8063
|
-
var _a;
|
|
8064
|
-
const definition = definitionForElement.get(this);
|
|
8065
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
8066
|
-
}
|
|
8067
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
8068
|
-
var _a;
|
|
8069
|
-
const definition = definitionForElement.get(this);
|
|
8070
|
-
// if both definitions are the same, then the observedAttributes is the same,
|
|
8071
|
-
// but if they are different, only if the runtime definition has the attribute
|
|
8072
|
-
// marked as observed, then it should invoke attributeChangedCallback.
|
|
8073
|
-
if (registeredDefinition === definition ||
|
|
8074
|
-
(definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
|
|
8075
|
-
(_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
|
|
8076
|
-
}
|
|
8077
|
-
}
|
|
8078
|
-
}
|
|
8079
|
-
PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
|
|
8080
|
-
// TODO [#3000]: support case where registeredDefinition is not form-associated, but later definition is.
|
|
8081
|
-
PivotCtor.formAssociated = registeredDefinition.formAssociated;
|
|
8082
|
-
registeredPivotCtors.add(PivotCtor);
|
|
8083
|
-
return PivotCtor;
|
|
8084
|
-
}
|
|
8085
|
-
function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
|
|
8086
|
-
const { observedAttributes, attributeChangedCallback } = pivotDefinition;
|
|
8087
|
-
if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
|
|
8088
|
-
// This instance does not need to observe any attributes, no need to patch
|
|
8089
|
-
return EMPTY_SET;
|
|
8090
|
-
}
|
|
8091
|
-
// Natively, the attributes observed by the registered definition are going to be taken
|
|
8092
|
-
// care of by the browser, only the difference between the two sets has to be taken
|
|
8093
|
-
// care by the patched version.
|
|
8094
|
-
return new Set([...pivotDefinition.observedAttributes].filter((x) => !registeredDefinition.observedAttributes.has(x)));
|
|
8095
|
-
}
|
|
8096
|
-
function throwAsyncError(error) {
|
|
8097
|
-
// Per native custom element behavior, errors thrown in attributeChangedCallback
|
|
8098
|
-
// become unhandled async errors. We use setTimeout() instead of Promise.resolve()
|
|
8099
|
-
// to make it an unhandled error rather than an unhandled rejection.
|
|
8100
|
-
setTimeout(() => {
|
|
8101
|
-
throw error;
|
|
8102
|
-
});
|
|
8103
|
-
}
|
|
8104
|
-
// Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
|
|
8105
|
-
// Why is this necessary? Well basically, you can't change the `observedAttributes` after
|
|
8106
|
-
// a custom element is defined. So with pivots, if two classes share the same tag name,
|
|
8107
|
-
// and the second class observes attributes that aren't observed by the first one,
|
|
8108
|
-
// then those attributes can never be observed by the native `observedAttributes` system.
|
|
8109
|
-
// So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
|
|
8110
|
-
// we only do this when absolutely necessary, though; i.e. because we've determined
|
|
8111
|
-
// that we aren't observing the attributes we need to.
|
|
8112
|
-
function patchAttributes(instance, registeredDefinition, pivotDefinition) {
|
|
8113
|
-
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
8114
|
-
if (newObservedAttributes.size === 0) {
|
|
8115
|
-
return;
|
|
8116
|
-
}
|
|
8117
|
-
const { attributeChangedCallback } = pivotDefinition;
|
|
8118
|
-
// Patch the instance.
|
|
8119
|
-
// Note we use the native `getAttribute` rather than the super's `getAttribute` because
|
|
8120
|
-
// we don't actually want it to be observable that we're calling `getAttribute` from
|
|
8121
|
-
// `setAttribute` and `removeAttribute`.
|
|
8122
|
-
// TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
|
|
8123
|
-
defineProperties(instance, {
|
|
8124
|
-
setAttribute: {
|
|
8125
|
-
value: function setAttribute(name, value) {
|
|
8126
|
-
if (newObservedAttributes.has(name)) {
|
|
8127
|
-
const old = nativeGetAttribute.call(this, name);
|
|
8128
|
-
nativeSetAttribute.call(this, name, value);
|
|
8129
|
-
try {
|
|
8130
|
-
attributeChangedCallback.call(this, name, old, value + '');
|
|
8131
|
-
}
|
|
8132
|
-
catch (error) {
|
|
8133
|
-
throwAsyncError(error);
|
|
8134
|
-
}
|
|
8135
|
-
}
|
|
8136
|
-
else {
|
|
8137
|
-
nativeSetAttribute.call(this, name, value);
|
|
8138
|
-
}
|
|
8139
|
-
},
|
|
8140
|
-
writable: true,
|
|
8141
|
-
enumerable: true,
|
|
8142
|
-
configurable: true,
|
|
8143
|
-
},
|
|
8144
|
-
removeAttribute: {
|
|
8145
|
-
value: function removeAttribute(name) {
|
|
8146
|
-
if (newObservedAttributes.has(name)) {
|
|
8147
|
-
const old = nativeGetAttribute.call(this, name);
|
|
8148
|
-
nativeRemoveAttribute.call(this, name);
|
|
8149
|
-
try {
|
|
8150
|
-
attributeChangedCallback.call(this, name, old, null);
|
|
8151
|
-
}
|
|
8152
|
-
catch (error) {
|
|
8153
|
-
throwAsyncError(error);
|
|
8154
|
-
}
|
|
8155
|
-
}
|
|
8156
|
-
else {
|
|
8157
|
-
nativeRemoveAttribute.call(this, name);
|
|
8158
|
-
}
|
|
8159
|
-
},
|
|
8160
|
-
writable: true,
|
|
8161
|
-
enumerable: true,
|
|
8162
|
-
configurable: true,
|
|
8163
|
-
},
|
|
8164
|
-
});
|
|
8165
|
-
}
|
|
8166
|
-
function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
8167
|
-
// The below case patches observed attributes for the case where the HTML element is upgraded
|
|
8168
|
-
// from a pre-existing one in the DOM.
|
|
8169
|
-
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
8170
|
-
if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
|
|
8171
|
-
return;
|
|
8172
|
-
}
|
|
8173
|
-
const { attributeChangedCallback } = pivotDefinition;
|
|
8174
|
-
// Approximate observedAttributes from the user class, but only for the new observed attributes
|
|
8175
|
-
newObservedAttributes.forEach((name) => {
|
|
8176
|
-
if (nativeHasAttribute.call(instance, name)) {
|
|
8177
|
-
const newValue = nativeGetAttribute.call(instance, name);
|
|
8178
|
-
attributeChangedCallback.call(instance, name, null, newValue);
|
|
8179
|
-
}
|
|
8180
|
-
});
|
|
8181
|
-
}
|
|
8182
|
-
// User extends this HTMLElement, which returns the CE being upgraded
|
|
8183
|
-
let upgradingInstance;
|
|
8184
|
-
// Helper to upgrade an instance with a CE definition using "constructor call trick"
|
|
8185
|
-
function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
8186
|
-
setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
|
|
8187
|
-
definitionForElement.set(instance, pivotDefinition);
|
|
8188
|
-
// attributes patches when needed
|
|
8189
|
-
if (pivotDefinition !== registeredDefinition) {
|
|
8190
|
-
patchAttributes(instance, registeredDefinition, pivotDefinition);
|
|
8191
|
-
}
|
|
8192
|
-
// Tricking the construction path to believe that a new instance is being created,
|
|
8193
|
-
// that way it will execute the super initialization mechanism but the HTMLElement
|
|
8194
|
-
// constructor will reuse the instance by returning the upgradingInstance.
|
|
8195
|
-
// This is by far the most important piece of the puzzle
|
|
8196
|
-
upgradingInstance = instance;
|
|
8197
|
-
// By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
|
|
8198
|
-
// The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
|
|
8199
|
-
// Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
|
|
8200
|
-
new pivotDefinition.UserCtor();
|
|
8201
|
-
patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
|
|
8202
|
-
}
|
|
8203
|
-
function isConstructor(constructor) {
|
|
8204
|
-
return isFunction$1(constructor) && isObject(constructor.prototype);
|
|
8205
|
-
}
|
|
8206
|
-
function getOrCreateDefinitionForConstructor(constructor) {
|
|
8207
|
-
if (!isConstructor(constructor)) {
|
|
8208
|
-
throw new TypeError('The referenced constructor is not a constructor.');
|
|
8209
|
-
}
|
|
8210
|
-
const definition = definitionForConstructor.get(constructor);
|
|
8211
|
-
if (!isUndefined$1(definition)) {
|
|
8212
|
-
return definition;
|
|
8213
|
-
}
|
|
8214
|
-
return createDefinitionRecord(constructor);
|
|
8215
|
-
}
|
|
8216
|
-
// Defer a `whenDefined()` callback until an externally-visible custom element is defined
|
|
8217
|
-
function createPendingWhenDefinedCallback(tagName) {
|
|
8218
|
-
return new Promise((resolve) => {
|
|
8219
|
-
let resolvers = pendingWhenDefinedCallbacks.get(tagName);
|
|
8220
|
-
if (isUndefined$1(resolvers)) {
|
|
8221
|
-
resolvers = [];
|
|
8222
|
-
pendingWhenDefinedCallbacks.set(tagName, resolvers);
|
|
8223
|
-
}
|
|
8224
|
-
resolvers.push(resolve);
|
|
8225
|
-
});
|
|
8226
|
-
}
|
|
8227
|
-
// Call any pending `whenDefined()` callbacks
|
|
8228
|
-
function flushPendingWhenDefinedCallbacks(tagName, ctor) {
|
|
8229
|
-
const resolvers = pendingWhenDefinedCallbacks.get(tagName);
|
|
8230
|
-
if (!isUndefined$1(resolvers)) {
|
|
8231
|
-
for (const resolver of resolvers) {
|
|
8232
|
-
resolver(ctor);
|
|
8233
|
-
}
|
|
8234
|
-
}
|
|
8235
|
-
pendingWhenDefinedCallbacks.delete(tagName);
|
|
8236
|
-
}
|
|
8237
|
-
const { customElements: nativeRegistry } = window;
|
|
8238
|
-
const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
|
|
8239
|
-
// patch for the global registry define mechanism
|
|
8240
|
-
CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
|
|
8241
|
-
if (options && options.extends) {
|
|
8242
|
-
// TODO [#2983]: should we support `extends`?
|
|
8243
|
-
throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
|
|
8244
|
-
}
|
|
8245
|
-
if (globalDefinitionsByTag.has(tagName)) {
|
|
8246
|
-
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`);
|
|
8247
|
-
}
|
|
8248
|
-
if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
|
|
8249
|
-
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`);
|
|
8250
|
-
}
|
|
8251
|
-
const definition = getOrCreateDefinitionForConstructor(constructor);
|
|
8252
|
-
registeredUserCtors.add(constructor);
|
|
8253
|
-
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
8254
|
-
if (isUndefined$1(PivotCtor)) {
|
|
8255
|
-
PivotCtor = createPivotingClass(tagName, definition);
|
|
8256
|
-
// Register a pivoting class which will handle global registry initializations
|
|
8257
|
-
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
8258
|
-
}
|
|
8259
|
-
// Only cache after nativeDefine has been called, because if it throws an error
|
|
8260
|
-
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
8261
|
-
definitionForConstructor.set(constructor, definition);
|
|
8262
|
-
pivotCtorByTag.set(tagName, PivotCtor);
|
|
8263
|
-
globalDefinitionsByTag.set(tagName, definition);
|
|
8264
|
-
globalDefinitionsByClass.set(constructor, definition);
|
|
8265
|
-
// For globally defined custom elements, the definition associated
|
|
8266
|
-
// to the UserCtor has a back-pointer to PivotCtor in case the user
|
|
8267
|
-
// new the UserCtor, so we know how to create the underlying element.
|
|
8268
|
-
definition.PivotCtor = PivotCtor;
|
|
8269
|
-
// Upgrade any elements created in this scope before customElements.define
|
|
8270
|
-
// was called, which should be exhibited by the following steps:
|
|
8271
|
-
// 1) LWC registers a tagName for an LWC component.
|
|
8272
|
-
// 2) Element with same tagName is created with document.createElement()
|
|
8273
|
-
// and inserted into DOM.
|
|
8274
|
-
// 3) customElements.define() is called with tagName and non-LWC constructor.
|
|
8275
|
-
// This requires immediate upgrade when the new global tagName is defined.
|
|
8276
|
-
const awaiting = awaitingUpgrade.get(tagName);
|
|
8277
|
-
if (!isUndefined$1(awaiting)) {
|
|
8278
|
-
awaitingUpgrade.delete(tagName);
|
|
8279
|
-
for (const element of awaiting) {
|
|
8280
|
-
const registeredDefinition = pendingRegistryForElement.get(element);
|
|
8281
|
-
// At this point, registeredDefinition should never be undefined because awaitingUpgrade
|
|
8282
|
-
// is only populated when we haven't run internalUpgrade yet, and we only populate
|
|
8283
|
-
// pendingRegistryForElement when internalUpgrade hasn't run yet.
|
|
8284
|
-
// But just to be safe, we check.
|
|
8285
|
-
if (!isUndefined$1(registeredDefinition)) {
|
|
8286
|
-
pendingRegistryForElement.delete(element);
|
|
8287
|
-
internalUpgrade(element, registeredDefinition, definition);
|
|
8288
|
-
}
|
|
8289
|
-
}
|
|
8290
|
-
}
|
|
8291
|
-
// If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
|
|
8292
|
-
flushPendingWhenDefinedCallbacks(tagName, constructor);
|
|
8293
|
-
};
|
|
8294
|
-
CustomElementRegistry.prototype.get = function get(tagName) {
|
|
8295
|
-
const NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
8296
|
-
if (!isUndefined$1(NativeCtor)) {
|
|
8297
|
-
const definition = globalDefinitionsByTag.get(tagName);
|
|
8298
|
-
if (!isUndefined$1(definition)) {
|
|
8299
|
-
return definition.UserCtor; // defined by the patched custom elements registry
|
|
8300
|
-
}
|
|
8301
|
-
if (registeredPivotCtors.has(NativeCtor)) {
|
|
8302
|
-
return undefined; // pivot constructors should not be observable, return undefined
|
|
8303
|
-
}
|
|
8304
|
-
return NativeCtor; // constructor that existed before patching
|
|
8305
|
-
}
|
|
8306
|
-
};
|
|
8307
|
-
CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
|
|
8308
|
-
return nativeWhenDefined.call(nativeRegistry, tagName).then((NativeCtor) => {
|
|
8309
|
-
const definition = globalDefinitionsByTag.get(tagName);
|
|
8310
|
-
if (!isUndefined$1(definition)) {
|
|
8311
|
-
return definition.UserCtor;
|
|
8312
|
-
}
|
|
8313
|
-
// In this case, the custom element must have been defined before the registry patches
|
|
8314
|
-
// were applied. So return the non-pivot constructor
|
|
8315
|
-
if (isUndefined$1(NativeCtor)) {
|
|
8316
|
-
// Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
|
|
8317
|
-
// We can patch the correct behavior using customElements.get()
|
|
8318
|
-
NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
8319
|
-
}
|
|
8320
|
-
if (registeredPivotCtors.has(NativeCtor)) {
|
|
8321
|
-
// Pivot constructors should not be observable. Wait to resolve the promise
|
|
8322
|
-
// if a constructor is ever defined in userland
|
|
8323
|
-
return createPendingWhenDefinedCallback(tagName);
|
|
8324
|
-
}
|
|
8325
|
-
return NativeCtor;
|
|
8326
|
-
});
|
|
8327
|
-
};
|
|
8328
|
-
// This constructor is invoked when we call `new pivotDefinition.UserCtor()`
|
|
8329
|
-
// @ts-ignore
|
|
8330
|
-
window.HTMLElement = function HTMLElement() {
|
|
8331
|
-
// Upgrading case: the pivoting class constructor was run by the browser's
|
|
8332
|
-
// native custom elements and we're in the process of running the
|
|
8333
|
-
// "constructor-call trick" on the natively constructed instance, so just
|
|
8334
|
-
// return that here.
|
|
8335
|
-
// This code path is also called when LWC `new`s a PivotCtor.
|
|
8336
|
-
const instance = upgradingInstance;
|
|
8337
|
-
if (!isUndefined$1(instance)) {
|
|
8338
|
-
upgradingInstance = undefined;
|
|
8339
|
-
return instance;
|
|
8340
|
-
}
|
|
8341
|
-
// Construction case: we need to construct the pivoting instance and return it.
|
|
8342
|
-
// This is possible when the user register it via global registry and instantiate
|
|
8343
|
-
// it via `new Ctor()`.
|
|
8344
|
-
const { constructor } = this;
|
|
8345
|
-
const definition = globalDefinitionsByClass.get(constructor);
|
|
8346
|
-
if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
|
|
8347
|
-
// This code path is hit if someone `new`s a class that extends `HTMLElement` without
|
|
8348
|
-
// doing `customElements.define()` first. This matches native browser behavior:
|
|
8349
|
-
// https://stackoverflow.com/a/61883392
|
|
8350
|
-
throw new TypeError('Illegal constructor');
|
|
8351
|
-
}
|
|
8352
|
-
// This constructor is ONLY invoked when it is the user instantiating
|
|
8353
|
-
// an element via new Ctor while Ctor is a registered global constructor.
|
|
8354
|
-
const { PivotCtor, UserCtor } = definition;
|
|
8355
|
-
return new PivotCtor(UserCtor);
|
|
8356
|
-
};
|
|
8357
|
-
HTMLElement.prototype = NativeHTMLElement.prototype;
|
|
8358
|
-
/**
|
|
8359
|
-
* Create a new PivotConstructor for the given tagName, which is capable of being constructed
|
|
8360
|
-
* with a UserConstructor defining the behavior. Passing in the UserConstructor here
|
|
8361
|
-
* is a hint that can be used when registering a custom element with the global custom elements
|
|
8362
|
-
* registry for the first time, which provides certain optimizations. It also marks the UserConstructor
|
|
8363
|
-
* as "safe" to be used when passed in to a PivotConstructor.
|
|
8364
|
-
*
|
|
8365
|
-
* @param tagName - element tag name
|
|
8366
|
-
* @param UserCtor - userland custom element constructor
|
|
8367
|
-
* @returns a new custom element constructor
|
|
8368
|
-
*/
|
|
8369
|
-
return function createPivotConstructor(tagName, UserCtor) {
|
|
8370
|
-
tagName = StringToLowerCase.call(tagName);
|
|
8371
|
-
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
8372
|
-
if (isUndefined$1(PivotCtor)) {
|
|
8373
|
-
const definition = getOrCreateDefinitionForConstructor(UserCtor);
|
|
8374
|
-
PivotCtor = createPivotingClass(tagName, definition);
|
|
8375
|
-
// Register a pivoting class as a global custom element
|
|
8376
|
-
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
8377
|
-
definition.PivotCtor = PivotCtor;
|
|
8378
|
-
// Only cache after nativeDefine has been called, because if it throws an error
|
|
8379
|
-
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
8380
|
-
definitionForConstructor.set(UserCtor, definition);
|
|
8381
|
-
pivotCtorByTag.set(tagName, PivotCtor);
|
|
8382
|
-
}
|
|
8383
|
-
// Register a UserConstructor as "safe" to be used within a PivotConstructor
|
|
8384
|
-
registeredUserCtors.add(UserCtor);
|
|
8385
|
-
return PivotCtor;
|
|
8386
|
-
};
|
|
8387
|
-
}
|
|
8388
|
-
|
|
8389
|
-
/*
|
|
8390
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
8391
|
-
* All rights reserved.
|
|
8392
|
-
* SPDX-License-Identifier: MIT
|
|
8393
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8394
|
-
*/
|
|
8395
|
-
let createScopedConstructor;
|
|
8396
|
-
let CachedHTMLElement;
|
|
8397
|
-
// We only call `createScopedRegistry()` if the browser supports custom elements and
|
|
8398
|
-
// ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
|
|
8399
|
-
// or we're in a legacy browser.
|
|
8400
|
-
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
8401
|
-
if (hasCustomElements) {
|
|
8402
|
-
// If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
|
|
8403
|
-
// It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
|
|
8404
|
-
//
|
|
8405
|
-
// Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
|
|
8406
|
-
//
|
|
8407
|
-
// 1. LWC loads
|
|
8408
|
-
// 2. `const Ctor = class extends HTMLElement {}`
|
|
8409
|
-
// 3. `lwc.createElement(...)` // here we lazily patch
|
|
8410
|
-
// 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
|
|
8411
|
-
//
|
|
8412
|
-
// To reduce the risk of this, it's safer to patch the registry eagerly.
|
|
8413
|
-
createScopedConstructor = createScopedRegistry();
|
|
8414
|
-
// It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
|
|
8415
|
-
// another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
|
|
8416
|
-
// because the HTMLElement prototypes are mixed up.
|
|
8417
|
-
//
|
|
8418
|
-
// The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
|
|
8419
|
-
// with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
|
|
8420
|
-
// the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
|
|
8421
|
-
// Caching avoids this problem.
|
|
8422
|
-
CachedHTMLElement = window.HTMLElement;
|
|
8423
|
-
}
|
|
8424
|
-
}
|
|
8425
|
-
// Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
|
|
8426
|
-
// In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
|
|
8427
|
-
// multiple times per tag name.
|
|
8428
|
-
const createUserConstructor = (HTMLElementToExtend, upgradeCallback, connectedCallback, disconnectedCallback) => {
|
|
8429
|
-
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
8430
|
-
return class UserConstructor extends HTMLElementToExtend {
|
|
8431
|
-
constructor() {
|
|
8432
|
-
super();
|
|
8433
|
-
upgradeCallback(this);
|
|
8434
|
-
}
|
|
8435
|
-
// Note that there is no need to do the "avoid defining connectedCallback/disconnectedCallback" optimization
|
|
8436
|
-
// here, because in create-scoped-registry.ts, the registered class will always have these callbacks anyway.
|
|
8437
|
-
// See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
|
|
8438
|
-
connectedCallback() {
|
|
8439
|
-
if (!isUndefined$1(connectedCallback)) {
|
|
8440
|
-
connectedCallback(this);
|
|
8441
|
-
}
|
|
8442
|
-
}
|
|
8443
|
-
disconnectedCallback() {
|
|
8444
|
-
if (!isUndefined$1(disconnectedCallback)) {
|
|
8445
|
-
disconnectedCallback(this);
|
|
8446
|
-
}
|
|
8447
|
-
}
|
|
8448
|
-
};
|
|
8449
|
-
};
|
|
8450
|
-
function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
8451
|
-
if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
|
|
8452
|
-
// This error should be impossible to hit
|
|
8453
|
-
throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
|
|
8454
|
-
}
|
|
8455
|
-
const UserConstructor = createUserConstructor(CachedHTMLElement, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
8456
|
-
const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
|
|
8457
|
-
return new ScopedConstructor(UserConstructor);
|
|
8458
|
-
}
|
|
8459
|
-
|
|
8460
7917
|
/*
|
|
8461
7918
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
8462
7919
|
* All rights reserved.
|
|
@@ -8464,29 +7921,22 @@ function createCustomElementScoped(tagName, upgradeCallback, connectedCallback,
|
|
|
8464
7921
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8465
7922
|
*/
|
|
8466
7923
|
/**
|
|
8467
|
-
* We have
|
|
7924
|
+
* We have two modes for creating custom elements:
|
|
8468
7925
|
*
|
|
8469
7926
|
* 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
|
|
8470
7927
|
* 2. "Upgradable constructor" custom element. This allows us to have two LWC components with the same tag name,
|
|
8471
7928
|
* via a trick: every custom element constructor we define in the registry is basically the same. It's essentially
|
|
8472
7929
|
* a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its constructor ("upgradable
|
|
8473
7930
|
* constructor"), which allows us to have completely customized functionality for different components.
|
|
8474
|
-
* 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
|
|
8475
|
-
* elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
|
|
8476
|
-
* between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
|
|
8477
|
-
* because it must patch the global `customElements` and `HTMLElement` objects.
|
|
8478
7931
|
*/
|
|
8479
7932
|
let createCustomElement;
|
|
8480
7933
|
if (hasCustomElements) {
|
|
8481
|
-
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
8482
|
-
createCustomElement = createCustomElementScoped;
|
|
8483
|
-
} else {
|
|
8484
7934
|
// use the global registry, with an upgradable constructor for the defined custom element
|
|
8485
7935
|
createCustomElement = createCustomElementUsingUpgradableConstructor;
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
7936
|
+
}
|
|
7937
|
+
else {
|
|
7938
|
+
// no registry available here
|
|
7939
|
+
createCustomElement = createCustomElementCompat;
|
|
8490
7940
|
}
|
|
8491
7941
|
|
|
8492
7942
|
/*
|
|
@@ -8549,7 +7999,7 @@ function rendererFactory(baseRenderer) {
|
|
|
8549
7999
|
function isNull(obj) {
|
|
8550
8000
|
return obj === null;
|
|
8551
8001
|
}
|
|
8552
|
-
/** version: 2.
|
|
8002
|
+
/** version: 2.37.0 */
|
|
8553
8003
|
|
|
8554
8004
|
/*
|
|
8555
8005
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -9110,6 +8560,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
9110
8560
|
});
|
|
9111
8561
|
freeze(LightningElement);
|
|
9112
8562
|
seal(LightningElement.prototype);
|
|
9113
|
-
/* version: 2.
|
|
8563
|
+
/* version: 2.37.0 */
|
|
9114
8564
|
|
|
9115
8565
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|