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
@@ -442,9 +442,9 @@ function htmlEscape(str, attrMode = false) {
442
442
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
443
443
  */
444
444
  // Increment whenever the LWC template compiler changes
445
- const LWC_VERSION = "2.35.2";
445
+ const LWC_VERSION = "2.37.0";
446
446
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
447
- /** version: 2.35.2 */
447
+ /** version: 2.37.0 */
448
448
 
449
449
  /*
450
450
  * Copyright (c) 2020, salesforce.com, inc.
@@ -496,10 +496,8 @@ const features = {
496
496
  ENABLE_WIRE_SYNC_EMIT: null,
497
497
  ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
498
498
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
499
- ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
500
499
  ENABLE_FROZEN_TEMPLATE: null,
501
500
  DISABLE_ARIA_REFLECTION_POLYFILL: null,
502
- ENABLE_PROGRAMMATIC_STYLESHEETS: null,
503
501
  };
504
502
  if (!_globalThis.lwcRuntimeFlags) {
505
503
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
@@ -555,7 +553,7 @@ function setFeatureFlagForTest(name, value) {
555
553
  setFeatureFlag(name, value);
556
554
  }
557
555
  }
558
- /** version: 2.35.2 */
556
+ /** version: 2.37.0 */
559
557
 
560
558
  /**
561
559
  * Copyright (C) 2018 salesforce.com, inc.
@@ -619,7 +617,7 @@ function applyAriaReflection(prototype = Element.prototype) {
619
617
  }
620
618
  }
621
619
  }
622
- /** version: 2.35.2 */
620
+ /** version: 2.37.0 */
623
621
 
624
622
  /* proxy-compat-disable */
625
623
 
@@ -734,6 +732,9 @@ function log(method, message, vm, once) {
734
732
  function logError(message, vm) {
735
733
  log('error', message, vm, false);
736
734
  }
735
+ function logWarnOnce(message, vm) {
736
+ log('warn', message, vm, true);
737
+ }
737
738
 
738
739
  /*
739
740
  * Copyright (c) 2019, salesforce.com, inc.
@@ -792,7 +793,7 @@ function guid() {
792
793
  function flattenStylesheets(stylesheets) {
793
794
  const list = [];
794
795
  for (const stylesheet of stylesheets) {
795
- if (!Array.isArray(stylesheet)) {
796
+ if (!isArray$1(stylesheet)) {
796
797
  list.push(stylesheet);
797
798
  }
798
799
  else {
@@ -4616,7 +4617,12 @@ function allocateInSlot(vm, children, owner) {
4616
4617
  } else if (isVScopedSlotFragment(vnode)) {
4617
4618
  slotName = vnode.slotName;
4618
4619
  }
4619
- const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
4620
+ // Can't use toString here because Symbol(1).toString() is 'Symbol(1)'
4621
+ // but elm.setAttribute('slot', Symbol(1)) is an error.
4622
+ // the following line also throws same error for symbols
4623
+ // Similar for Object.create(null)
4624
+ const normalizedSlotName = '' + slotName;
4625
+ const vnodes = cmpSlotsMapping[normalizedSlotName] = cmpSlotsMapping[normalizedSlotName] || [];
4620
4626
  ArrayPush$1.call(vnodes, vnode);
4621
4627
  }
4622
4628
  vm.cmpSlots = {
@@ -5643,6 +5649,8 @@ function registerComponent(
5643
5649
  Ctor, { tmpl }) {
5644
5650
  if (isFunction$1(Ctor)) {
5645
5651
  if (process.env.NODE_ENV !== 'production') {
5652
+ // There is no point in running this in production, because the version mismatch check relies
5653
+ // on code comments which are stripped out in production by minifiers
5646
5654
  checkVersionMismatch(Ctor, 'component');
5647
5655
  }
5648
5656
  signedTemplateMap.set(Ctor, tmpl);
@@ -5901,20 +5909,37 @@ function validateComponentStylesheets(vm, stylesheets) {
5901
5909
  }
5902
5910
  // Validate and flatten any stylesheets defined as `static stylesheets`
5903
5911
  function computeStylesheets(vm, ctor) {
5904
- if (lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
5905
- const {
5912
+ warnOnStylesheetsMutation(ctor);
5913
+ const {
5914
+ stylesheets
5915
+ } = ctor;
5916
+ if (!isUndefined$1(stylesheets)) {
5917
+ const valid = validateComponentStylesheets(vm, stylesheets);
5918
+ if (valid) {
5919
+ return flattenStylesheets(stylesheets);
5920
+ } else if (process.env.NODE_ENV !== 'production') {
5921
+ logError(`static stylesheets must be an array of CSS stylesheets. Found invalid stylesheets on <${vm.tagName}>`, vm);
5922
+ }
5923
+ }
5924
+ return null;
5925
+ }
5926
+ function warnOnStylesheetsMutation(ctor) {
5927
+ if (process.env.NODE_ENV !== 'production') {
5928
+ let {
5906
5929
  stylesheets
5907
5930
  } = ctor;
5908
- if (!isUndefined$1(stylesheets)) {
5909
- const valid = validateComponentStylesheets(vm, stylesheets);
5910
- if (valid) {
5911
- return flattenStylesheets(stylesheets);
5912
- } else if (process.env.NODE_ENV !== 'production') {
5913
- logError(`static stylesheets must be an array of CSS stylesheets. Found invalid stylesheets on <${vm.tagName}>`, vm);
5931
+ defineProperty(ctor, 'stylesheets', {
5932
+ enumerable: true,
5933
+ configurable: true,
5934
+ get() {
5935
+ return stylesheets;
5936
+ },
5937
+ set(newValue) {
5938
+ logWarnOnce(`Dynamically setting the "stylesheets" static property on ${ctor.name} ` + 'will not affect the stylesheets injected.');
5939
+ stylesheets = newValue;
5914
5940
  }
5915
- }
5941
+ });
5916
5942
  }
5917
- return null;
5918
5943
  }
5919
5944
  function computeShadowMode(vm, renderer) {
5920
5945
  const {
@@ -6279,12 +6304,13 @@ function setHooks(hooks) {
6279
6304
  */
6280
6305
  // See @lwc/engine-core/src/framework/template.ts
6281
6306
  const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
6282
- // Via https://www.npmjs.com/package/object-observer
6283
- const ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
6284
6307
  // Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
6285
- const STYLESHEET_FUNCTION_EXPANDOS = [
6308
+ const STYLESHEET_PROPS = [
6286
6309
  // SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
6287
6310
  '$scoped$'];
6311
+ // Via https://www.npmjs.com/package/object-observer
6312
+ const ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
6313
+ let mutationTrackingDisabled = false;
6288
6314
  function getOriginalArrayMethod(prop) {
6289
6315
  switch (prop) {
6290
6316
  case 'pop':
@@ -6307,7 +6333,17 @@ function getOriginalArrayMethod(prop) {
6307
6333
  return ArrayCopyWithin;
6308
6334
  }
6309
6335
  }
6310
- let mutationWarningsSilenced = false;
6336
+ function reportViolation(type, eventId, prop) {
6337
+ if (process.env.NODE_ENV !== 'production') {
6338
+ logWarnOnce(`Mutating the "${prop}" property on a ${type} ` + `is deprecated and will be removed in a future version of LWC. ` + `See: https://sfdc.co/template-mutation`);
6339
+ }
6340
+ }
6341
+ function reportTemplateViolation(prop) {
6342
+ reportViolation('template', 3 /* ReportingEventId.TemplateMutation */, prop);
6343
+ }
6344
+ function reportStylesheetViolation(prop) {
6345
+ reportViolation('stylesheet', 4 /* ReportingEventId.StylesheetMutation */, prop);
6346
+ }
6311
6347
  // Warn if the user tries to mutate a stylesheets array, e.g.:
6312
6348
  // `tmpl.stylesheets.push(someStylesheetFunction)`
6313
6349
  function warnOnArrayMutation(stylesheets) {
@@ -6316,7 +6352,7 @@ function warnOnArrayMutation(stylesheets) {
6316
6352
  for (const prop of ARRAY_MUTATION_METHODS) {
6317
6353
  const originalArrayMethod = getOriginalArrayMethod(prop);
6318
6354
  stylesheets[prop] = function arrayMutationWarningWrapper() {
6319
- logError(`Mutating the "stylesheets" array on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6355
+ reportTemplateViolation('stylesheets');
6320
6356
  // @ts-ignore
6321
6357
  return originalArrayMethod.apply(this, arguments);
6322
6358
  };
@@ -6325,8 +6361,7 @@ function warnOnArrayMutation(stylesheets) {
6325
6361
  // Warn if the user tries to mutate a stylesheet factory function, e.g.:
6326
6362
  // `stylesheet.$scoped$ = true`
6327
6363
  function warnOnStylesheetFunctionMutation(stylesheet) {
6328
- // We could warn on other properties, but in practice only certain expandos are meaningful to LWC at runtime
6329
- for (const prop of STYLESHEET_FUNCTION_EXPANDOS) {
6364
+ for (const prop of STYLESHEET_PROPS) {
6330
6365
  let value = stylesheet[prop];
6331
6366
  defineProperty(stylesheet, prop, {
6332
6367
  enumerable: true,
@@ -6335,14 +6370,14 @@ function warnOnStylesheetFunctionMutation(stylesheet) {
6335
6370
  return value;
6336
6371
  },
6337
6372
  set(newValue) {
6338
- logError(`Dynamically setting the "${prop}" property on a stylesheet function ` + `is deprecated and may be removed in a future version of LWC.`);
6373
+ reportStylesheetViolation(prop);
6339
6374
  value = newValue;
6340
6375
  }
6341
6376
  });
6342
6377
  }
6343
6378
  }
6344
6379
  // Warn on either array or stylesheet (function) mutation, in a deeply-nested array
6345
- function warnOnStylesheetsMutation(stylesheets) {
6380
+ function trackStylesheetsMutation(stylesheets) {
6346
6381
  traverseStylesheets(stylesheets, subStylesheets => {
6347
6382
  if (isArray$1(subStylesheets)) {
6348
6383
  warnOnArrayMutation(subStylesheets);
@@ -6369,7 +6404,70 @@ function traverseStylesheets(stylesheets, callback) {
6369
6404
  }
6370
6405
  }
6371
6406
  }
6407
+ function trackMutations(tmpl) {
6408
+ if (!isUndefined$1(tmpl.stylesheets)) {
6409
+ trackStylesheetsMutation(tmpl.stylesheets);
6410
+ }
6411
+ for (const prop of TEMPLATE_PROPS) {
6412
+ let value = tmpl[prop];
6413
+ defineProperty(tmpl, prop, {
6414
+ enumerable: true,
6415
+ configurable: true,
6416
+ get() {
6417
+ return value;
6418
+ },
6419
+ set(newValue) {
6420
+ if (!mutationTrackingDisabled) {
6421
+ reportTemplateViolation(prop);
6422
+ }
6423
+ value = newValue;
6424
+ }
6425
+ });
6426
+ }
6427
+ const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
6428
+ defineProperty(tmpl, 'stylesheetTokens', {
6429
+ enumerable: true,
6430
+ configurable: true,
6431
+ get: originalDescriptor.get,
6432
+ set(value) {
6433
+ reportTemplateViolation('stylesheetTokens');
6434
+ // Avoid logging/reporting twice (for both stylesheetToken and stylesheetTokens)
6435
+ mutationTrackingDisabled = true;
6436
+ originalDescriptor.set.call(this, value);
6437
+ mutationTrackingDisabled = false;
6438
+ }
6439
+ });
6440
+ }
6441
+ function addLegacyStylesheetTokensShim(tmpl) {
6442
+ // When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
6443
+ // is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
6444
+ defineProperty(tmpl, 'stylesheetTokens', {
6445
+ enumerable: true,
6446
+ configurable: true,
6447
+ get() {
6448
+ const {
6449
+ stylesheetToken
6450
+ } = this;
6451
+ if (isUndefined$1(stylesheetToken)) {
6452
+ return stylesheetToken;
6453
+ }
6454
+ // Shim for the old `stylesheetTokens` property
6455
+ // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
6456
+ return {
6457
+ hostAttribute: `${stylesheetToken}-host`,
6458
+ shadowAttribute: stylesheetToken
6459
+ };
6460
+ },
6461
+ set(value) {
6462
+ // If the value is null or some other exotic object, you would be broken anyway in the past
6463
+ // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
6464
+ // However it may be undefined in newer versions of LWC, so we need to guard against that case.
6465
+ this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
6466
+ }
6467
+ });
6468
+ }
6372
6469
  function freezeTemplate(tmpl) {
6470
+ // TODO [#2782]: remove this flag and delete the legacy behavior
6373
6471
  if (lwcRuntimeFlags.ENABLE_FROZEN_TEMPLATE) {
6374
6472
  // Deep freeze the template
6375
6473
  freeze(tmpl);
@@ -6377,71 +6475,16 @@ function freezeTemplate(tmpl) {
6377
6475
  deepFreeze(tmpl.stylesheets);
6378
6476
  }
6379
6477
  } else {
6380
- // TODO [#2782]: remove this flag and delete the legacy behavior
6381
- // When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
6382
- // is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
6383
- defineProperty(tmpl, 'stylesheetTokens', {
6384
- enumerable: true,
6385
- configurable: true,
6386
- get() {
6387
- const {
6388
- stylesheetToken
6389
- } = this;
6390
- if (isUndefined$1(stylesheetToken)) {
6391
- return stylesheetToken;
6392
- }
6393
- // Shim for the old `stylesheetTokens` property
6394
- // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
6395
- return {
6396
- hostAttribute: `${stylesheetToken}-host`,
6397
- shadowAttribute: stylesheetToken
6398
- };
6399
- },
6400
- set(value) {
6401
- // If the value is null or some other exotic object, you would be broken anyway in the past
6402
- // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
6403
- // However it may be undefined in newer versions of LWC, so we need to guard against that case.
6404
- this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
6405
- }
6406
- });
6407
- // When ENABLE_FROZEN_TEMPLATE is false, warn in dev mode whenever someone is mutating the template
6478
+ // template is not frozen - shim, report, and warn
6479
+ // this shim should be applied in both dev and prod
6480
+ addLegacyStylesheetTokensShim(tmpl);
6481
+ // When ENABLE_FROZEN_TEMPLATE is false, we want to warn in dev mode whenever someone is mutating the template
6408
6482
  if (process.env.NODE_ENV !== 'production') {
6409
- if (!isUndefined$1(tmpl.stylesheets)) {
6410
- warnOnStylesheetsMutation(tmpl.stylesheets);
6411
- }
6412
- for (const prop of TEMPLATE_PROPS) {
6413
- let value = tmpl[prop];
6414
- defineProperty(tmpl, prop, {
6415
- enumerable: true,
6416
- configurable: true,
6417
- get() {
6418
- return value;
6419
- },
6420
- set(newValue) {
6421
- if (!mutationWarningsSilenced) {
6422
- logError(`Dynamically setting the "${prop}" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6423
- }
6424
- value = newValue;
6425
- }
6426
- });
6427
- }
6428
- const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
6429
- defineProperty(tmpl, 'stylesheetTokens', {
6430
- enumerable: true,
6431
- configurable: true,
6432
- get: originalDescriptor.get,
6433
- set(value) {
6434
- logError(`Dynamically setting the "stylesheetTokens" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6435
- // Avoid logging twice (for both stylesheetToken and stylesheetTokens)
6436
- mutationWarningsSilenced = true;
6437
- originalDescriptor.set.call(this, value);
6438
- mutationWarningsSilenced = false;
6439
- }
6440
- });
6483
+ trackMutations(tmpl);
6441
6484
  }
6442
6485
  }
6443
6486
  }
6444
- /* version: 2.35.2 */
6487
+ /* version: 2.37.0 */
6445
6488
 
6446
6489
  /*
6447
6490
  * Copyright (c) 2020, salesforce.com, inc.
@@ -6493,7 +6536,7 @@ function unsupportedMethod(name) {
6493
6536
  throw new TypeError(`"${name}" is not supported in this environment`);
6494
6537
  };
6495
6538
  }
6496
- function createElement(tagName, namespace) {
6539
+ function createElement$1(tagName, namespace) {
6497
6540
  return {
6498
6541
  [HostTypeKey]: HostNodeType.Element,
6499
6542
  tagName,
@@ -6744,7 +6787,7 @@ const assertInstanceOfHTMLElement = noop;
6744
6787
  const localRegistryRecord = new Map();
6745
6788
  function createUpgradableElementConstructor(tagName) {
6746
6789
  return function Ctor(upgradeCallback) {
6747
- const elm = createElement(tagName);
6790
+ const elm = createElement$1(tagName);
6748
6791
  if (isFunction$1(upgradeCallback)) {
6749
6792
  upgradeCallback(elm); // nothing to do with the result for now
6750
6793
  }
@@ -6771,7 +6814,7 @@ const renderer = {
6771
6814
  remove,
6772
6815
  cloneNode,
6773
6816
  createFragment,
6774
- createElement,
6817
+ createElement: createElement$1,
6775
6818
  createText,
6776
6819
  createComment,
6777
6820
  createCustomElement,
@@ -6912,11 +6955,29 @@ function renderComponent(tagName, Ctor, props = {}) {
6912
6955
  */
6913
6956
  freeze(LightningElement);
6914
6957
  seal(LightningElement.prototype);
6915
- /* version: 2.35.2 */
6958
+
6959
+ /*
6960
+ * Copyright (c) 2018, salesforce.com, inc.
6961
+ * All rights reserved.
6962
+ * SPDX-License-Identifier: MIT
6963
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6964
+ */
6965
+ /**
6966
+ * This API is equivalent to the createElement function exposed by @lwc/engine-dom. It doesn't do anything on
6967
+ * the server side, however, you may import it.
6968
+ *
6969
+ * The whole point of defining this and exporting it is so that you can import it in isomorphic code without
6970
+ * an error being thrown by the import itself.
6971
+ */
6972
+ function createElement() {
6973
+ throw new Error('createElement is not supported in @lwc/engine-server, only @lwc/engine-dom.');
6974
+ }
6975
+ /* version: 2.37.0 */
6916
6976
 
6917
6977
  exports.LightningElement = LightningElement;
6918
6978
  exports.api = api$1;
6919
6979
  exports.createContextProvider = createContextProvider;
6980
+ exports.createElement = createElement;
6920
6981
  exports.freezeTemplate = freezeTemplate;
6921
6982
  exports.getComponentDef = getComponentDef;
6922
6983
  exports.isComponentConstructor = isComponentConstructor;