lwc 2.35.2 → 2.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +260 -654
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +260 -654
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +286 -608
  5. package/dist/engine-dom/iife/es5/engine-dom.js +406 -852
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +450 -778
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +260 -654
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +286 -608
  11. package/dist/engine-dom/umd/es5/engine-dom.js +406 -852
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +450 -778
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +153 -92
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +153 -93
  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.35.2 */
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.35.2 */
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.35.2 */
457
+ /** version: 2.37.0 */
460
458
 
461
459
  /*
462
460
  * Copyright (c) 2018, salesforce.com, inc.
@@ -476,7 +474,6 @@
476
474
  * SPDX-License-Identifier: MIT
477
475
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
478
476
  */
479
- /** Callbacks to invoke when reporting is enabled **/
480
477
  const onReportingEnabledCallbacks = [];
481
478
  /** The currently assigned reporting dispatcher. */
482
479
  let currentDispatcher$1 = noop;
@@ -534,11 +531,11 @@
534
531
  /**
535
532
  * Report to the current dispatcher, if there is one.
536
533
  * @param reportingEventId
537
- * @param vm
534
+ * @param payload - data to report
538
535
  */
539
- function report(reportingEventId, vm) {
536
+ function report(reportingEventId, payload) {
540
537
  if (enabled$1) {
541
- currentDispatcher$1(reportingEventId, vm.tagName, vm.idx);
538
+ currentDispatcher$1(reportingEventId, payload);
542
539
  }
543
540
  }
544
541
 
@@ -784,7 +781,7 @@
784
781
  // Make a shallow copy of an object but omit the given key
785
782
  function cloneAndOmitKey(object, keyToOmit) {
786
783
  const result = {};
787
- for (const key of Object.keys(object)) {
784
+ for (const key of keys(object)) {
788
785
  if (key !== keyToOmit) {
789
786
  result[key] = object[key];
790
787
  }
@@ -794,7 +791,7 @@
794
791
  function flattenStylesheets(stylesheets) {
795
792
  const list = [];
796
793
  for (const stylesheet of stylesheets) {
797
- if (!Array.isArray(stylesheet)) {
794
+ if (!isArray$1(stylesheet)) {
798
795
  list.push(stylesheet);
799
796
  }
800
797
  else {
@@ -3759,7 +3756,12 @@
3759
3756
  } else if (isVScopedSlotFragment(vnode)) {
3760
3757
  slotName = vnode.slotName;
3761
3758
  }
3762
- const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
3759
+ // Can't use toString here because Symbol(1).toString() is 'Symbol(1)'
3760
+ // but elm.setAttribute('slot', Symbol(1)) is an error.
3761
+ // the following line also throws same error for symbols
3762
+ // Similar for Object.create(null)
3763
+ const normalizedSlotName = '' + slotName;
3764
+ const vnodes = cmpSlotsMapping[normalizedSlotName] = cmpSlotsMapping[normalizedSlotName] || [];
3763
3765
  ArrayPush$1.call(vnodes, vnode);
3764
3766
  }
3765
3767
  vm.cmpSlots = {
@@ -4835,15 +4837,13 @@
4835
4837
  }
4836
4838
  // Validate and flatten any stylesheets defined as `static stylesheets`
4837
4839
  function computeStylesheets(vm, ctor) {
4838
- if (lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
4839
- const {
4840
- stylesheets
4841
- } = ctor;
4842
- if (!isUndefined$1(stylesheets)) {
4843
- const valid = validateComponentStylesheets(vm, stylesheets);
4844
- if (valid) {
4845
- return flattenStylesheets(stylesheets);
4846
- }
4840
+ const {
4841
+ stylesheets
4842
+ } = ctor;
4843
+ if (!isUndefined$1(stylesheets)) {
4844
+ const valid = validateComponentStylesheets(vm, stylesheets);
4845
+ if (valid) {
4846
+ return flattenStylesheets(stylesheets);
4847
4847
  }
4848
4848
  }
4849
4849
  return null;
@@ -5184,7 +5184,7 @@
5184
5184
  // The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
5185
5185
  // These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
5186
5186
  // When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
5187
- // See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
5187
+ // See: https://sfdc.co/synthetic-aria
5188
5188
  //
5189
5189
  // Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
5190
5190
  const getElementById = _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
@@ -5192,7 +5192,7 @@
5192
5192
  function isSyntheticShadowRootInstance(rootNode) {
5193
5193
  return rootNode !== document && isTrue(rootNode.synthetic);
5194
5194
  }
5195
- function reportViolation(source, target, attrName) {
5195
+ function reportViolation$1(source, target, attrName) {
5196
5196
  // The vm is either for the source, the target, or both. Either one or both must be using synthetic
5197
5197
  // shadow for a violation to be detected.
5198
5198
  let vm = getAssociatedVMIfPresent(source.getRootNode().host);
@@ -5203,7 +5203,10 @@
5203
5203
  // vm should never be undefined here, but just to be safe, bail out and don't report
5204
5204
  return;
5205
5205
  }
5206
- report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
5206
+ report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, {
5207
+ tagName: vm.tagName,
5208
+ attributeName: attrName,
5209
+ });
5207
5210
  }
5208
5211
  function parseIdRefAttributeValue(attrValue) {
5209
5212
  // split on whitespace and skip empty strings after splitting
@@ -5229,7 +5232,7 @@
5229
5232
  const sourceElement = sourceElements[i];
5230
5233
  const sourceRoot = sourceElement.getRootNode();
5231
5234
  if (sourceRoot !== root) {
5232
- reportViolation(sourceElement, elm);
5235
+ reportViolation$1(sourceElement, elm, idRefAttrName);
5233
5236
  break;
5234
5237
  }
5235
5238
  }
@@ -5244,7 +5247,7 @@
5244
5247
  const targetRoot = target.getRootNode();
5245
5248
  if (targetRoot !== root) {
5246
5249
  // target element's shadow root is not the same as ours
5247
- reportViolation(elm, target);
5250
+ reportViolation$1(elm, target, attrName);
5248
5251
  }
5249
5252
  }
5250
5253
  }
@@ -5253,7 +5256,7 @@
5253
5256
  let enabled = false;
5254
5257
  // We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
5255
5258
  // reporting is not enabled. It should also only run once
5256
- function enableDetection() {
5259
+ function enableDetection$1() {
5257
5260
  if (enabled) {
5258
5261
  return; // don't double-apply the patches
5259
5262
  }
@@ -5306,8 +5309,92 @@
5306
5309
  // Always run detection in dev mode, so we can at least print to the console
5307
5310
  {
5308
5311
  // In prod mode, only enable detection if reporting is enabled
5309
- onReportingEnabled(enableDetection);
5312
+ onReportingEnabled(enableDetection$1);
5313
+ }
5314
+ }
5315
+
5316
+ /*
5317
+ * Copyright (c) 2018, salesforce.com, inc.
5318
+ * All rights reserved.
5319
+ * SPDX-License-Identifier: MIT
5320
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5321
+ */
5322
+ //
5323
+ // The goal of this code is to detect usages of non-standard reflected ARIA properties. These are caused by
5324
+ // legacy non-standard Element.prototype extensions added by the @lwc/aria-reflection package.
5325
+ //
5326
+ // See the README for @lwc/aria-reflection
5327
+ const NON_STANDARD_ARIA_PROPS = ['ariaActiveDescendant', 'ariaControls', 'ariaDescribedBy', 'ariaDetails', 'ariaErrorMessage', 'ariaFlowTo', 'ariaLabelledBy', 'ariaOwns'];
5328
+ function isLightningElement(elm) {
5329
+ // The former case is for `this.prop` (inside component) and the latter is for `element.prop` (outside component).
5330
+ // In both cases, we apply the non-standard prop even when the global polyfill is disabled, so this is kosher.
5331
+ return elm instanceof LightningElement || elm instanceof BaseBridgeElement;
5332
+ }
5333
+ function findVM(elm) {
5334
+ // If it's a shadow DOM component, then it has a host
5335
+ const {
5336
+ host
5337
+ } = elm.getRootNode();
5338
+ const vm = isUndefined$1(host) ? undefined : getAssociatedVMIfPresent(host);
5339
+ if (!isUndefined$1(vm)) {
5340
+ return vm;
5341
+ }
5342
+ // Else it might be a light DOM component. Walk up the tree trying to find the owner
5343
+ let parentElement = elm;
5344
+ while (!isNull(parentElement = parentElement.parentElement)) {
5345
+ if (isLightningElement(parentElement)) {
5346
+ const vm = getAssociatedVMIfPresent(parentElement);
5347
+ if (!isUndefined$1(vm)) {
5348
+ return vm;
5349
+ }
5350
+ }
5351
+ }
5352
+ // If we return undefined, it's because the element was rendered wholly outside a LightningElement
5353
+ }
5354
+
5355
+ function checkAndReportViolation(elm, prop) {
5356
+ if (!isLightningElement(elm)) {
5357
+ const vm = findVM(elm);
5358
+ report(2 /* ReportingEventId.NonStandardAriaReflection */, {
5359
+ tagName: vm === null || vm === void 0 ? void 0 : vm.tagName,
5360
+ propertyName: prop
5361
+ });
5362
+ }
5363
+ }
5364
+ function enableDetection() {
5365
+ const {
5366
+ prototype
5367
+ } = Element;
5368
+ for (const prop of NON_STANDARD_ARIA_PROPS) {
5369
+ const descriptor = getOwnPropertyDescriptor$1(prototype, prop);
5370
+ // @ts-ignore
5371
+ const {
5372
+ get,
5373
+ set
5374
+ } = descriptor;
5375
+ defineProperty(prototype, prop, {
5376
+ get() {
5377
+ checkAndReportViolation(this, prop);
5378
+ return get.call(this);
5379
+ },
5380
+ set(val) {
5381
+ checkAndReportViolation(this, prop);
5382
+ return set.call(this, val);
5383
+ },
5384
+ configurable: true,
5385
+ enumerable: true
5386
+ });
5387
+ }
5388
+ }
5389
+ // No point in running this code if we're not in a browser, or if the global polyfill is not loaded
5390
+ {
5391
+ if (!lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
5392
+ // Always run detection in dev mode, so we can at least print to the console
5393
+ {
5394
+ // In prod mode, only enable detection if reporting is enabled
5395
+ onReportingEnabled(enableDetection);
5310
5396
  }
5397
+ }
5311
5398
  }
5312
5399
 
5313
5400
  /*
@@ -5714,6 +5801,97 @@
5714
5801
  hooksAreSet = true;
5715
5802
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5716
5803
  }
5804
+
5805
+ /*
5806
+ * Copyright (c) 2018, salesforce.com, inc.
5807
+ * All rights reserved.
5808
+ * SPDX-License-Identifier: MIT
5809
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5810
+ */
5811
+ // See @lwc/engine-core/src/framework/template.ts
5812
+ const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
5813
+ // Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
5814
+ const STYLESHEET_PROPS = [
5815
+ // SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
5816
+ '$scoped$'];
5817
+ // Via https://www.npmjs.com/package/object-observer
5818
+ const ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
5819
+ let mutationTrackingDisabled = false;
5820
+ function getOriginalArrayMethod(prop) {
5821
+ switch (prop) {
5822
+ case 'pop':
5823
+ return ArrayPop;
5824
+ case 'push':
5825
+ return ArrayPush$1;
5826
+ case 'shift':
5827
+ return ArrayShift;
5828
+ case 'unshift':
5829
+ return ArrayUnshift;
5830
+ case 'reverse':
5831
+ return ArrayReverse;
5832
+ case 'sort':
5833
+ return ArraySort;
5834
+ case 'fill':
5835
+ return ArrayFill;
5836
+ case 'splice':
5837
+ return ArraySplice;
5838
+ case 'copyWithin':
5839
+ return ArrayCopyWithin;
5840
+ }
5841
+ }
5842
+ function reportViolation(type, eventId, prop) {
5843
+ report(eventId, {
5844
+ propertyName: prop
5845
+ });
5846
+ }
5847
+ function reportTemplateViolation(prop) {
5848
+ reportViolation('template', 3 /* ReportingEventId.TemplateMutation */, prop);
5849
+ }
5850
+ function reportStylesheetViolation(prop) {
5851
+ reportViolation('stylesheet', 4 /* ReportingEventId.StylesheetMutation */, prop);
5852
+ }
5853
+ // Warn if the user tries to mutate a stylesheets array, e.g.:
5854
+ // `tmpl.stylesheets.push(someStylesheetFunction)`
5855
+ function warnOnArrayMutation(stylesheets) {
5856
+ // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
5857
+ // we can at least warn when they use the most common mutation methods.
5858
+ for (const prop of ARRAY_MUTATION_METHODS) {
5859
+ const originalArrayMethod = getOriginalArrayMethod(prop);
5860
+ stylesheets[prop] = function arrayMutationWarningWrapper() {
5861
+ reportTemplateViolation('stylesheets');
5862
+ // @ts-ignore
5863
+ return originalArrayMethod.apply(this, arguments);
5864
+ };
5865
+ }
5866
+ }
5867
+ // Warn if the user tries to mutate a stylesheet factory function, e.g.:
5868
+ // `stylesheet.$scoped$ = true`
5869
+ function warnOnStylesheetFunctionMutation(stylesheet) {
5870
+ for (const prop of STYLESHEET_PROPS) {
5871
+ let value = stylesheet[prop];
5872
+ defineProperty(stylesheet, prop, {
5873
+ enumerable: true,
5874
+ configurable: true,
5875
+ get() {
5876
+ return value;
5877
+ },
5878
+ set(newValue) {
5879
+ reportStylesheetViolation(prop);
5880
+ value = newValue;
5881
+ }
5882
+ });
5883
+ }
5884
+ }
5885
+ // Warn on either array or stylesheet (function) mutation, in a deeply-nested array
5886
+ function trackStylesheetsMutation(stylesheets) {
5887
+ traverseStylesheets(stylesheets, subStylesheets => {
5888
+ if (isArray$1(subStylesheets)) {
5889
+ warnOnArrayMutation(subStylesheets);
5890
+ } else {
5891
+ warnOnStylesheetFunctionMutation(subStylesheets);
5892
+ }
5893
+ });
5894
+ }
5717
5895
  // Deeply freeze the entire array (of arrays) of stylesheet factory functions
5718
5896
  function deepFreeze(stylesheets) {
5719
5897
  traverseStylesheets(stylesheets, subStylesheets => {
@@ -5732,7 +5910,70 @@
5732
5910
  }
5733
5911
  }
5734
5912
  }
5913
+ function trackMutations(tmpl) {
5914
+ if (!isUndefined$1(tmpl.stylesheets)) {
5915
+ trackStylesheetsMutation(tmpl.stylesheets);
5916
+ }
5917
+ for (const prop of TEMPLATE_PROPS) {
5918
+ let value = tmpl[prop];
5919
+ defineProperty(tmpl, prop, {
5920
+ enumerable: true,
5921
+ configurable: true,
5922
+ get() {
5923
+ return value;
5924
+ },
5925
+ set(newValue) {
5926
+ if (!mutationTrackingDisabled) {
5927
+ reportTemplateViolation(prop);
5928
+ }
5929
+ value = newValue;
5930
+ }
5931
+ });
5932
+ }
5933
+ const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
5934
+ defineProperty(tmpl, 'stylesheetTokens', {
5935
+ enumerable: true,
5936
+ configurable: true,
5937
+ get: originalDescriptor.get,
5938
+ set(value) {
5939
+ reportTemplateViolation('stylesheetTokens');
5940
+ // Avoid logging/reporting twice (for both stylesheetToken and stylesheetTokens)
5941
+ mutationTrackingDisabled = true;
5942
+ originalDescriptor.set.call(this, value);
5943
+ mutationTrackingDisabled = false;
5944
+ }
5945
+ });
5946
+ }
5947
+ function addLegacyStylesheetTokensShim(tmpl) {
5948
+ // When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
5949
+ // is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
5950
+ defineProperty(tmpl, 'stylesheetTokens', {
5951
+ enumerable: true,
5952
+ configurable: true,
5953
+ get() {
5954
+ const {
5955
+ stylesheetToken
5956
+ } = this;
5957
+ if (isUndefined$1(stylesheetToken)) {
5958
+ return stylesheetToken;
5959
+ }
5960
+ // Shim for the old `stylesheetTokens` property
5961
+ // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
5962
+ return {
5963
+ hostAttribute: `${stylesheetToken}-host`,
5964
+ shadowAttribute: stylesheetToken
5965
+ };
5966
+ },
5967
+ set(value) {
5968
+ // If the value is null or some other exotic object, you would be broken anyway in the past
5969
+ // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
5970
+ // However it may be undefined in newer versions of LWC, so we need to guard against that case.
5971
+ this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
5972
+ }
5973
+ });
5974
+ }
5735
5975
  function freezeTemplate(tmpl) {
5976
+ // TODO [#2782]: remove this flag and delete the legacy behavior
5736
5977
  if (lwcRuntimeFlags.ENABLE_FROZEN_TEMPLATE) {
5737
5978
  // Deep freeze the template
5738
5979
  freeze(tmpl);
@@ -5740,33 +5981,16 @@
5740
5981
  deepFreeze(tmpl.stylesheets);
5741
5982
  }
5742
5983
  } else {
5743
- // TODO [#2782]: remove this flag and delete the legacy behavior
5744
- // When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
5745
- // is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
5746
- defineProperty(tmpl, 'stylesheetTokens', {
5747
- enumerable: true,
5748
- configurable: true,
5749
- get() {
5750
- const {
5751
- stylesheetToken
5752
- } = this;
5753
- if (isUndefined$1(stylesheetToken)) {
5754
- return stylesheetToken;
5755
- }
5756
- // Shim for the old `stylesheetTokens` property
5757
- // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
5758
- return {
5759
- hostAttribute: `${stylesheetToken}-host`,
5760
- shadowAttribute: stylesheetToken
5761
- };
5762
- },
5763
- set(value) {
5764
- // If the value is null or some other exotic object, you would be broken anyway in the past
5765
- // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
5766
- // However it may be undefined in newer versions of LWC, so we need to guard against that case.
5767
- this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
5768
- }
5769
- });
5984
+ // template is not frozen - shim, report, and warn
5985
+ // this shim should be applied in both dev and prod
5986
+ addLegacyStylesheetTokensShim(tmpl);
5987
+ // When ENABLE_FROZEN_TEMPLATE is false, we want to warn in dev mode whenever someone is mutating the template
5988
+ {
5989
+ // In prod mode, we only track mutations if reporting is enabled
5990
+ onReportingEnabled(() => {
5991
+ trackMutations(tmpl);
5992
+ });
5993
+ }
5770
5994
  }
5771
5995
  }
5772
5996
 
@@ -6044,545 +6268,6 @@
6044
6268
  }
6045
6269
  };
6046
6270
 
6047
- /*
6048
- * Copyright (c) 2020, salesforce.com, inc.
6049
- * All rights reserved.
6050
- * SPDX-License-Identifier: MIT
6051
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6052
- */
6053
- /**
6054
- * Create a scoped registry, i.e. a function that can create custom elements whose tag names
6055
- * do not conflict with third-party custom elements having the same tag name.
6056
- */
6057
- function createScopedRegistry() {
6058
- if (!hasCustomElements) {
6059
- // This code should never be reached, because we don't use the pivot registry if
6060
- // custom elements are unavailable.
6061
- throw new Error('Custom elements are not supported in this environment.');
6062
- }
6063
- const { HTMLElement: NativeHTMLElement } = window;
6064
- const { hasAttribute: nativeHasAttribute, setAttribute: nativeSetAttribute, removeAttribute: nativeRemoveAttribute, getAttribute: nativeGetAttribute, } = NativeHTMLElement.prototype;
6065
- const definitionForElement = new WeakMap();
6066
- const pendingRegistryForElement = new WeakMap();
6067
- const definitionForConstructor = new WeakMap();
6068
- const registeredUserCtors = new WeakSet();
6069
- const registeredPivotCtors = new WeakSet();
6070
- const pivotCtorByTag = new Map();
6071
- const globalDefinitionsByTag = new Map();
6072
- const globalDefinitionsByClass = new Map();
6073
- const awaitingUpgrade = new Map();
6074
- const pendingWhenDefinedCallbacks = new Map();
6075
- const EMPTY_SET = new Set();
6076
- function createDefinitionRecord(constructor) {
6077
- var _a;
6078
- const { connectedCallback, disconnectedCallback, formAssociatedCallback, formDisabledCallback, formResetCallback, formStateRestoreCallback, adoptedCallback, attributeChangedCallback, } = constructor.prototype;
6079
- const formAssociated = Boolean(constructor.formAssociated);
6080
- const observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
6081
- return {
6082
- UserCtor: constructor,
6083
- PivotCtor: undefined,
6084
- connectedCallback,
6085
- disconnectedCallback,
6086
- formAssociatedCallback,
6087
- formDisabledCallback,
6088
- formResetCallback,
6089
- formStateRestoreCallback,
6090
- adoptedCallback,
6091
- attributeChangedCallback,
6092
- observedAttributes,
6093
- formAssociated,
6094
- };
6095
- }
6096
- // Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
6097
- // element. Note that the `registeredDefinition` represents the constructor that was used to register during
6098
- // `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
6099
- // constructor is invoked with another constructor.
6100
- function createPivotingClass(tagName, registeredDefinition) {
6101
- class PivotCtor extends NativeHTMLElement {
6102
- constructor(UserCtor) {
6103
- // This constructor can only be invoked by:
6104
- // a) the browser instantiating an element from parsing or via document.createElement.
6105
- // b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
6106
- // b) new UserClass.
6107
- // When LWC instantiates it, it will pass the upgrading definition as an argument
6108
- // If the caller signals via UserCtor that this is in fact a controlled
6109
- // definition, we use that one, otherwise fallback to the global
6110
- // internal registry.
6111
- super();
6112
- const userCtorIsDefined = !isUndefined$1(UserCtor);
6113
- if (userCtorIsDefined) {
6114
- if (!isConstructor(UserCtor)) {
6115
- throw new TypeError(`Failed to create custom element: the provided constructor is not a constructor.`);
6116
- }
6117
- if (!registeredUserCtors.has(UserCtor)) {
6118
- throw new Error(`Failed to create custom element: the provided constructor is unregistered: ${UserCtor.name}.`);
6119
- }
6120
- }
6121
- const definition = userCtorIsDefined
6122
- ? getOrCreateDefinitionForConstructor(UserCtor)
6123
- : globalDefinitionsByTag.get(tagName);
6124
- if (!isUndefined$1(definition)) {
6125
- internalUpgrade(this, registeredDefinition, definition);
6126
- }
6127
- else {
6128
- // This is the case in which there is no global definition, and
6129
- // it is not handled by LWC (otherwise it will have a valid UserCtor)
6130
- // so we need to add it to the pending queue just in case it eventually
6131
- // gets defined in the global registry.
6132
- pendingRegistryForElement.set(this, registeredDefinition);
6133
- }
6134
- }
6135
- connectedCallback() {
6136
- var _a;
6137
- const definition = definitionForElement.get(this);
6138
- if (!isUndefined$1(definition)) {
6139
- // Delegate out to user callback
6140
- (_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
6141
- }
6142
- else {
6143
- // Register for upgrade when defined (only when connected, so we don't leak)
6144
- let awaiting = awaitingUpgrade.get(tagName);
6145
- if (isUndefined$1(awaiting)) {
6146
- awaitingUpgrade.set(tagName, (awaiting = new Set()));
6147
- }
6148
- awaiting.add(this);
6149
- }
6150
- }
6151
- disconnectedCallback() {
6152
- var _a;
6153
- const definition = definitionForElement.get(this);
6154
- if (!isUndefined$1(definition)) {
6155
- // Delegate out to user callback
6156
- (_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
6157
- }
6158
- else {
6159
- // Un-register for upgrade when defined (so we don't leak)
6160
- const awaiting = awaitingUpgrade.get(tagName);
6161
- // At this point, awaiting should never be undefined, because connectedCallback
6162
- // must have been called before disconnectedCallback. But just to be safe, we check
6163
- if (!isUndefined$1(awaiting)) {
6164
- awaiting.delete(this);
6165
- }
6166
- }
6167
- }
6168
- formAssociatedCallback(form) {
6169
- var _a;
6170
- const definition = definitionForElement.get(this);
6171
- (_a = definition === null || definition === void 0 ? void 0 : definition.formAssociatedCallback) === null || _a === void 0 ? void 0 : _a.call(this, form);
6172
- }
6173
- formDisabledCallback(disabled) {
6174
- var _a;
6175
- const definition = definitionForElement.get(this);
6176
- (_a = definition === null || definition === void 0 ? void 0 : definition.formDisabledCallback) === null || _a === void 0 ? void 0 : _a.call(this, disabled);
6177
- }
6178
- formResetCallback() {
6179
- var _a;
6180
- const definition = definitionForElement.get(this);
6181
- (_a = definition === null || definition === void 0 ? void 0 : definition.formResetCallback) === null || _a === void 0 ? void 0 : _a.call(this);
6182
- }
6183
- formStateRestoreCallback(state, mode) {
6184
- var _a;
6185
- const definition = definitionForElement.get(this);
6186
- (_a = definition === null || definition === void 0 ? void 0 : definition.formStateRestoreCallback) === null || _a === void 0 ? void 0 : _a.call(this, state, mode);
6187
- }
6188
- adoptedCallback() {
6189
- var _a;
6190
- const definition = definitionForElement.get(this);
6191
- (_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
6192
- }
6193
- attributeChangedCallback(name, oldValue, newValue) {
6194
- var _a;
6195
- const definition = definitionForElement.get(this);
6196
- // if both definitions are the same, then the observedAttributes is the same,
6197
- // but if they are different, only if the runtime definition has the attribute
6198
- // marked as observed, then it should invoke attributeChangedCallback.
6199
- if (registeredDefinition === definition ||
6200
- (definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
6201
- (_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
6202
- }
6203
- }
6204
- }
6205
- PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
6206
- // TODO [#3000]: support case where registeredDefinition is not form-associated, but later definition is.
6207
- PivotCtor.formAssociated = registeredDefinition.formAssociated;
6208
- registeredPivotCtors.add(PivotCtor);
6209
- return PivotCtor;
6210
- }
6211
- function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
6212
- const { observedAttributes, attributeChangedCallback } = pivotDefinition;
6213
- if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
6214
- // This instance does not need to observe any attributes, no need to patch
6215
- return EMPTY_SET;
6216
- }
6217
- // Natively, the attributes observed by the registered definition are going to be taken
6218
- // care of by the browser, only the difference between the two sets has to be taken
6219
- // care by the patched version.
6220
- return new Set([...pivotDefinition.observedAttributes].filter((x) => !registeredDefinition.observedAttributes.has(x)));
6221
- }
6222
- function throwAsyncError(error) {
6223
- // Per native custom element behavior, errors thrown in attributeChangedCallback
6224
- // become unhandled async errors. We use setTimeout() instead of Promise.resolve()
6225
- // to make it an unhandled error rather than an unhandled rejection.
6226
- setTimeout(() => {
6227
- throw error;
6228
- });
6229
- }
6230
- // Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
6231
- // Why is this necessary? Well basically, you can't change the `observedAttributes` after
6232
- // a custom element is defined. So with pivots, if two classes share the same tag name,
6233
- // and the second class observes attributes that aren't observed by the first one,
6234
- // then those attributes can never be observed by the native `observedAttributes` system.
6235
- // So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
6236
- // we only do this when absolutely necessary, though; i.e. because we've determined
6237
- // that we aren't observing the attributes we need to.
6238
- function patchAttributes(instance, registeredDefinition, pivotDefinition) {
6239
- const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
6240
- if (newObservedAttributes.size === 0) {
6241
- return;
6242
- }
6243
- const { attributeChangedCallback } = pivotDefinition;
6244
- // Patch the instance.
6245
- // Note we use the native `getAttribute` rather than the super's `getAttribute` because
6246
- // we don't actually want it to be observable that we're calling `getAttribute` from
6247
- // `setAttribute` and `removeAttribute`.
6248
- // TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
6249
- defineProperties(instance, {
6250
- setAttribute: {
6251
- value: function setAttribute(name, value) {
6252
- if (newObservedAttributes.has(name)) {
6253
- const old = nativeGetAttribute.call(this, name);
6254
- nativeSetAttribute.call(this, name, value);
6255
- try {
6256
- attributeChangedCallback.call(this, name, old, value + '');
6257
- }
6258
- catch (error) {
6259
- throwAsyncError(error);
6260
- }
6261
- }
6262
- else {
6263
- nativeSetAttribute.call(this, name, value);
6264
- }
6265
- },
6266
- writable: true,
6267
- enumerable: true,
6268
- configurable: true,
6269
- },
6270
- removeAttribute: {
6271
- value: function removeAttribute(name) {
6272
- if (newObservedAttributes.has(name)) {
6273
- const old = nativeGetAttribute.call(this, name);
6274
- nativeRemoveAttribute.call(this, name);
6275
- try {
6276
- attributeChangedCallback.call(this, name, old, null);
6277
- }
6278
- catch (error) {
6279
- throwAsyncError(error);
6280
- }
6281
- }
6282
- else {
6283
- nativeRemoveAttribute.call(this, name);
6284
- }
6285
- },
6286
- writable: true,
6287
- enumerable: true,
6288
- configurable: true,
6289
- },
6290
- });
6291
- }
6292
- function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
6293
- // The below case patches observed attributes for the case where the HTML element is upgraded
6294
- // from a pre-existing one in the DOM.
6295
- const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
6296
- if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
6297
- return;
6298
- }
6299
- const { attributeChangedCallback } = pivotDefinition;
6300
- // Approximate observedAttributes from the user class, but only for the new observed attributes
6301
- newObservedAttributes.forEach((name) => {
6302
- if (nativeHasAttribute.call(instance, name)) {
6303
- const newValue = nativeGetAttribute.call(instance, name);
6304
- attributeChangedCallback.call(instance, name, null, newValue);
6305
- }
6306
- });
6307
- }
6308
- // User extends this HTMLElement, which returns the CE being upgraded
6309
- let upgradingInstance;
6310
- // Helper to upgrade an instance with a CE definition using "constructor call trick"
6311
- function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
6312
- setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
6313
- definitionForElement.set(instance, pivotDefinition);
6314
- // attributes patches when needed
6315
- if (pivotDefinition !== registeredDefinition) {
6316
- patchAttributes(instance, registeredDefinition, pivotDefinition);
6317
- }
6318
- // Tricking the construction path to believe that a new instance is being created,
6319
- // that way it will execute the super initialization mechanism but the HTMLElement
6320
- // constructor will reuse the instance by returning the upgradingInstance.
6321
- // This is by far the most important piece of the puzzle
6322
- upgradingInstance = instance;
6323
- // By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
6324
- // The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
6325
- // Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
6326
- new pivotDefinition.UserCtor();
6327
- patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
6328
- }
6329
- function isConstructor(constructor) {
6330
- return isFunction$1(constructor) && isObject(constructor.prototype);
6331
- }
6332
- function getOrCreateDefinitionForConstructor(constructor) {
6333
- if (!isConstructor(constructor)) {
6334
- throw new TypeError('The referenced constructor is not a constructor.');
6335
- }
6336
- const definition = definitionForConstructor.get(constructor);
6337
- if (!isUndefined$1(definition)) {
6338
- return definition;
6339
- }
6340
- return createDefinitionRecord(constructor);
6341
- }
6342
- // Defer a `whenDefined()` callback until an externally-visible custom element is defined
6343
- function createPendingWhenDefinedCallback(tagName) {
6344
- return new Promise((resolve) => {
6345
- let resolvers = pendingWhenDefinedCallbacks.get(tagName);
6346
- if (isUndefined$1(resolvers)) {
6347
- resolvers = [];
6348
- pendingWhenDefinedCallbacks.set(tagName, resolvers);
6349
- }
6350
- resolvers.push(resolve);
6351
- });
6352
- }
6353
- // Call any pending `whenDefined()` callbacks
6354
- function flushPendingWhenDefinedCallbacks(tagName, ctor) {
6355
- const resolvers = pendingWhenDefinedCallbacks.get(tagName);
6356
- if (!isUndefined$1(resolvers)) {
6357
- for (const resolver of resolvers) {
6358
- resolver(ctor);
6359
- }
6360
- }
6361
- pendingWhenDefinedCallbacks.delete(tagName);
6362
- }
6363
- const { customElements: nativeRegistry } = window;
6364
- const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
6365
- // patch for the global registry define mechanism
6366
- CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
6367
- if (options && options.extends) {
6368
- // TODO [#2983]: should we support `extends`?
6369
- throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
6370
- }
6371
- if (globalDefinitionsByTag.has(tagName)) {
6372
- throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`);
6373
- }
6374
- if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
6375
- throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`);
6376
- }
6377
- const definition = getOrCreateDefinitionForConstructor(constructor);
6378
- registeredUserCtors.add(constructor);
6379
- let PivotCtor = pivotCtorByTag.get(tagName);
6380
- if (isUndefined$1(PivotCtor)) {
6381
- PivotCtor = createPivotingClass(tagName, definition);
6382
- // Register a pivoting class which will handle global registry initializations
6383
- nativeDefine.call(nativeRegistry, tagName, PivotCtor);
6384
- }
6385
- // Only cache after nativeDefine has been called, because if it throws an error
6386
- // (e.g. for an invalid tag name), then we don't want to cache anything.
6387
- definitionForConstructor.set(constructor, definition);
6388
- pivotCtorByTag.set(tagName, PivotCtor);
6389
- globalDefinitionsByTag.set(tagName, definition);
6390
- globalDefinitionsByClass.set(constructor, definition);
6391
- // For globally defined custom elements, the definition associated
6392
- // to the UserCtor has a back-pointer to PivotCtor in case the user
6393
- // new the UserCtor, so we know how to create the underlying element.
6394
- definition.PivotCtor = PivotCtor;
6395
- // Upgrade any elements created in this scope before customElements.define
6396
- // was called, which should be exhibited by the following steps:
6397
- // 1) LWC registers a tagName for an LWC component.
6398
- // 2) Element with same tagName is created with document.createElement()
6399
- // and inserted into DOM.
6400
- // 3) customElements.define() is called with tagName and non-LWC constructor.
6401
- // This requires immediate upgrade when the new global tagName is defined.
6402
- const awaiting = awaitingUpgrade.get(tagName);
6403
- if (!isUndefined$1(awaiting)) {
6404
- awaitingUpgrade.delete(tagName);
6405
- for (const element of awaiting) {
6406
- const registeredDefinition = pendingRegistryForElement.get(element);
6407
- // At this point, registeredDefinition should never be undefined because awaitingUpgrade
6408
- // is only populated when we haven't run internalUpgrade yet, and we only populate
6409
- // pendingRegistryForElement when internalUpgrade hasn't run yet.
6410
- // But just to be safe, we check.
6411
- if (!isUndefined$1(registeredDefinition)) {
6412
- pendingRegistryForElement.delete(element);
6413
- internalUpgrade(element, registeredDefinition, definition);
6414
- }
6415
- }
6416
- }
6417
- // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
6418
- flushPendingWhenDefinedCallbacks(tagName, constructor);
6419
- };
6420
- CustomElementRegistry.prototype.get = function get(tagName) {
6421
- const NativeCtor = nativeGet.call(nativeRegistry, tagName);
6422
- if (!isUndefined$1(NativeCtor)) {
6423
- const definition = globalDefinitionsByTag.get(tagName);
6424
- if (!isUndefined$1(definition)) {
6425
- return definition.UserCtor; // defined by the patched custom elements registry
6426
- }
6427
- if (registeredPivotCtors.has(NativeCtor)) {
6428
- return undefined; // pivot constructors should not be observable, return undefined
6429
- }
6430
- return NativeCtor; // constructor that existed before patching
6431
- }
6432
- };
6433
- CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
6434
- return nativeWhenDefined.call(nativeRegistry, tagName).then((NativeCtor) => {
6435
- const definition = globalDefinitionsByTag.get(tagName);
6436
- if (!isUndefined$1(definition)) {
6437
- return definition.UserCtor;
6438
- }
6439
- // In this case, the custom element must have been defined before the registry patches
6440
- // were applied. So return the non-pivot constructor
6441
- if (isUndefined$1(NativeCtor)) {
6442
- // Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
6443
- // We can patch the correct behavior using customElements.get()
6444
- NativeCtor = nativeGet.call(nativeRegistry, tagName);
6445
- }
6446
- if (registeredPivotCtors.has(NativeCtor)) {
6447
- // Pivot constructors should not be observable. Wait to resolve the promise
6448
- // if a constructor is ever defined in userland
6449
- return createPendingWhenDefinedCallback(tagName);
6450
- }
6451
- return NativeCtor;
6452
- });
6453
- };
6454
- // This constructor is invoked when we call `new pivotDefinition.UserCtor()`
6455
- // @ts-ignore
6456
- window.HTMLElement = function HTMLElement() {
6457
- // Upgrading case: the pivoting class constructor was run by the browser's
6458
- // native custom elements and we're in the process of running the
6459
- // "constructor-call trick" on the natively constructed instance, so just
6460
- // return that here.
6461
- // This code path is also called when LWC `new`s a PivotCtor.
6462
- const instance = upgradingInstance;
6463
- if (!isUndefined$1(instance)) {
6464
- upgradingInstance = undefined;
6465
- return instance;
6466
- }
6467
- // Construction case: we need to construct the pivoting instance and return it.
6468
- // This is possible when the user register it via global registry and instantiate
6469
- // it via `new Ctor()`.
6470
- const { constructor } = this;
6471
- const definition = globalDefinitionsByClass.get(constructor);
6472
- if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
6473
- // This code path is hit if someone `new`s a class that extends `HTMLElement` without
6474
- // doing `customElements.define()` first. This matches native browser behavior:
6475
- // https://stackoverflow.com/a/61883392
6476
- throw new TypeError('Illegal constructor');
6477
- }
6478
- // This constructor is ONLY invoked when it is the user instantiating
6479
- // an element via new Ctor while Ctor is a registered global constructor.
6480
- const { PivotCtor, UserCtor } = definition;
6481
- return new PivotCtor(UserCtor);
6482
- };
6483
- HTMLElement.prototype = NativeHTMLElement.prototype;
6484
- /**
6485
- * Create a new PivotConstructor for the given tagName, which is capable of being constructed
6486
- * with a UserConstructor defining the behavior. Passing in the UserConstructor here
6487
- * is a hint that can be used when registering a custom element with the global custom elements
6488
- * registry for the first time, which provides certain optimizations. It also marks the UserConstructor
6489
- * as "safe" to be used when passed in to a PivotConstructor.
6490
- *
6491
- * @param tagName - element tag name
6492
- * @param UserCtor - userland custom element constructor
6493
- * @returns a new custom element constructor
6494
- */
6495
- return function createPivotConstructor(tagName, UserCtor) {
6496
- tagName = StringToLowerCase.call(tagName);
6497
- let PivotCtor = pivotCtorByTag.get(tagName);
6498
- if (isUndefined$1(PivotCtor)) {
6499
- const definition = getOrCreateDefinitionForConstructor(UserCtor);
6500
- PivotCtor = createPivotingClass(tagName, definition);
6501
- // Register a pivoting class as a global custom element
6502
- nativeDefine.call(nativeRegistry, tagName, PivotCtor);
6503
- definition.PivotCtor = PivotCtor;
6504
- // Only cache after nativeDefine has been called, because if it throws an error
6505
- // (e.g. for an invalid tag name), then we don't want to cache anything.
6506
- definitionForConstructor.set(UserCtor, definition);
6507
- pivotCtorByTag.set(tagName, PivotCtor);
6508
- }
6509
- // Register a UserConstructor as "safe" to be used within a PivotConstructor
6510
- registeredUserCtors.add(UserCtor);
6511
- return PivotCtor;
6512
- };
6513
- }
6514
-
6515
- /*
6516
- * Copyright (c) 2018, salesforce.com, inc.
6517
- * All rights reserved.
6518
- * SPDX-License-Identifier: MIT
6519
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6520
- */
6521
- let createScopedConstructor;
6522
- let CachedHTMLElement;
6523
- // We only call `createScopedRegistry()` if the browser supports custom elements and
6524
- // ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
6525
- // or we're in a legacy browser.
6526
- if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
6527
- if (hasCustomElements) {
6528
- // If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
6529
- // It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
6530
- //
6531
- // Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
6532
- //
6533
- // 1. LWC loads
6534
- // 2. `const Ctor = class extends HTMLElement {}`
6535
- // 3. `lwc.createElement(...)` // here we lazily patch
6536
- // 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
6537
- //
6538
- // To reduce the risk of this, it's safer to patch the registry eagerly.
6539
- createScopedConstructor = createScopedRegistry();
6540
- // It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
6541
- // another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
6542
- // because the HTMLElement prototypes are mixed up.
6543
- //
6544
- // The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
6545
- // with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
6546
- // the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
6547
- // Caching avoids this problem.
6548
- CachedHTMLElement = window.HTMLElement;
6549
- }
6550
- }
6551
- // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
6552
- // In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
6553
- // multiple times per tag name.
6554
- const createUserConstructor = (HTMLElementToExtend, upgradeCallback, connectedCallback, disconnectedCallback) => {
6555
- // TODO [#2972]: this class should expose observedAttributes as necessary
6556
- return class UserConstructor extends HTMLElementToExtend {
6557
- constructor() {
6558
- super();
6559
- upgradeCallback(this);
6560
- }
6561
- // Note that there is no need to do the "avoid defining connectedCallback/disconnectedCallback" optimization
6562
- // here, because in create-scoped-registry.ts, the registered class will always have these callbacks anyway.
6563
- // See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
6564
- connectedCallback() {
6565
- if (!isUndefined$1(connectedCallback)) {
6566
- connectedCallback(this);
6567
- }
6568
- }
6569
- disconnectedCallback() {
6570
- if (!isUndefined$1(disconnectedCallback)) {
6571
- disconnectedCallback(this);
6572
- }
6573
- }
6574
- };
6575
- };
6576
- function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
6577
- if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
6578
- // This error should be impossible to hit
6579
- throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
6580
- }
6581
- const UserConstructor = createUserConstructor(CachedHTMLElement, upgradeCallback, connectedCallback, disconnectedCallback);
6582
- const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
6583
- return new ScopedConstructor(UserConstructor);
6584
- }
6585
-
6586
6271
  /*
6587
6272
  * Copyright (c) 2018, salesforce.com, inc.
6588
6273
  * All rights reserved.
@@ -6590,29 +6275,22 @@
6590
6275
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6591
6276
  */
6592
6277
  /**
6593
- * We have three modes for creating custom elements:
6278
+ * We have two modes for creating custom elements:
6594
6279
  *
6595
6280
  * 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
6596
6281
  * 2. "Upgradable constructor" custom element. This allows us to have two LWC components with the same tag name,
6597
6282
  * via a trick: every custom element constructor we define in the registry is basically the same. It's essentially
6598
6283
  * a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its constructor ("upgradable
6599
6284
  * constructor"), which allows us to have completely customized functionality for different components.
6600
- * 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
6601
- * elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
6602
- * between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
6603
- * because it must patch the global `customElements` and `HTMLElement` objects.
6604
6285
  */
6605
6286
  let createCustomElement;
6606
6287
  if (hasCustomElements) {
6607
- if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
6608
- createCustomElement = createCustomElementScoped;
6609
- } else {
6610
6288
  // use the global registry, with an upgradable constructor for the defined custom element
6611
6289
  createCustomElement = createCustomElementUsingUpgradableConstructor;
6612
- }
6613
- } else {
6614
- // no registry available here
6615
- createCustomElement = createCustomElementCompat;
6290
+ }
6291
+ else {
6292
+ // no registry available here
6293
+ createCustomElement = createCustomElementCompat;
6616
6294
  }
6617
6295
 
6618
6296
  /*
@@ -6675,7 +6353,7 @@
6675
6353
  function isNull(obj) {
6676
6354
  return obj === null;
6677
6355
  }
6678
- /** version: 2.35.2 */
6356
+ /** version: 2.37.0 */
6679
6357
 
6680
6358
  /*
6681
6359
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7228,7 +6906,7 @@
7228
6906
  });
7229
6907
  freeze(LightningElement);
7230
6908
  seal(LightningElement.prototype);
7231
- /* version: 2.35.2 */
6909
+ /* version: 2.37.0 */
7232
6910
 
7233
6911
  exports.LightningElement = LightningElement;
7234
6912
  exports.__unstable__ProfilerControl = profilerControl;