lwc 2.45.0 → 2.45.2

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 (66) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +158 -83
  2. package/dist/engine-dom/esm/es2017/engine-dom.js.map +1 -1
  3. package/dist/engine-dom/iife/es2017/engine-dom.js +158 -83
  4. package/dist/engine-dom/iife/es2017/engine-dom.js.map +1 -1
  5. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  6. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +75 -18
  7. package/dist/engine-dom/iife/es2017/engine-dom_debug.js.map +1 -1
  8. package/dist/engine-dom/iife/es5/engine-dom.js +162 -79
  9. package/dist/engine-dom/iife/es5/engine-dom.js.map +1 -1
  10. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  11. package/dist/engine-dom/iife/es5/engine-dom_debug.js +83 -16
  12. package/dist/engine-dom/iife/es5/engine-dom_debug.js.map +1 -1
  13. package/dist/engine-dom/umd/es2017/engine-dom.js +158 -83
  14. package/dist/engine-dom/umd/es2017/engine-dom.js.map +1 -1
  15. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  16. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +75 -18
  17. package/dist/engine-dom/umd/es2017/engine-dom_debug.js.map +1 -1
  18. package/dist/engine-dom/umd/es5/engine-dom.js +162 -79
  19. package/dist/engine-dom/umd/es5/engine-dom.js.map +1 -1
  20. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  21. package/dist/engine-dom/umd/es5/engine-dom_debug.js +83 -16
  22. package/dist/engine-dom/umd/es5/engine-dom_debug.js.map +1 -1
  23. package/dist/engine-server/commonjs/es2017/engine-server.js +102 -75
  24. package/dist/engine-server/commonjs/es2017/engine-server.js.map +1 -1
  25. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  26. package/dist/engine-server/esm/es2017/engine-server.js +102 -75
  27. package/dist/engine-server/esm/es2017/engine-server.js.map +1 -1
  28. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +4 -4
  29. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js.map +1 -1
  30. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +4 -4
  31. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js.map +1 -1
  32. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  33. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +4 -4
  34. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js.map +1 -1
  35. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  36. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js.map +1 -1
  37. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  38. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js.map +1 -1
  39. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +4 -4
  40. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js.map +1 -1
  41. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  42. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +4 -4
  43. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js.map +1 -1
  44. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  45. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js.map +1 -1
  46. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  47. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js.map +1 -1
  48. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  49. package/dist/wire-service/esm/es2017/wire-service.js.map +1 -1
  50. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  51. package/dist/wire-service/iife/es2017/wire-service.js.map +1 -1
  52. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  53. package/dist/wire-service/iife/es2017/wire-service_debug.js.map +1 -1
  54. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  55. package/dist/wire-service/iife/es5/wire-service.js.map +1 -1
  56. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  57. package/dist/wire-service/iife/es5/wire-service_debug.js.map +1 -1
  58. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  59. package/dist/wire-service/umd/es2017/wire-service.js.map +1 -1
  60. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  61. package/dist/wire-service/umd/es2017/wire-service_debug.js.map +1 -1
  62. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  63. package/dist/wire-service/umd/es5/wire-service.js.map +1 -1
  64. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  65. package/dist/wire-service/umd/es5/wire-service_debug.js.map +1 -1
  66. package/package.json +7 -7
@@ -49,7 +49,16 @@
49
49
  */
50
50
  const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor: getOwnPropertyDescriptor$1, getOwnPropertyNames: getOwnPropertyNames$1, getPrototypeOf: getPrototypeOf$1, hasOwnProperty: hasOwnProperty$1, isFrozen, keys, seal, setPrototypeOf, } = Object;
51
51
  const { isArray: isArray$1 } = Array;
52
- const { concat: ArrayConcat$1, copyWithin: ArrayCopyWithin, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
52
+ const { concat: ArrayConcat$1, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, } = Array.prototype;
53
+ // The type of the return value of Array.prototype.every is `this is T[]`. However, once this
54
+ // Array method is pulled out of the prototype, the function is now referencing `this` where
55
+ // `this` is meaningless, resulting in a TypeScript compilation error.
56
+ //
57
+ // Exposing this helper function is the closest we can get to preserving the usage patterns
58
+ // of Array.prototype methods used elsewhere in the codebase.
59
+ function arrayEvery(arr, predicate) {
60
+ return ArrayEvery.call(arr, predicate);
61
+ }
53
62
  const { fromCharCode: StringFromCharCode } = String;
54
63
  const { charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
55
64
  function isUndefined$1(obj) {
@@ -335,9 +344,9 @@
335
344
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
336
345
  */
337
346
  // Increment whenever the LWC template compiler changes
338
- const LWC_VERSION = "2.45.0";
347
+ const LWC_VERSION = "2.45.2";
339
348
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
340
- /** version: 2.45.0 */
349
+ /** version: 2.45.2 */
341
350
 
342
351
  /**
343
352
  * Copyright (C) 2018 salesforce.com, inc.
@@ -415,7 +424,7 @@
415
424
  setFeatureFlag(name, value);
416
425
  }
417
426
  }
418
- /** version: 2.45.0 */
427
+ /** version: 2.45.2 */
419
428
 
420
429
  /**
421
430
  * Copyright (C) 2018 salesforce.com, inc.
@@ -479,7 +488,7 @@
479
488
  }
480
489
  }
481
490
  }
482
- /** version: 2.45.0 */
491
+ /** version: 2.45.2 */
483
492
 
484
493
  /*
485
494
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1006,8 +1015,9 @@
1006
1015
  get() {
1007
1016
  return originalOuterHTMLDescriptor.get.call(this);
1008
1017
  },
1009
- set(_value) {
1010
- throw new TypeError(`Invalid attempt to set outerHTML on Element.`);
1018
+ set(value) {
1019
+ logError(`Invalid attempt to set outerHTML on Element.`);
1020
+ return originalOuterHTMLDescriptor.set.call(this, value);
1011
1021
  },
1012
1022
  }),
1013
1023
  };
@@ -1092,16 +1102,18 @@
1092
1102
  get() {
1093
1103
  return originalInnerHTMLDescriptor.get.call(this);
1094
1104
  },
1095
- set(_value) {
1096
- throw new TypeError(`Invalid attempt to set innerHTML on ShadowRoot.`);
1105
+ set(value) {
1106
+ logError(`Invalid attempt to set innerHTML on ShadowRoot.`);
1107
+ return originalInnerHTMLDescriptor.set.call(this, value);
1097
1108
  },
1098
1109
  }),
1099
1110
  textContent: generateAccessorDescriptor({
1100
1111
  get() {
1101
1112
  return originalTextContentDescriptor.get.call(this);
1102
1113
  },
1103
- set(_value) {
1104
- throw new TypeError(`Invalid attempt to set textContent on ShadowRoot.`);
1114
+ set(value) {
1115
+ logError(`Invalid attempt to set textContent on ShadowRoot.`);
1116
+ return originalTextContentDescriptor.set.call(this, value);
1105
1117
  },
1106
1118
  }),
1107
1119
  addEventListener: generateDataDescriptor({
@@ -1130,24 +1142,27 @@
1130
1142
  get() {
1131
1143
  return originalInnerHTMLDescriptor.get.call(this);
1132
1144
  },
1133
- set(_value) {
1134
- throw new TypeError(`Invalid attempt to set innerHTML on HTMLElement.`);
1145
+ set(value) {
1146
+ logError(`Invalid attempt to set innerHTML on HTMLElement.`);
1147
+ return originalInnerHTMLDescriptor.set.call(this, value);
1135
1148
  },
1136
1149
  }),
1137
1150
  outerHTML: generateAccessorDescriptor({
1138
1151
  get() {
1139
1152
  return originalOuterHTMLDescriptor.get.call(this);
1140
1153
  },
1141
- set(_value) {
1142
- throw new TypeError(`Invalid attempt to set outerHTML on HTMLElement.`);
1154
+ set(value) {
1155
+ logError(`Invalid attempt to set outerHTML on HTMLElement.`);
1156
+ return originalOuterHTMLDescriptor.set.call(this, value);
1143
1157
  },
1144
1158
  }),
1145
1159
  textContent: generateAccessorDescriptor({
1146
1160
  get() {
1147
1161
  return originalTextContentDescriptor.get.call(this);
1148
1162
  },
1149
- set(_value) {
1150
- throw new TypeError(`Invalid attempt to set textContent on HTMLElement.`);
1163
+ set(value) {
1164
+ logError(`Invalid attempt to set textContent on HTMLElement.`);
1165
+ return originalTextContentDescriptor.set.call(this, value);
1151
1166
  },
1152
1167
  }),
1153
1168
  addEventListener: generateDataDescriptor({
@@ -1163,20 +1178,6 @@
1163
1178
  }),
1164
1179
  };
1165
1180
  }
1166
- function getComponentRestrictionsDescriptors() {
1167
- assertNotProd(); // this method should never leak to prod
1168
- return {
1169
- tagName: generateAccessorDescriptor({
1170
- get() {
1171
- throw new Error(`Usage of property \`tagName\` is disallowed because the component itself does` +
1172
- ` not know which tagName will be used to create the element, therefore writing` +
1173
- ` code that check for that value is error prone.`);
1174
- },
1175
- configurable: true,
1176
- enumerable: false, // no enumerable properties on component
1177
- }),
1178
- };
1179
- }
1180
1181
  function getLightningElementPrototypeRestrictionsDescriptors(proto) {
1181
1182
  assertNotProd(); // this method should never leak to prod
1182
1183
  const originalDispatchEvent = proto.dispatchEvent;
@@ -1209,9 +1210,6 @@
1209
1210
  const elmProto = getPrototypeOf$1(elm);
1210
1211
  setPrototypeOf(elm, create(elmProto, restrictionsDescriptors));
1211
1212
  }
1212
- function patchComponentWithRestrictions(cmp) {
1213
- defineProperties(cmp, getComponentRestrictionsDescriptors());
1214
- }
1215
1213
  function patchLightningElementPrototypeWithRestrictions(proto) {
1216
1214
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1217
1215
  }
@@ -1822,16 +1820,10 @@
1822
1820
  function createBridgeToElementDescriptor(propName, descriptor) {
1823
1821
  const { get, set, enumerable, configurable } = descriptor;
1824
1822
  if (!isFunction$1(get)) {
1825
- if (process.env.NODE_ENV !== 'production') {
1826
- assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
1827
- }
1828
- throw new TypeError();
1823
+ throw new TypeError(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
1829
1824
  }
1830
1825
  if (!isFunction$1(set)) {
1831
- if (process.env.NODE_ENV !== 'production') {
1832
- assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
1833
- }
1834
- throw new TypeError();
1826
+ throw new TypeError(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
1835
1827
  }
1836
1828
  return {
1837
1829
  enumerable,
@@ -1851,10 +1843,18 @@
1851
1843
  const vm = getAssociatedVM(this);
1852
1844
  if (process.env.NODE_ENV !== 'production') {
1853
1845
  const vmBeingRendered = getVMBeingRendered();
1854
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
1855
- assert.invariant(!isUpdatingTemplate, `When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
1856
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1857
- assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1846
+ if (isInvokingRender) {
1847
+ logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
1848
+ }
1849
+ if (isUpdatingTemplate) {
1850
+ logError(`When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
1851
+ }
1852
+ if (isBeingConstructed(vm)) {
1853
+ logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1854
+ }
1855
+ if (isObject(newValue) && !isNull(newValue)) {
1856
+ logError(`Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1857
+ }
1858
1858
  }
1859
1859
  updateComponentValue(vm, propName, newValue);
1860
1860
  return set.call(vm.elm, newValue);
@@ -1907,7 +1907,6 @@
1907
1907
  // Adding extra guard rails in DEV mode.
1908
1908
  if (process.env.NODE_ENV !== 'production') {
1909
1909
  patchCustomElementWithRestrictions(elm);
1910
- patchComponentWithRestrictions(component);
1911
1910
  }
1912
1911
  return this;
1913
1912
  };
@@ -1943,9 +1942,15 @@
1943
1942
  const { elm, renderer: { addEventListener }, } = vm;
1944
1943
  if (process.env.NODE_ENV !== 'production') {
1945
1944
  const vmBeingRendered = getVMBeingRendered();
1946
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
1947
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
1948
- assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
1945
+ if (isInvokingRender) {
1946
+ logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
1947
+ }
1948
+ if (isUpdatingTemplate) {
1949
+ logError(`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
1950
+ }
1951
+ if (!isFunction$1(listener)) {
1952
+ logError(`Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
1953
+ }
1949
1954
  }
1950
1955
  const wrappedListener = getWrappedComponentsListener(vm, listener);
1951
1956
  addEventListener(elm, type, wrappedListener, options);
@@ -1995,7 +2000,9 @@
1995
2000
  const vm = getAssociatedVM(this);
1996
2001
  const { elm, renderer: { setAttribute }, } = vm;
1997
2002
  if (process.env.NODE_ENV !== 'production') {
1998
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2003
+ if (isBeingConstructed(vm)) {
2004
+ logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2005
+ }
1999
2006
  }
2000
2007
  unlockAttribute(elm, name);
2001
2008
  setAttribute(elm, name, value);
@@ -2005,7 +2012,9 @@
2005
2012
  const vm = getAssociatedVM(this);
2006
2013
  const { elm, renderer: { setAttribute }, } = vm;
2007
2014
  if (process.env.NODE_ENV !== 'production') {
2008
- assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2015
+ if (isBeingConstructed(vm)) {
2016
+ logError(`Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
2017
+ }
2009
2018
  }
2010
2019
  unlockAttribute(elm, name);
2011
2020
  setAttribute(elm, name, value, namespace);
@@ -2028,9 +2037,9 @@
2028
2037
  const vm = getAssociatedVM(this);
2029
2038
  const { elm, renderer: { getClassList }, } = vm;
2030
2039
  if (process.env.NODE_ENV !== 'production') {
2031
- // TODO [#1290]: this still fails in dev but works in production, eventually, we should
2032
- // just throw in all modes
2033
- assert.isFalse(isBeingConstructed(vm), `Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
2040
+ if (isBeingConstructed(vm)) {
2041
+ logError(`Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
2042
+ }
2034
2043
  }
2035
2044
  return getClassList(elm);
2036
2045
  },
@@ -2536,8 +2545,12 @@
2536
2545
  const vm = getAssociatedVM(this);
2537
2546
  if (process.env.NODE_ENV !== 'production') {
2538
2547
  const vmBeingRendered = getVMBeingRendered();
2539
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2540
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2548
+ if (isInvokingRender) {
2549
+ logError(`render() method has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2550
+ }
2551
+ if (isUpdatingTemplate) {
2552
+ logError(`Updating the template has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2553
+ }
2541
2554
  }
2542
2555
  vm.cmpProps[key] = newValue;
2543
2556
  componentValueMutated(vm, key);
@@ -2561,14 +2574,18 @@
2561
2574
  const vm = getAssociatedVM(this);
2562
2575
  if (process.env.NODE_ENV !== 'production') {
2563
2576
  const vmBeingRendered = getVMBeingRendered();
2564
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2565
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2577
+ if (isInvokingRender) {
2578
+ logError(`render() method has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2579
+ }
2580
+ if (isUpdatingTemplate) {
2581
+ logError(`Updating the template has side effects on the state of property "${toString$1(key)}"`, isNull(vmBeingRendered) ? vm : vmBeingRendered);
2582
+ }
2566
2583
  }
2567
2584
  if (set) {
2568
2585
  set.call(this, newValue);
2569
2586
  }
2570
2587
  else if (process.env.NODE_ENV !== 'production') {
2571
- assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
2588
+ logError(`Invalid attempt to set a new value for property "${toString$1(key)}" that does not has a setter decorated with @api.`, vm);
2572
2589
  }
2573
2590
  },
2574
2591
  enumerable,
@@ -2602,8 +2619,12 @@
2602
2619
  const vm = getAssociatedVM(this);
2603
2620
  if (process.env.NODE_ENV !== 'production') {
2604
2621
  const vmBeingRendered = getVMBeingRendered();
2605
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2606
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2622
+ if (isInvokingRender) {
2623
+ logError(`${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2624
+ }
2625
+ if (isUpdatingTemplate) {
2626
+ logError(`Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2627
+ }
2607
2628
  }
2608
2629
  const reactiveOrAnyValue = getReactiveProxy(newValue);
2609
2630
  updateComponentValue(vm, key, reactiveOrAnyValue);
@@ -3380,13 +3401,20 @@
3380
3401
  const ctorName = Ctor.name;
3381
3402
  // Removing the following assert until https://bugs.webkit.org/show_bug.cgi?id=190140 is fixed.
3382
3403
  // assert.isTrue(ctorName && isString(ctorName), `${toString(Ctor)} should have a "name" property with string value, but found ${ctorName}.`);
3383
- assert.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
3384
- if (!isUndefined$1(ctorShadowSupportMode)) {
3385
- assert.invariant(ctorShadowSupportMode === "any" /* ShadowSupportMode.Any */ ||
3386
- ctorShadowSupportMode === "reset" /* ShadowSupportMode.Default */, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
3404
+ if (!Ctor.constructor) {
3405
+ // This error seems impossible to hit, due to an earlier check in `isComponentConstructor()`.
3406
+ // But we keep it here just in case.
3407
+ logError(`Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
3408
+ }
3409
+ if (!isUndefined$1(ctorShadowSupportMode) &&
3410
+ ctorShadowSupportMode !== "any" /* ShadowSupportMode.Any */ &&
3411
+ ctorShadowSupportMode !== "reset" /* ShadowSupportMode.Default */) {
3412
+ logError(`Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
3387
3413
  }
3388
- if (!isUndefined$1(ctorRenderMode)) {
3389
- assert.invariant(ctorRenderMode === 'light' || ctorRenderMode === 'shadow', `Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
3414
+ if (!isUndefined$1(ctorRenderMode) &&
3415
+ ctorRenderMode !== 'light' &&
3416
+ ctorRenderMode !== 'shadow') {
3417
+ logError(`Invalid value for static property renderMode: '${ctorRenderMode}'. renderMode must be either 'light' or 'shadow'.`);
3390
3418
  }
3391
3419
  }
3392
3420
  const decoratorsMeta = getDecoratorsMeta(Ctor);
@@ -5163,7 +5191,7 @@
5163
5191
  return compilerKey + ':' + obj;
5164
5192
  case 'object':
5165
5193
  if (process.env.NODE_ENV !== 'production') {
5166
- assert.fail(`Invalid key value "${obj}" in ${getVMBeingRendered()}. Key must be a string or number.`);
5194
+ logError(`Invalid key value "${obj}" in ${getVMBeingRendered()}. Key must be a string or number.`);
5167
5195
  }
5168
5196
  }
5169
5197
  }
@@ -5453,13 +5481,19 @@
5453
5481
  }
5454
5482
  }
5455
5483
  function validateLightDomTemplate(template, vm) {
5456
- if (template === defaultEmptyTemplate)
5484
+ assertNotProd(); // should never leak to prod mode
5485
+ if (template === defaultEmptyTemplate) {
5457
5486
  return;
5487
+ }
5458
5488
  if (vm.renderMode === 0 /* RenderMode.Light */) {
5459
- assert.isTrue(template.renderMode === 'light', `Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of ${getComponentTag(vm)}.`);
5489
+ if (template.renderMode !== 'light') {
5490
+ logError(`Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of ${getComponentTag(vm)}.`);
5491
+ }
5460
5492
  }
5461
5493
  else {
5462
- assert.isTrue(isUndefined$1(template.renderMode), `Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${getComponentTag(vm)} or set it to 'lwc:render-mode="shadow"`);
5494
+ if (!isUndefined$1(template.renderMode)) {
5495
+ logError(`Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${getComponentTag(vm)} or set it to 'lwc:render-mode="shadow"`);
5496
+ }
5463
5497
  }
5464
5498
  }
5465
5499
  function buildParseFragmentFn(createFragmentFn) {
@@ -5592,7 +5626,9 @@
5592
5626
  logOperationEnd(1 /* OperationId.Render */, vm);
5593
5627
  });
5594
5628
  if (process.env.NODE_ENV !== 'production') {
5595
- assert.invariant(isArray$1(vnodes), `Compiler should produce html functions that always return an array.`);
5629
+ if (!isArray$1(vnodes)) {
5630
+ logError(`Compiler should produce html functions that always return an array.`);
5631
+ }
5596
5632
  }
5597
5633
  return vnodes;
5598
5634
  }
@@ -6681,6 +6717,27 @@
6681
6717
  }
6682
6718
  return false;
6683
6719
  }
6720
+ // The validationOptOut static property can be an array of attribute names.
6721
+ // Any attribute names specified in that array will not be validated, and the
6722
+ // LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
6723
+ function getValidationPredicate(optOutStaticProp) {
6724
+ if (isUndefined$1(optOutStaticProp)) {
6725
+ return (_attrName) => true;
6726
+ }
6727
+ // If validationOptOut is true, no attributes will be checked for correctness
6728
+ // and the runtime will assume VDOM attrs and DOM attrs are in sync.
6729
+ if (isTrue(optOutStaticProp)) {
6730
+ return (_attrName) => false;
6731
+ }
6732
+ // If validationOptOut is an array of strings, attributes specified in the
6733
+ // array will be "opted out". Attributes not specified in the array will still
6734
+ // be validated.
6735
+ if (isArray$1(optOutStaticProp) && arrayEvery(optOutStaticProp, isString)) {
6736
+ return (attrName) => !ArrayIncludes.call(optOutStaticProp, attrName);
6737
+ }
6738
+ logWarn('Validation opt out must be `true` or an array of attributes that should not be validated.');
6739
+ return (_attrName) => true;
6740
+ }
6684
6741
  function hydrateText(node, vnode, renderer) {
6685
6742
  var _a;
6686
6743
  if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
@@ -6759,8 +6816,19 @@
6759
6816
  return elm;
6760
6817
  }
6761
6818
  function hydrateCustomElement(elm, vnode, renderer) {
6819
+ const { validationOptOut } = vnode.ctor;
6820
+ const shouldValidateAttr = getValidationPredicate(validationOptOut);
6821
+ // The validationOptOut static property can be an array of attribute names.
6822
+ // Any attribute names specified in that array will not be validated, and the
6823
+ // LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
6824
+ //
6825
+ // If validationOptOut is true, no attributes will be checked for correctness
6826
+ // and the runtime will assume VDOM attrs and DOM attrs are in sync.
6827
+ //
6828
+ // Therefore, if validationOptOut is falsey or an array of strings, we need to
6829
+ // examine some or all of the custom element's attributes.
6762
6830
  if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) ||
6763
- !isMatchingElement(vnode, elm, renderer)) {
6831
+ !isMatchingElement(vnode, elm, renderer, shouldValidateAttr)) {
6764
6832
  return handleMismatch(elm, vnode, renderer);
6765
6833
  }
6766
6834
  const { sel, mode, ctor, owner } = vnode;
@@ -6854,7 +6922,7 @@
6854
6922
  }
6855
6923
  return true;
6856
6924
  }
6857
- function isMatchingElement(vnode, elm, renderer) {
6925
+ function isMatchingElement(vnode, elm, renderer, shouldValidateAttr = () => true) {
6858
6926
  const { getProperty } = renderer;
6859
6927
  if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
6860
6928
  if (process.env.NODE_ENV !== 'production') {
@@ -6862,10 +6930,14 @@
6862
6930
  }
6863
6931
  return false;
6864
6932
  }
6865
- const hasIncompatibleAttrs = validateAttrs(vnode, elm, renderer);
6866
- const hasIncompatibleClass = validateClassAttr(vnode, elm, renderer);
6867
- const hasIncompatibleStyle = validateStyleAttr(vnode, elm, renderer);
6868
- return hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
6933
+ const hasCompatibleAttrs = validateAttrs(vnode, elm, renderer, shouldValidateAttr);
6934
+ const hasCompatibleClass = shouldValidateAttr('class')
6935
+ ? validateClassAttr(vnode, elm, renderer)
6936
+ : true;
6937
+ const hasCompatibleStyle = shouldValidateAttr('style')
6938
+ ? validateStyleAttr(vnode, elm, renderer)
6939
+ : true;
6940
+ return hasCompatibleAttrs && hasCompatibleClass && hasCompatibleStyle;
6869
6941
  }
6870
6942
  function attributeValuesAreEqual(vnodeValue, value) {
6871
6943
  const vnodeValueAsString = String(vnodeValue);
@@ -6880,12 +6952,15 @@
6880
6952
  // In all other cases, the two values are not considered equal
6881
6953
  return false;
6882
6954
  }
6883
- function validateAttrs(vnode, elm, renderer) {
6955
+ function validateAttrs(vnode, elm, renderer, shouldValidateAttr) {
6884
6956
  const { data: { attrs = {} }, } = vnode;
6885
6957
  let nodesAreCompatible = true;
6886
6958
  // Validate attributes, though we could always recovery from those by running the update mods.
6887
6959
  // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
6888
6960
  for (const [attrName, attrValue] of Object.entries(attrs)) {
6961
+ if (!shouldValidateAttr(attrName)) {
6962
+ continue;
6963
+ }
6889
6964
  const { owner } = vnode;
6890
6965
  const { getAttribute } = renderer;
6891
6966
  const elmAttrValue = getAttribute(elm, attrName);
@@ -7309,7 +7384,7 @@
7309
7384
  }
7310
7385
  return getReadOnlyProxy(obj);
7311
7386
  }
7312
- /* version: 2.45.0 */
7387
+ /* version: 2.45.2 */
7313
7388
 
7314
7389
  /*
7315
7390
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7737,7 +7812,7 @@
7737
7812
  function isNull(obj) {
7738
7813
  return obj === null;
7739
7814
  }
7740
- /** version: 2.45.0 */
7815
+ /** version: 2.45.2 */
7741
7816
 
7742
7817
  /*
7743
7818
  * Copyright (c) 2023, salesforce.com, inc.
@@ -8356,7 +8431,7 @@
8356
8431
  });
8357
8432
  }));
8358
8433
  }
8359
- /* version: 2.45.0 */
8434
+ /* version: 2.45.2 */
8360
8435
 
8361
8436
  exports.LightningElement = LightningElement;
8362
8437
  exports.__unstable__ProfilerControl = profilerControl;