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