lwc 2.35.2 → 2.36.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 +245 -89
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +245 -89
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +273 -45
  5. package/dist/engine-dom/iife/es5/engine-dom.js +402 -232
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +449 -161
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +245 -89
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +273 -45
  11. package/dist/engine-dom/umd/es5/engine-dom.js +402 -232
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +449 -161
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +124 -77
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +124 -77
  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.36.0 */
328
328
 
329
329
  /**
330
330
  * Copyright (C) 2018 salesforce.com, inc.
@@ -392,7 +392,7 @@
392
392
  */
393
393
  function setFeatureFlagForTest(name, value) {
394
394
  }
395
- /** version: 2.35.2 */
395
+ /** version: 2.36.0 */
396
396
 
397
397
  /**
398
398
  * Copyright (C) 2018 salesforce.com, inc.
@@ -456,7 +456,7 @@
456
456
  }
457
457
  }
458
458
  }
459
- /** version: 2.35.2 */
459
+ /** version: 2.36.0 */
460
460
 
461
461
  /*
462
462
  * Copyright (c) 2018, salesforce.com, inc.
@@ -476,7 +476,6 @@
476
476
  * SPDX-License-Identifier: MIT
477
477
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
478
478
  */
479
- /** Callbacks to invoke when reporting is enabled **/
480
479
  const onReportingEnabledCallbacks = [];
481
480
  /** The currently assigned reporting dispatcher. */
482
481
  let currentDispatcher$1 = noop;
@@ -534,11 +533,11 @@
534
533
  /**
535
534
  * Report to the current dispatcher, if there is one.
536
535
  * @param reportingEventId
537
- * @param vm
536
+ * @param payload - data to report
538
537
  */
539
- function report(reportingEventId, vm) {
538
+ function report(reportingEventId, payload) {
540
539
  if (enabled$1) {
541
- currentDispatcher$1(reportingEventId, vm.tagName, vm.idx);
540
+ currentDispatcher$1(reportingEventId, payload);
542
541
  }
543
542
  }
544
543
 
@@ -784,7 +783,7 @@
784
783
  // Make a shallow copy of an object but omit the given key
785
784
  function cloneAndOmitKey(object, keyToOmit) {
786
785
  const result = {};
787
- for (const key of Object.keys(object)) {
786
+ for (const key of keys(object)) {
788
787
  if (key !== keyToOmit) {
789
788
  result[key] = object[key];
790
789
  }
@@ -794,7 +793,7 @@
794
793
  function flattenStylesheets(stylesheets) {
795
794
  const list = [];
796
795
  for (const stylesheet of stylesheets) {
797
- if (!Array.isArray(stylesheet)) {
796
+ if (!isArray$1(stylesheet)) {
798
797
  list.push(stylesheet);
799
798
  }
800
799
  else {
@@ -3759,7 +3758,12 @@
3759
3758
  } else if (isVScopedSlotFragment(vnode)) {
3760
3759
  slotName = vnode.slotName;
3761
3760
  }
3762
- const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
3761
+ // Can't use toString here because Symbol(1).toString() is 'Symbol(1)'
3762
+ // but elm.setAttribute('slot', Symbol(1)) is an error.
3763
+ // the following line also throws same error for symbols
3764
+ // Similar for Object.create(null)
3765
+ const normalizedSlotName = '' + slotName;
3766
+ const vnodes = cmpSlotsMapping[normalizedSlotName] = cmpSlotsMapping[normalizedSlotName] || [];
3763
3767
  ArrayPush$1.call(vnodes, vnode);
3764
3768
  }
3765
3769
  vm.cmpSlots = {
@@ -5192,7 +5196,7 @@
5192
5196
  function isSyntheticShadowRootInstance(rootNode) {
5193
5197
  return rootNode !== document && isTrue(rootNode.synthetic);
5194
5198
  }
5195
- function reportViolation(source, target, attrName) {
5199
+ function reportViolation$1(source, target, attrName) {
5196
5200
  // The vm is either for the source, the target, or both. Either one or both must be using synthetic
5197
5201
  // shadow for a violation to be detected.
5198
5202
  let vm = getAssociatedVMIfPresent(source.getRootNode().host);
@@ -5203,7 +5207,10 @@
5203
5207
  // vm should never be undefined here, but just to be safe, bail out and don't report
5204
5208
  return;
5205
5209
  }
5206
- report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, vm);
5210
+ report(0 /* ReportingEventId.CrossRootAriaInSyntheticShadow */, {
5211
+ tagName: vm.tagName,
5212
+ attributeName: attrName,
5213
+ });
5207
5214
  }
5208
5215
  function parseIdRefAttributeValue(attrValue) {
5209
5216
  // split on whitespace and skip empty strings after splitting
@@ -5229,7 +5236,7 @@
5229
5236
  const sourceElement = sourceElements[i];
5230
5237
  const sourceRoot = sourceElement.getRootNode();
5231
5238
  if (sourceRoot !== root) {
5232
- reportViolation(sourceElement, elm);
5239
+ reportViolation$1(sourceElement, elm, idRefAttrName);
5233
5240
  break;
5234
5241
  }
5235
5242
  }
@@ -5244,7 +5251,7 @@
5244
5251
  const targetRoot = target.getRootNode();
5245
5252
  if (targetRoot !== root) {
5246
5253
  // target element's shadow root is not the same as ours
5247
- reportViolation(elm, target);
5254
+ reportViolation$1(elm, target, attrName);
5248
5255
  }
5249
5256
  }
5250
5257
  }
@@ -5253,7 +5260,7 @@
5253
5260
  let enabled = false;
5254
5261
  // We want to avoid patching globals whenever possible, so this should be tree-shaken out in prod-mode and if
5255
5262
  // reporting is not enabled. It should also only run once
5256
- function enableDetection() {
5263
+ function enableDetection$1() {
5257
5264
  if (enabled) {
5258
5265
  return; // don't double-apply the patches
5259
5266
  }
@@ -5306,10 +5313,94 @@
5306
5313
  // Always run detection in dev mode, so we can at least print to the console
5307
5314
  {
5308
5315
  // In prod mode, only enable detection if reporting is enabled
5309
- onReportingEnabled(enableDetection);
5316
+ onReportingEnabled(enableDetection$1);
5310
5317
  }
5311
5318
  }
5312
5319
 
5320
+ /*
5321
+ * Copyright (c) 2018, salesforce.com, inc.
5322
+ * All rights reserved.
5323
+ * SPDX-License-Identifier: MIT
5324
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5325
+ */
5326
+ //
5327
+ // The goal of this code is to detect usages of non-standard reflected ARIA properties. These are caused by
5328
+ // legacy non-standard Element.prototype extensions added by the @lwc/aria-reflection package.
5329
+ //
5330
+ // See the README for @lwc/aria-reflection
5331
+ const NON_STANDARD_ARIA_PROPS = ['ariaActiveDescendant', 'ariaControls', 'ariaDescribedBy', 'ariaDetails', 'ariaErrorMessage', 'ariaFlowTo', 'ariaLabelledBy', 'ariaOwns'];
5332
+ function isLightningElement(elm) {
5333
+ // The former case is for `this.prop` (inside component) and the latter is for `element.prop` (outside component).
5334
+ // In both cases, we apply the non-standard prop even when the global polyfill is disabled, so this is kosher.
5335
+ return elm instanceof LightningElement || elm instanceof BaseBridgeElement;
5336
+ }
5337
+ function findVM(elm) {
5338
+ // If it's a shadow DOM component, then it has a host
5339
+ const {
5340
+ host
5341
+ } = elm.getRootNode();
5342
+ const vm = isUndefined$1(host) ? undefined : getAssociatedVMIfPresent(host);
5343
+ if (!isUndefined$1(vm)) {
5344
+ return vm;
5345
+ }
5346
+ // Else it might be a light DOM component. Walk up the tree trying to find the owner
5347
+ let parentElement = elm;
5348
+ while (!isNull(parentElement = parentElement.parentElement)) {
5349
+ if (isLightningElement(parentElement)) {
5350
+ const vm = getAssociatedVMIfPresent(parentElement);
5351
+ if (!isUndefined$1(vm)) {
5352
+ return vm;
5353
+ }
5354
+ }
5355
+ }
5356
+ // If we return undefined, it's because the element was rendered wholly outside a LightningElement
5357
+ }
5358
+
5359
+ function checkAndReportViolation(elm, prop) {
5360
+ if (!isLightningElement(elm)) {
5361
+ const vm = findVM(elm);
5362
+ report(2 /* ReportingEventId.NonStandardAriaReflection */, {
5363
+ tagName: vm === null || vm === void 0 ? void 0 : vm.tagName,
5364
+ propertyName: prop
5365
+ });
5366
+ }
5367
+ }
5368
+ function enableDetection() {
5369
+ const {
5370
+ prototype
5371
+ } = Element;
5372
+ for (const prop of NON_STANDARD_ARIA_PROPS) {
5373
+ const descriptor = getOwnPropertyDescriptor$1(prototype, prop);
5374
+ // @ts-ignore
5375
+ const {
5376
+ get,
5377
+ set
5378
+ } = descriptor;
5379
+ defineProperty(prototype, prop, {
5380
+ get() {
5381
+ checkAndReportViolation(this, prop);
5382
+ return get.call(this);
5383
+ },
5384
+ set(val) {
5385
+ checkAndReportViolation(this, prop);
5386
+ return set.call(this, val);
5387
+ },
5388
+ configurable: true,
5389
+ enumerable: true
5390
+ });
5391
+ }
5392
+ }
5393
+ // No point in running this code if we're not in a browser, or if the global polyfill is not loaded
5394
+ {
5395
+ if (!lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
5396
+ // Always run detection in dev mode, so we can at least print to the console
5397
+ {
5398
+ // In prod mode, only enable detection if reporting is enabled
5399
+ onReportingEnabled(enableDetection);
5400
+ }
5401
+ }
5402
+ }
5403
+
5313
5404
  /*
5314
5405
  * Copyright (c) 2018, salesforce.com, inc.
5315
5406
  * All rights reserved.
@@ -5714,6 +5805,97 @@
5714
5805
  hooksAreSet = true;
5715
5806
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5716
5807
  }
5808
+
5809
+ /*
5810
+ * Copyright (c) 2018, salesforce.com, inc.
5811
+ * All rights reserved.
5812
+ * SPDX-License-Identifier: MIT
5813
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5814
+ */
5815
+ // See @lwc/engine-core/src/framework/template.ts
5816
+ const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
5817
+ // Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
5818
+ const STYLESHEET_PROPS = [
5819
+ // SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
5820
+ '$scoped$'];
5821
+ // Via https://www.npmjs.com/package/object-observer
5822
+ const ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
5823
+ let mutationTrackingDisabled = false;
5824
+ function getOriginalArrayMethod(prop) {
5825
+ switch (prop) {
5826
+ case 'pop':
5827
+ return ArrayPop;
5828
+ case 'push':
5829
+ return ArrayPush$1;
5830
+ case 'shift':
5831
+ return ArrayShift;
5832
+ case 'unshift':
5833
+ return ArrayUnshift;
5834
+ case 'reverse':
5835
+ return ArrayReverse;
5836
+ case 'sort':
5837
+ return ArraySort;
5838
+ case 'fill':
5839
+ return ArrayFill;
5840
+ case 'splice':
5841
+ return ArraySplice;
5842
+ case 'copyWithin':
5843
+ return ArrayCopyWithin;
5844
+ }
5845
+ }
5846
+ function reportViolation(type, eventId, prop) {
5847
+ report(eventId, {
5848
+ propertyName: prop
5849
+ });
5850
+ }
5851
+ function reportTemplateViolation(prop) {
5852
+ reportViolation('template', 3 /* ReportingEventId.TemplateMutation */, prop);
5853
+ }
5854
+ function reportStylesheetViolation(prop) {
5855
+ reportViolation('stylesheet', 4 /* ReportingEventId.StylesheetMutation */, prop);
5856
+ }
5857
+ // Warn if the user tries to mutate a stylesheets array, e.g.:
5858
+ // `tmpl.stylesheets.push(someStylesheetFunction)`
5859
+ function warnOnArrayMutation(stylesheets) {
5860
+ // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
5861
+ // we can at least warn when they use the most common mutation methods.
5862
+ for (const prop of ARRAY_MUTATION_METHODS) {
5863
+ const originalArrayMethod = getOriginalArrayMethod(prop);
5864
+ stylesheets[prop] = function arrayMutationWarningWrapper() {
5865
+ reportTemplateViolation('stylesheets');
5866
+ // @ts-ignore
5867
+ return originalArrayMethod.apply(this, arguments);
5868
+ };
5869
+ }
5870
+ }
5871
+ // Warn if the user tries to mutate a stylesheet factory function, e.g.:
5872
+ // `stylesheet.$scoped$ = true`
5873
+ function warnOnStylesheetFunctionMutation(stylesheet) {
5874
+ for (const prop of STYLESHEET_PROPS) {
5875
+ let value = stylesheet[prop];
5876
+ defineProperty(stylesheet, prop, {
5877
+ enumerable: true,
5878
+ configurable: true,
5879
+ get() {
5880
+ return value;
5881
+ },
5882
+ set(newValue) {
5883
+ reportStylesheetViolation(prop);
5884
+ value = newValue;
5885
+ }
5886
+ });
5887
+ }
5888
+ }
5889
+ // Warn on either array or stylesheet (function) mutation, in a deeply-nested array
5890
+ function trackStylesheetsMutation(stylesheets) {
5891
+ traverseStylesheets(stylesheets, subStylesheets => {
5892
+ if (isArray$1(subStylesheets)) {
5893
+ warnOnArrayMutation(subStylesheets);
5894
+ } else {
5895
+ warnOnStylesheetFunctionMutation(subStylesheets);
5896
+ }
5897
+ });
5898
+ }
5717
5899
  // Deeply freeze the entire array (of arrays) of stylesheet factory functions
5718
5900
  function deepFreeze(stylesheets) {
5719
5901
  traverseStylesheets(stylesheets, subStylesheets => {
@@ -5732,7 +5914,70 @@
5732
5914
  }
5733
5915
  }
5734
5916
  }
5917
+ function trackMutations(tmpl) {
5918
+ if (!isUndefined$1(tmpl.stylesheets)) {
5919
+ trackStylesheetsMutation(tmpl.stylesheets);
5920
+ }
5921
+ for (const prop of TEMPLATE_PROPS) {
5922
+ let value = tmpl[prop];
5923
+ defineProperty(tmpl, prop, {
5924
+ enumerable: true,
5925
+ configurable: true,
5926
+ get() {
5927
+ return value;
5928
+ },
5929
+ set(newValue) {
5930
+ if (!mutationTrackingDisabled) {
5931
+ reportTemplateViolation(prop);
5932
+ }
5933
+ value = newValue;
5934
+ }
5935
+ });
5936
+ }
5937
+ const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
5938
+ defineProperty(tmpl, 'stylesheetTokens', {
5939
+ enumerable: true,
5940
+ configurable: true,
5941
+ get: originalDescriptor.get,
5942
+ set(value) {
5943
+ reportTemplateViolation('stylesheetTokens');
5944
+ // Avoid logging/reporting twice (for both stylesheetToken and stylesheetTokens)
5945
+ mutationTrackingDisabled = true;
5946
+ originalDescriptor.set.call(this, value);
5947
+ mutationTrackingDisabled = false;
5948
+ }
5949
+ });
5950
+ }
5951
+ function addLegacyStylesheetTokensShim(tmpl) {
5952
+ // When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
5953
+ // is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
5954
+ defineProperty(tmpl, 'stylesheetTokens', {
5955
+ enumerable: true,
5956
+ configurable: true,
5957
+ get() {
5958
+ const {
5959
+ stylesheetToken
5960
+ } = this;
5961
+ if (isUndefined$1(stylesheetToken)) {
5962
+ return stylesheetToken;
5963
+ }
5964
+ // Shim for the old `stylesheetTokens` property
5965
+ // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
5966
+ return {
5967
+ hostAttribute: `${stylesheetToken}-host`,
5968
+ shadowAttribute: stylesheetToken
5969
+ };
5970
+ },
5971
+ set(value) {
5972
+ // If the value is null or some other exotic object, you would be broken anyway in the past
5973
+ // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
5974
+ // However it may be undefined in newer versions of LWC, so we need to guard against that case.
5975
+ this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
5976
+ }
5977
+ });
5978
+ }
5735
5979
  function freezeTemplate(tmpl) {
5980
+ // TODO [#2782]: remove this flag and delete the legacy behavior
5736
5981
  if (lwcRuntimeFlags.ENABLE_FROZEN_TEMPLATE) {
5737
5982
  // Deep freeze the template
5738
5983
  freeze(tmpl);
@@ -5740,33 +5985,16 @@
5740
5985
  deepFreeze(tmpl.stylesheets);
5741
5986
  }
5742
5987
  } 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
- });
5988
+ // template is not frozen - shim, report, and warn
5989
+ // this shim should be applied in both dev and prod
5990
+ addLegacyStylesheetTokensShim(tmpl);
5991
+ // When ENABLE_FROZEN_TEMPLATE is false, we want to warn in dev mode whenever someone is mutating the template
5992
+ {
5993
+ // In prod mode, we only track mutations if reporting is enabled
5994
+ onReportingEnabled(() => {
5995
+ trackMutations(tmpl);
5996
+ });
5997
+ }
5770
5998
  }
5771
5999
  }
5772
6000
 
@@ -6675,7 +6903,7 @@
6675
6903
  function isNull(obj) {
6676
6904
  return obj === null;
6677
6905
  }
6678
- /** version: 2.35.2 */
6906
+ /** version: 2.36.0 */
6679
6907
 
6680
6908
  /*
6681
6909
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7228,7 +7456,7 @@
7228
7456
  });
7229
7457
  freeze(LightningElement);
7230
7458
  seal(LightningElement.prototype);
7231
- /* version: 2.35.2 */
7459
+ /* version: 2.36.0 */
7232
7460
 
7233
7461
  exports.LightningElement = LightningElement;
7234
7462
  exports.__unstable__ProfilerControl = profilerControl;