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
@@ -324,7 +324,7 @@
324
324
  CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
325
325
  return propertyName;
326
326
  }
327
- /** version: 2.36.0 */
327
+ /** version: 2.37.0 */
328
328
 
329
329
  /**
330
330
  * Copyright (C) 2018 salesforce.com, inc.
@@ -344,10 +344,8 @@
344
344
  ENABLE_WIRE_SYNC_EMIT: null,
345
345
  ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
346
346
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
347
- ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
348
347
  ENABLE_FROZEN_TEMPLATE: null,
349
348
  DISABLE_ARIA_REFLECTION_POLYFILL: null,
350
- ENABLE_PROGRAMMATIC_STYLESHEETS: null,
351
349
  };
352
350
  if (!_globalThis.lwcRuntimeFlags) {
353
351
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
@@ -392,7 +390,7 @@
392
390
  */
393
391
  function setFeatureFlagForTest(name, value) {
394
392
  }
395
- /** version: 2.36.0 */
393
+ /** version: 2.37.0 */
396
394
 
397
395
  /**
398
396
  * Copyright (C) 2018 salesforce.com, inc.
@@ -456,7 +454,7 @@
456
454
  }
457
455
  }
458
456
  }
459
- /** version: 2.36.0 */
457
+ /** version: 2.37.0 */
460
458
 
461
459
  /*
462
460
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4839,15 +4837,13 @@
4839
4837
  }
4840
4838
  // Validate and flatten any stylesheets defined as `static stylesheets`
4841
4839
  function computeStylesheets(vm, ctor) {
4842
- if (lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
4843
- const {
4844
- stylesheets
4845
- } = ctor;
4846
- if (!isUndefined$1(stylesheets)) {
4847
- const valid = validateComponentStylesheets(vm, stylesheets);
4848
- if (valid) {
4849
- return flattenStylesheets(stylesheets);
4850
- }
4840
+ const {
4841
+ stylesheets
4842
+ } = ctor;
4843
+ if (!isUndefined$1(stylesheets)) {
4844
+ const valid = validateComponentStylesheets(vm, stylesheets);
4845
+ if (valid) {
4846
+ return flattenStylesheets(stylesheets);
4851
4847
  }
4852
4848
  }
4853
4849
  return null;
@@ -5188,7 +5184,7 @@
5188
5184
  // The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
5189
5185
  // These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
5190
5186
  // When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
5191
- // See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
5187
+ // See: https://sfdc.co/synthetic-aria
5192
5188
  //
5193
5189
  // Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
5194
5190
  const getElementById = _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
@@ -6272,545 +6268,6 @@
6272
6268
  }
6273
6269
  };
6274
6270
 
6275
- /*
6276
- * Copyright (c) 2020, salesforce.com, inc.
6277
- * All rights reserved.
6278
- * SPDX-License-Identifier: MIT
6279
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6280
- */
6281
- /**
6282
- * Create a scoped registry, i.e. a function that can create custom elements whose tag names
6283
- * do not conflict with third-party custom elements having the same tag name.
6284
- */
6285
- function createScopedRegistry() {
6286
- if (!hasCustomElements) {
6287
- // This code should never be reached, because we don't use the pivot registry if
6288
- // custom elements are unavailable.
6289
- throw new Error('Custom elements are not supported in this environment.');
6290
- }
6291
- const { HTMLElement: NativeHTMLElement } = window;
6292
- const { hasAttribute: nativeHasAttribute, setAttribute: nativeSetAttribute, removeAttribute: nativeRemoveAttribute, getAttribute: nativeGetAttribute, } = NativeHTMLElement.prototype;
6293
- const definitionForElement = new WeakMap();
6294
- const pendingRegistryForElement = new WeakMap();
6295
- const definitionForConstructor = new WeakMap();
6296
- const registeredUserCtors = new WeakSet();
6297
- const registeredPivotCtors = new WeakSet();
6298
- const pivotCtorByTag = new Map();
6299
- const globalDefinitionsByTag = new Map();
6300
- const globalDefinitionsByClass = new Map();
6301
- const awaitingUpgrade = new Map();
6302
- const pendingWhenDefinedCallbacks = new Map();
6303
- const EMPTY_SET = new Set();
6304
- function createDefinitionRecord(constructor) {
6305
- var _a;
6306
- const { connectedCallback, disconnectedCallback, formAssociatedCallback, formDisabledCallback, formResetCallback, formStateRestoreCallback, adoptedCallback, attributeChangedCallback, } = constructor.prototype;
6307
- const formAssociated = Boolean(constructor.formAssociated);
6308
- const observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
6309
- return {
6310
- UserCtor: constructor,
6311
- PivotCtor: undefined,
6312
- connectedCallback,
6313
- disconnectedCallback,
6314
- formAssociatedCallback,
6315
- formDisabledCallback,
6316
- formResetCallback,
6317
- formStateRestoreCallback,
6318
- adoptedCallback,
6319
- attributeChangedCallback,
6320
- observedAttributes,
6321
- formAssociated,
6322
- };
6323
- }
6324
- // Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
6325
- // element. Note that the `registeredDefinition` represents the constructor that was used to register during
6326
- // `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
6327
- // constructor is invoked with another constructor.
6328
- function createPivotingClass(tagName, registeredDefinition) {
6329
- class PivotCtor extends NativeHTMLElement {
6330
- constructor(UserCtor) {
6331
- // This constructor can only be invoked by:
6332
- // a) the browser instantiating an element from parsing or via document.createElement.
6333
- // b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
6334
- // b) new UserClass.
6335
- // When LWC instantiates it, it will pass the upgrading definition as an argument
6336
- // If the caller signals via UserCtor that this is in fact a controlled
6337
- // definition, we use that one, otherwise fallback to the global
6338
- // internal registry.
6339
- super();
6340
- const userCtorIsDefined = !isUndefined$1(UserCtor);
6341
- if (userCtorIsDefined) {
6342
- if (!isConstructor(UserCtor)) {
6343
- throw new TypeError(`Failed to create custom element: the provided constructor is not a constructor.`);
6344
- }
6345
- if (!registeredUserCtors.has(UserCtor)) {
6346
- throw new Error(`Failed to create custom element: the provided constructor is unregistered: ${UserCtor.name}.`);
6347
- }
6348
- }
6349
- const definition = userCtorIsDefined
6350
- ? getOrCreateDefinitionForConstructor(UserCtor)
6351
- : globalDefinitionsByTag.get(tagName);
6352
- if (!isUndefined$1(definition)) {
6353
- internalUpgrade(this, registeredDefinition, definition);
6354
- }
6355
- else {
6356
- // This is the case in which there is no global definition, and
6357
- // it is not handled by LWC (otherwise it will have a valid UserCtor)
6358
- // so we need to add it to the pending queue just in case it eventually
6359
- // gets defined in the global registry.
6360
- pendingRegistryForElement.set(this, registeredDefinition);
6361
- }
6362
- }
6363
- connectedCallback() {
6364
- var _a;
6365
- const definition = definitionForElement.get(this);
6366
- if (!isUndefined$1(definition)) {
6367
- // Delegate out to user callback
6368
- (_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
6369
- }
6370
- else {
6371
- // Register for upgrade when defined (only when connected, so we don't leak)
6372
- let awaiting = awaitingUpgrade.get(tagName);
6373
- if (isUndefined$1(awaiting)) {
6374
- awaitingUpgrade.set(tagName, (awaiting = new Set()));
6375
- }
6376
- awaiting.add(this);
6377
- }
6378
- }
6379
- disconnectedCallback() {
6380
- var _a;
6381
- const definition = definitionForElement.get(this);
6382
- if (!isUndefined$1(definition)) {
6383
- // Delegate out to user callback
6384
- (_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
6385
- }
6386
- else {
6387
- // Un-register for upgrade when defined (so we don't leak)
6388
- const awaiting = awaitingUpgrade.get(tagName);
6389
- // At this point, awaiting should never be undefined, because connectedCallback
6390
- // must have been called before disconnectedCallback. But just to be safe, we check
6391
- if (!isUndefined$1(awaiting)) {
6392
- awaiting.delete(this);
6393
- }
6394
- }
6395
- }
6396
- formAssociatedCallback(form) {
6397
- var _a;
6398
- const definition = definitionForElement.get(this);
6399
- (_a = definition === null || definition === void 0 ? void 0 : definition.formAssociatedCallback) === null || _a === void 0 ? void 0 : _a.call(this, form);
6400
- }
6401
- formDisabledCallback(disabled) {
6402
- var _a;
6403
- const definition = definitionForElement.get(this);
6404
- (_a = definition === null || definition === void 0 ? void 0 : definition.formDisabledCallback) === null || _a === void 0 ? void 0 : _a.call(this, disabled);
6405
- }
6406
- formResetCallback() {
6407
- var _a;
6408
- const definition = definitionForElement.get(this);
6409
- (_a = definition === null || definition === void 0 ? void 0 : definition.formResetCallback) === null || _a === void 0 ? void 0 : _a.call(this);
6410
- }
6411
- formStateRestoreCallback(state, mode) {
6412
- var _a;
6413
- const definition = definitionForElement.get(this);
6414
- (_a = definition === null || definition === void 0 ? void 0 : definition.formStateRestoreCallback) === null || _a === void 0 ? void 0 : _a.call(this, state, mode);
6415
- }
6416
- adoptedCallback() {
6417
- var _a;
6418
- const definition = definitionForElement.get(this);
6419
- (_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
6420
- }
6421
- attributeChangedCallback(name, oldValue, newValue) {
6422
- var _a;
6423
- const definition = definitionForElement.get(this);
6424
- // if both definitions are the same, then the observedAttributes is the same,
6425
- // but if they are different, only if the runtime definition has the attribute
6426
- // marked as observed, then it should invoke attributeChangedCallback.
6427
- if (registeredDefinition === definition ||
6428
- (definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
6429
- (_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
6430
- }
6431
- }
6432
- }
6433
- PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
6434
- // TODO [#3000]: support case where registeredDefinition is not form-associated, but later definition is.
6435
- PivotCtor.formAssociated = registeredDefinition.formAssociated;
6436
- registeredPivotCtors.add(PivotCtor);
6437
- return PivotCtor;
6438
- }
6439
- function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
6440
- const { observedAttributes, attributeChangedCallback } = pivotDefinition;
6441
- if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
6442
- // This instance does not need to observe any attributes, no need to patch
6443
- return EMPTY_SET;
6444
- }
6445
- // Natively, the attributes observed by the registered definition are going to be taken
6446
- // care of by the browser, only the difference between the two sets has to be taken
6447
- // care by the patched version.
6448
- return new Set([...pivotDefinition.observedAttributes].filter((x) => !registeredDefinition.observedAttributes.has(x)));
6449
- }
6450
- function throwAsyncError(error) {
6451
- // Per native custom element behavior, errors thrown in attributeChangedCallback
6452
- // become unhandled async errors. We use setTimeout() instead of Promise.resolve()
6453
- // to make it an unhandled error rather than an unhandled rejection.
6454
- setTimeout(() => {
6455
- throw error;
6456
- });
6457
- }
6458
- // Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
6459
- // Why is this necessary? Well basically, you can't change the `observedAttributes` after
6460
- // a custom element is defined. So with pivots, if two classes share the same tag name,
6461
- // and the second class observes attributes that aren't observed by the first one,
6462
- // then those attributes can never be observed by the native `observedAttributes` system.
6463
- // So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
6464
- // we only do this when absolutely necessary, though; i.e. because we've determined
6465
- // that we aren't observing the attributes we need to.
6466
- function patchAttributes(instance, registeredDefinition, pivotDefinition) {
6467
- const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
6468
- if (newObservedAttributes.size === 0) {
6469
- return;
6470
- }
6471
- const { attributeChangedCallback } = pivotDefinition;
6472
- // Patch the instance.
6473
- // Note we use the native `getAttribute` rather than the super's `getAttribute` because
6474
- // we don't actually want it to be observable that we're calling `getAttribute` from
6475
- // `setAttribute` and `removeAttribute`.
6476
- // TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
6477
- defineProperties(instance, {
6478
- setAttribute: {
6479
- value: function setAttribute(name, value) {
6480
- if (newObservedAttributes.has(name)) {
6481
- const old = nativeGetAttribute.call(this, name);
6482
- nativeSetAttribute.call(this, name, value);
6483
- try {
6484
- attributeChangedCallback.call(this, name, old, value + '');
6485
- }
6486
- catch (error) {
6487
- throwAsyncError(error);
6488
- }
6489
- }
6490
- else {
6491
- nativeSetAttribute.call(this, name, value);
6492
- }
6493
- },
6494
- writable: true,
6495
- enumerable: true,
6496
- configurable: true,
6497
- },
6498
- removeAttribute: {
6499
- value: function removeAttribute(name) {
6500
- if (newObservedAttributes.has(name)) {
6501
- const old = nativeGetAttribute.call(this, name);
6502
- nativeRemoveAttribute.call(this, name);
6503
- try {
6504
- attributeChangedCallback.call(this, name, old, null);
6505
- }
6506
- catch (error) {
6507
- throwAsyncError(error);
6508
- }
6509
- }
6510
- else {
6511
- nativeRemoveAttribute.call(this, name);
6512
- }
6513
- },
6514
- writable: true,
6515
- enumerable: true,
6516
- configurable: true,
6517
- },
6518
- });
6519
- }
6520
- function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
6521
- // The below case patches observed attributes for the case where the HTML element is upgraded
6522
- // from a pre-existing one in the DOM.
6523
- const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
6524
- if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
6525
- return;
6526
- }
6527
- const { attributeChangedCallback } = pivotDefinition;
6528
- // Approximate observedAttributes from the user class, but only for the new observed attributes
6529
- newObservedAttributes.forEach((name) => {
6530
- if (nativeHasAttribute.call(instance, name)) {
6531
- const newValue = nativeGetAttribute.call(instance, name);
6532
- attributeChangedCallback.call(instance, name, null, newValue);
6533
- }
6534
- });
6535
- }
6536
- // User extends this HTMLElement, which returns the CE being upgraded
6537
- let upgradingInstance;
6538
- // Helper to upgrade an instance with a CE definition using "constructor call trick"
6539
- function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
6540
- setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
6541
- definitionForElement.set(instance, pivotDefinition);
6542
- // attributes patches when needed
6543
- if (pivotDefinition !== registeredDefinition) {
6544
- patchAttributes(instance, registeredDefinition, pivotDefinition);
6545
- }
6546
- // Tricking the construction path to believe that a new instance is being created,
6547
- // that way it will execute the super initialization mechanism but the HTMLElement
6548
- // constructor will reuse the instance by returning the upgradingInstance.
6549
- // This is by far the most important piece of the puzzle
6550
- upgradingInstance = instance;
6551
- // By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
6552
- // The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
6553
- // Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
6554
- new pivotDefinition.UserCtor();
6555
- patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
6556
- }
6557
- function isConstructor(constructor) {
6558
- return isFunction$1(constructor) && isObject(constructor.prototype);
6559
- }
6560
- function getOrCreateDefinitionForConstructor(constructor) {
6561
- if (!isConstructor(constructor)) {
6562
- throw new TypeError('The referenced constructor is not a constructor.');
6563
- }
6564
- const definition = definitionForConstructor.get(constructor);
6565
- if (!isUndefined$1(definition)) {
6566
- return definition;
6567
- }
6568
- return createDefinitionRecord(constructor);
6569
- }
6570
- // Defer a `whenDefined()` callback until an externally-visible custom element is defined
6571
- function createPendingWhenDefinedCallback(tagName) {
6572
- return new Promise((resolve) => {
6573
- let resolvers = pendingWhenDefinedCallbacks.get(tagName);
6574
- if (isUndefined$1(resolvers)) {
6575
- resolvers = [];
6576
- pendingWhenDefinedCallbacks.set(tagName, resolvers);
6577
- }
6578
- resolvers.push(resolve);
6579
- });
6580
- }
6581
- // Call any pending `whenDefined()` callbacks
6582
- function flushPendingWhenDefinedCallbacks(tagName, ctor) {
6583
- const resolvers = pendingWhenDefinedCallbacks.get(tagName);
6584
- if (!isUndefined$1(resolvers)) {
6585
- for (const resolver of resolvers) {
6586
- resolver(ctor);
6587
- }
6588
- }
6589
- pendingWhenDefinedCallbacks.delete(tagName);
6590
- }
6591
- const { customElements: nativeRegistry } = window;
6592
- const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
6593
- // patch for the global registry define mechanism
6594
- CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
6595
- if (options && options.extends) {
6596
- // TODO [#2983]: should we support `extends`?
6597
- throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
6598
- }
6599
- if (globalDefinitionsByTag.has(tagName)) {
6600
- throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`);
6601
- }
6602
- if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
6603
- throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`);
6604
- }
6605
- const definition = getOrCreateDefinitionForConstructor(constructor);
6606
- registeredUserCtors.add(constructor);
6607
- let PivotCtor = pivotCtorByTag.get(tagName);
6608
- if (isUndefined$1(PivotCtor)) {
6609
- PivotCtor = createPivotingClass(tagName, definition);
6610
- // Register a pivoting class which will handle global registry initializations
6611
- nativeDefine.call(nativeRegistry, tagName, PivotCtor);
6612
- }
6613
- // Only cache after nativeDefine has been called, because if it throws an error
6614
- // (e.g. for an invalid tag name), then we don't want to cache anything.
6615
- definitionForConstructor.set(constructor, definition);
6616
- pivotCtorByTag.set(tagName, PivotCtor);
6617
- globalDefinitionsByTag.set(tagName, definition);
6618
- globalDefinitionsByClass.set(constructor, definition);
6619
- // For globally defined custom elements, the definition associated
6620
- // to the UserCtor has a back-pointer to PivotCtor in case the user
6621
- // new the UserCtor, so we know how to create the underlying element.
6622
- definition.PivotCtor = PivotCtor;
6623
- // Upgrade any elements created in this scope before customElements.define
6624
- // was called, which should be exhibited by the following steps:
6625
- // 1) LWC registers a tagName for an LWC component.
6626
- // 2) Element with same tagName is created with document.createElement()
6627
- // and inserted into DOM.
6628
- // 3) customElements.define() is called with tagName and non-LWC constructor.
6629
- // This requires immediate upgrade when the new global tagName is defined.
6630
- const awaiting = awaitingUpgrade.get(tagName);
6631
- if (!isUndefined$1(awaiting)) {
6632
- awaitingUpgrade.delete(tagName);
6633
- for (const element of awaiting) {
6634
- const registeredDefinition = pendingRegistryForElement.get(element);
6635
- // At this point, registeredDefinition should never be undefined because awaitingUpgrade
6636
- // is only populated when we haven't run internalUpgrade yet, and we only populate
6637
- // pendingRegistryForElement when internalUpgrade hasn't run yet.
6638
- // But just to be safe, we check.
6639
- if (!isUndefined$1(registeredDefinition)) {
6640
- pendingRegistryForElement.delete(element);
6641
- internalUpgrade(element, registeredDefinition, definition);
6642
- }
6643
- }
6644
- }
6645
- // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
6646
- flushPendingWhenDefinedCallbacks(tagName, constructor);
6647
- };
6648
- CustomElementRegistry.prototype.get = function get(tagName) {
6649
- const NativeCtor = nativeGet.call(nativeRegistry, tagName);
6650
- if (!isUndefined$1(NativeCtor)) {
6651
- const definition = globalDefinitionsByTag.get(tagName);
6652
- if (!isUndefined$1(definition)) {
6653
- return definition.UserCtor; // defined by the patched custom elements registry
6654
- }
6655
- if (registeredPivotCtors.has(NativeCtor)) {
6656
- return undefined; // pivot constructors should not be observable, return undefined
6657
- }
6658
- return NativeCtor; // constructor that existed before patching
6659
- }
6660
- };
6661
- CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
6662
- return nativeWhenDefined.call(nativeRegistry, tagName).then((NativeCtor) => {
6663
- const definition = globalDefinitionsByTag.get(tagName);
6664
- if (!isUndefined$1(definition)) {
6665
- return definition.UserCtor;
6666
- }
6667
- // In this case, the custom element must have been defined before the registry patches
6668
- // were applied. So return the non-pivot constructor
6669
- if (isUndefined$1(NativeCtor)) {
6670
- // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
6671
- // We can patch the correct behavior using customElements.get()
6672
- NativeCtor = nativeGet.call(nativeRegistry, tagName);
6673
- }
6674
- if (registeredPivotCtors.has(NativeCtor)) {
6675
- // Pivot constructors should not be observable. Wait to resolve the promise
6676
- // if a constructor is ever defined in userland
6677
- return createPendingWhenDefinedCallback(tagName);
6678
- }
6679
- return NativeCtor;
6680
- });
6681
- };
6682
- // This constructor is invoked when we call `new pivotDefinition.UserCtor()`
6683
- // @ts-ignore
6684
- window.HTMLElement = function HTMLElement() {
6685
- // Upgrading case: the pivoting class constructor was run by the browser's
6686
- // native custom elements and we're in the process of running the
6687
- // "constructor-call trick" on the natively constructed instance, so just
6688
- // return that here.
6689
- // This code path is also called when LWC `new`s a PivotCtor.
6690
- const instance = upgradingInstance;
6691
- if (!isUndefined$1(instance)) {
6692
- upgradingInstance = undefined;
6693
- return instance;
6694
- }
6695
- // Construction case: we need to construct the pivoting instance and return it.
6696
- // This is possible when the user register it via global registry and instantiate
6697
- // it via `new Ctor()`.
6698
- const { constructor } = this;
6699
- const definition = globalDefinitionsByClass.get(constructor);
6700
- if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
6701
- // This code path is hit if someone `new`s a class that extends `HTMLElement` without
6702
- // doing `customElements.define()` first. This matches native browser behavior:
6703
- // https://stackoverflow.com/a/61883392
6704
- throw new TypeError('Illegal constructor');
6705
- }
6706
- // This constructor is ONLY invoked when it is the user instantiating
6707
- // an element via new Ctor while Ctor is a registered global constructor.
6708
- const { PivotCtor, UserCtor } = definition;
6709
- return new PivotCtor(UserCtor);
6710
- };
6711
- HTMLElement.prototype = NativeHTMLElement.prototype;
6712
- /**
6713
- * Create a new PivotConstructor for the given tagName, which is capable of being constructed
6714
- * with a UserConstructor defining the behavior. Passing in the UserConstructor here
6715
- * is a hint that can be used when registering a custom element with the global custom elements
6716
- * registry for the first time, which provides certain optimizations. It also marks the UserConstructor
6717
- * as "safe" to be used when passed in to a PivotConstructor.
6718
- *
6719
- * @param tagName - element tag name
6720
- * @param UserCtor - userland custom element constructor
6721
- * @returns a new custom element constructor
6722
- */
6723
- return function createPivotConstructor(tagName, UserCtor) {
6724
- tagName = StringToLowerCase.call(tagName);
6725
- let PivotCtor = pivotCtorByTag.get(tagName);
6726
- if (isUndefined$1(PivotCtor)) {
6727
- const definition = getOrCreateDefinitionForConstructor(UserCtor);
6728
- PivotCtor = createPivotingClass(tagName, definition);
6729
- // Register a pivoting class as a global custom element
6730
- nativeDefine.call(nativeRegistry, tagName, PivotCtor);
6731
- definition.PivotCtor = PivotCtor;
6732
- // Only cache after nativeDefine has been called, because if it throws an error
6733
- // (e.g. for an invalid tag name), then we don't want to cache anything.
6734
- definitionForConstructor.set(UserCtor, definition);
6735
- pivotCtorByTag.set(tagName, PivotCtor);
6736
- }
6737
- // Register a UserConstructor as "safe" to be used within a PivotConstructor
6738
- registeredUserCtors.add(UserCtor);
6739
- return PivotCtor;
6740
- };
6741
- }
6742
-
6743
- /*
6744
- * Copyright (c) 2018, salesforce.com, inc.
6745
- * All rights reserved.
6746
- * SPDX-License-Identifier: MIT
6747
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6748
- */
6749
- let createScopedConstructor;
6750
- let CachedHTMLElement;
6751
- // We only call `createScopedRegistry()` if the browser supports custom elements and
6752
- // ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
6753
- // or we're in a legacy browser.
6754
- if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
6755
- if (hasCustomElements) {
6756
- // If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
6757
- // It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
6758
- //
6759
- // Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
6760
- //
6761
- // 1. LWC loads
6762
- // 2. `const Ctor = class extends HTMLElement {}`
6763
- // 3. `lwc.createElement(...)` // here we lazily patch
6764
- // 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
6765
- //
6766
- // To reduce the risk of this, it's safer to patch the registry eagerly.
6767
- createScopedConstructor = createScopedRegistry();
6768
- // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
6769
- // another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
6770
- // because the HTMLElement prototypes are mixed up.
6771
- //
6772
- // The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
6773
- // with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
6774
- // the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
6775
- // Caching avoids this problem.
6776
- CachedHTMLElement = window.HTMLElement;
6777
- }
6778
- }
6779
- // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
6780
- // In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
6781
- // multiple times per tag name.
6782
- const createUserConstructor = (HTMLElementToExtend, upgradeCallback, connectedCallback, disconnectedCallback) => {
6783
- // TODO [#2972]: this class should expose observedAttributes as necessary
6784
- return class UserConstructor extends HTMLElementToExtend {
6785
- constructor() {
6786
- super();
6787
- upgradeCallback(this);
6788
- }
6789
- // Note that there is no need to do the "avoid defining connectedCallback/disconnectedCallback" optimization
6790
- // here, because in create-scoped-registry.ts, the registered class will always have these callbacks anyway.
6791
- // See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
6792
- connectedCallback() {
6793
- if (!isUndefined$1(connectedCallback)) {
6794
- connectedCallback(this);
6795
- }
6796
- }
6797
- disconnectedCallback() {
6798
- if (!isUndefined$1(disconnectedCallback)) {
6799
- disconnectedCallback(this);
6800
- }
6801
- }
6802
- };
6803
- };
6804
- function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
6805
- if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
6806
- // This error should be impossible to hit
6807
- throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
6808
- }
6809
- const UserConstructor = createUserConstructor(CachedHTMLElement, upgradeCallback, connectedCallback, disconnectedCallback);
6810
- const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
6811
- return new ScopedConstructor(UserConstructor);
6812
- }
6813
-
6814
6271
  /*
6815
6272
  * Copyright (c) 2018, salesforce.com, inc.
6816
6273
  * All rights reserved.
@@ -6818,29 +6275,22 @@
6818
6275
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6819
6276
  */
6820
6277
  /**
6821
- * We have three modes for creating custom elements:
6278
+ * We have two modes for creating custom elements:
6822
6279
  *
6823
6280
  * 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
6824
6281
  * 2. "Upgradable constructor" custom element. This allows us to have two LWC components with the same tag name,
6825
6282
  * via a trick: every custom element constructor we define in the registry is basically the same. It's essentially
6826
6283
  * a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its constructor ("upgradable
6827
6284
  * constructor"), which allows us to have completely customized functionality for different components.
6828
- * 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
6829
- * elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
6830
- * between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
6831
- * because it must patch the global `customElements` and `HTMLElement` objects.
6832
6285
  */
6833
6286
  let createCustomElement;
6834
6287
  if (hasCustomElements) {
6835
- if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
6836
- createCustomElement = createCustomElementScoped;
6837
- } else {
6838
6288
  // use the global registry, with an upgradable constructor for the defined custom element
6839
6289
  createCustomElement = createCustomElementUsingUpgradableConstructor;
6840
- }
6841
- } else {
6842
- // no registry available here
6843
- createCustomElement = createCustomElementCompat;
6290
+ }
6291
+ else {
6292
+ // no registry available here
6293
+ createCustomElement = createCustomElementCompat;
6844
6294
  }
6845
6295
 
6846
6296
  /*
@@ -6903,7 +6353,7 @@
6903
6353
  function isNull(obj) {
6904
6354
  return obj === null;
6905
6355
  }
6906
- /** version: 2.36.0 */
6356
+ /** version: 2.37.0 */
6907
6357
 
6908
6358
  /*
6909
6359
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7456,7 +6906,7 @@
7456
6906
  });
7457
6907
  freeze(LightningElement);
7458
6908
  seal(LightningElement.prototype);
7459
- /* version: 2.36.0 */
6909
+ /* version: 2.37.0 */
7460
6910
 
7461
6911
  exports.LightningElement = LightningElement;
7462
6912
  exports.__unstable__ProfilerControl = profilerControl;