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