lwc 2.31.1 → 2.32.1

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 (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +237 -264
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +237 -264
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +109 -160
  5. package/dist/engine-dom/iife/es5/engine-dom.js +233 -242
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +142 -199
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +237 -264
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +109 -160
  11. package/dist/engine-dom/umd/es5/engine-dom.js +233 -242
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +142 -199
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +218 -224
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +218 -224
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +676 -909
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +676 -909
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +644 -882
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +85 -345
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +85 -345
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +676 -909
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +644 -882
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +85 -345
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +85 -345
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. package/package.json +7 -7
@@ -469,9 +469,9 @@ function htmlEscape(str, attrMode = false) {
469
469
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
470
470
  */
471
471
  // Increment whenever the LWC template compiler changes
472
- const LWC_VERSION = "2.31.1";
472
+ const LWC_VERSION = "2.32.1";
473
473
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
474
- /** version: 2.31.1 */
474
+ /** version: 2.32.1 */
475
475
 
476
476
  /*
477
477
  * Copyright (c) 2020, salesforce.com, inc.
@@ -517,19 +517,14 @@ if (typeof CustomEvent !== 'function') {
517
517
  */
518
518
  const features = {
519
519
  DUMMY_TEST_FLAG: null,
520
- ENABLE_ELEMENT_PATCH: null,
521
520
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
522
- ENABLE_HTML_COLLECTIONS_PATCH: null,
523
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
524
521
  ENABLE_MIXED_SHADOW_MODE: null,
525
522
  ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
526
- ENABLE_NODE_LIST_PATCH: null,
527
- ENABLE_NODE_PATCH: null,
528
- ENABLE_REACTIVE_SETTER: null,
529
523
  ENABLE_WIRE_SYNC_EMIT: null,
530
524
  ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
531
525
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
532
526
  ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
527
+ ENABLE_FROZEN_TEMPLATE: null,
533
528
  };
534
529
  if (!_globalThis.lwcRuntimeFlags) {
535
530
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
@@ -583,7 +578,7 @@ function setFeatureFlagForTest(name, value) {
583
578
  setFeatureFlag(name, value);
584
579
  }
585
580
  }
586
- /** version: 2.31.1 */
581
+ /** version: 2.32.1 */
587
582
 
588
583
  /* proxy-compat-disable */
589
584
 
@@ -1000,7 +995,7 @@ function patchElementWithRestrictions(elm, options) {
1000
995
  }),
1001
996
  };
1002
997
  // Apply extra restriction related to DOM manipulation if the element is not a portal.
1003
- if (!options.isLight && !options.isPortal) {
998
+ if (!options.isLight && options.isSynthetic && !options.isPortal) {
1004
999
  const { appendChild, insertBefore, removeChild, replaceChild } = elm;
1005
1000
  const originalNodeValueDescriptor = getPropertyDescriptor(elm, 'nodeValue');
1006
1001
  const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
@@ -2243,24 +2238,6 @@ function createObservedFieldPropertyDescriptor(key) {
2243
2238
  };
2244
2239
  }
2245
2240
 
2246
- /*
2247
- * Copyright (c) 2018, salesforce.com, inc.
2248
- * All rights reserved.
2249
- * SPDX-License-Identifier: MIT
2250
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2251
- */
2252
- const DUMMY_ACCESSOR_REACTIVE_OBSERVER = {
2253
- observe(job) {
2254
- job();
2255
- },
2256
- reset() { },
2257
- link() { },
2258
- };
2259
- function createAccessorReactiveObserver(vm, set) {
2260
- // On the server side, we don't need mutation tracking. Skipping it improves performance.
2261
- return DUMMY_ACCESSOR_REACTIVE_OBSERVER;
2262
- }
2263
-
2264
2241
  /*
2265
2242
  * Copyright (c) 2018, salesforce.com, inc.
2266
2243
  * All rights reserved.
@@ -2268,88 +2245,69 @@ function createAccessorReactiveObserver(vm, set) {
2268
2245
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2269
2246
  */
2270
2247
  function api$1() {
2271
- if (process.env.NODE_ENV !== 'production') {
2272
- assert.fail(`@api decorator can only be used as a decorator function.`);
2273
- }
2274
- throw new Error();
2248
+ if (process.env.NODE_ENV !== 'production') {
2249
+ assert.fail(`@api decorator can only be used as a decorator function.`);
2250
+ }
2251
+ throw new Error();
2275
2252
  }
2276
2253
  function createPublicPropertyDescriptor(key) {
2277
- return {
2278
- get() {
2279
- const vm = getAssociatedVM(this);
2280
- if (isBeingConstructed(vm)) {
2281
- if (process.env.NODE_ENV !== 'production') {
2282
- logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
2283
- }
2284
- return;
2285
- }
2286
- return vm.cmpProps[key];
2287
- },
2288
- set(newValue) {
2289
- const vm = getAssociatedVM(this);
2290
- if (process.env.NODE_ENV !== 'production') {
2291
- const vmBeingRendered = getVMBeingRendered();
2292
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2293
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2294
- }
2295
- vm.cmpProps[key] = newValue;
2296
- },
2297
- enumerable: true,
2298
- configurable: true
2299
- };
2254
+ return {
2255
+ get() {
2256
+ const vm = getAssociatedVM(this);
2257
+ if (isBeingConstructed(vm)) {
2258
+ if (process.env.NODE_ENV !== 'production') {
2259
+ logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
2260
+ }
2261
+ return;
2262
+ }
2263
+ return vm.cmpProps[key];
2264
+ },
2265
+ set(newValue) {
2266
+ const vm = getAssociatedVM(this);
2267
+ if (process.env.NODE_ENV !== 'production') {
2268
+ const vmBeingRendered = getVMBeingRendered();
2269
+ assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2270
+ assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2271
+ }
2272
+ vm.cmpProps[key] = newValue;
2273
+ },
2274
+ enumerable: true,
2275
+ configurable: true,
2276
+ };
2300
2277
  }
2301
2278
  function createPublicAccessorDescriptor(key, descriptor) {
2302
- const {
2303
- get,
2304
- set,
2305
- enumerable,
2306
- configurable
2307
- } = descriptor;
2308
- if (!isFunction$1(get)) {
2309
- if (process.env.NODE_ENV !== 'production') {
2310
- assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
2311
- }
2312
- throw new Error();
2313
- }
2314
- return {
2315
- get() {
2316
- if (process.env.NODE_ENV !== 'production') {
2317
- // Assert that the this value is an actual Component with an associated VM.
2318
- getAssociatedVM(this);
2319
- }
2320
- return get.call(this);
2321
- },
2322
- set(newValue) {
2323
- const vm = getAssociatedVM(this);
2324
- if (process.env.NODE_ENV !== 'production') {
2325
- const vmBeingRendered = getVMBeingRendered();
2326
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2327
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2328
- }
2329
- if (set) {
2330
- if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
2331
- let ro = vm.oar[key];
2332
- if (isUndefined$1(ro)) {
2333
- ro = vm.oar[key] = createAccessorReactiveObserver();
2334
- }
2335
- // every time we invoke this setter from outside (through this wrapper setter)
2336
- // we should reset the value and then debounce just in case there is a pending
2337
- // invocation the next tick that is not longer relevant since the value is changing
2338
- // from outside.
2339
- ro.reset(newValue);
2340
- ro.observe(() => {
2341
- set.call(this, newValue);
2342
- });
2343
- } else {
2344
- set.call(this, newValue);
2279
+ const { get, set, enumerable, configurable } = descriptor;
2280
+ if (!isFunction$1(get)) {
2281
+ if (process.env.NODE_ENV !== 'production') {
2282
+ assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
2345
2283
  }
2346
- } else if (process.env.NODE_ENV !== 'production') {
2347
- 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.`);
2348
- }
2349
- },
2350
- enumerable,
2351
- configurable
2352
- };
2284
+ throw new Error();
2285
+ }
2286
+ return {
2287
+ get() {
2288
+ if (process.env.NODE_ENV !== 'production') {
2289
+ // Assert that the this value is an actual Component with an associated VM.
2290
+ getAssociatedVM(this);
2291
+ }
2292
+ return get.call(this);
2293
+ },
2294
+ set(newValue) {
2295
+ const vm = getAssociatedVM(this);
2296
+ if (process.env.NODE_ENV !== 'production') {
2297
+ const vmBeingRendered = getVMBeingRendered();
2298
+ assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2299
+ assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2300
+ }
2301
+ if (set) {
2302
+ set.call(this, newValue);
2303
+ }
2304
+ else if (process.env.NODE_ENV !== 'production') {
2305
+ 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.`);
2306
+ }
2307
+ },
2308
+ enumerable,
2309
+ configurable,
2310
+ };
2353
2311
  }
2354
2312
 
2355
2313
  /*
@@ -2673,12 +2631,6 @@ function checkVersionMismatch(func, type) {
2673
2631
  }
2674
2632
  }
2675
2633
 
2676
- /*
2677
- * Copyright (c) 2018, salesforce.com, inc.
2678
- * All rights reserved.
2679
- * SPDX-License-Identifier: MIT
2680
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2681
- */
2682
2634
  const signedTemplateSet = new Set();
2683
2635
  function defaultEmptyTemplate() {
2684
2636
  return [];
@@ -2696,32 +2648,6 @@ function registerTemplate(tpl) {
2696
2648
  checkVersionMismatch(tpl, 'template');
2697
2649
  }
2698
2650
  signedTemplateSet.add(tpl);
2699
- // FIXME[@W-10950976]: the template object should be frozen, and it should not be possible to set
2700
- // the stylesheets or stylesheetToken(s). For backwards compat, though, we shim stylesheetTokens
2701
- // on top of stylesheetToken for anyone who is accessing the old internal API.
2702
- // Details: https://salesforce.quip.com/v1rmAFu2cKAr
2703
- defineProperty(tpl, 'stylesheetTokens', {
2704
- enumerable: true,
2705
- configurable: true,
2706
- get() {
2707
- const { stylesheetToken } = this;
2708
- if (isUndefined$1(stylesheetToken)) {
2709
- return stylesheetToken;
2710
- }
2711
- // Shim for the old `stylesheetTokens` property
2712
- // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
2713
- return {
2714
- hostAttribute: `${stylesheetToken}-host`,
2715
- shadowAttribute: stylesheetToken,
2716
- };
2717
- },
2718
- set(value) {
2719
- // If the value is null or some other exotic object, you would be broken anyway in the past
2720
- // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
2721
- // However it may be undefined in newer versions of LWC, so we need to guard against that case.
2722
- this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
2723
- },
2724
- });
2725
2651
  // chaining this method as a way to wrap existing
2726
2652
  // assignment of templates easily, without too much transformation
2727
2653
  return tpl;
@@ -4113,11 +4039,13 @@ function applyDomManual(elm, vnode) {
4113
4039
  function applyElementRestrictions(elm, vnode) {
4114
4040
  var _a, _b;
4115
4041
  if (process.env.NODE_ENV !== 'production') {
4042
+ const isSynthetic = vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
4116
4043
  const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
4117
4044
  const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
4118
4045
  patchElementWithRestrictions(elm, {
4119
4046
  isPortal,
4120
- isLight
4047
+ isLight,
4048
+ isSynthetic
4121
4049
  });
4122
4050
  }
4123
4051
  }
@@ -4533,7 +4461,7 @@ function s(slotName, data, children, slotset) {
4533
4461
  // undefined is for root components, but root components cannot accept slotted content
4534
4462
  setVMBeingRendered(slotset.owner);
4535
4463
  try {
4536
- ArrayPush$1.apply(newChildren, vnode.factory(data.slotData));
4464
+ ArrayPush$1.call(newChildren, vnode.factory(data.slotData, data.key));
4537
4465
  }
4538
4466
  finally {
4539
4467
  setVMBeingRendered(vmBeingRenderedInception);
@@ -5368,15 +5296,10 @@ function resetComponentStateWhenRemoved(vm) {
5368
5296
  } = vm;
5369
5297
  if (state !== 2 /* VMState.disconnected */) {
5370
5298
  const {
5371
- oar,
5372
5299
  tro
5373
5300
  } = vm;
5374
5301
  // Making sure that any observing record will not trigger the rehydrated on this vm
5375
5302
  tro.reset();
5376
- // Making sure that any observing accessor record will not trigger the setter to be reinvoked
5377
- for (const key in oar) {
5378
- oar[key].reset();
5379
- }
5380
5303
  runDisconnectedCallback(vm);
5381
5304
  // Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
5382
5305
  runChildNodesDisconnectedCallback(vm);
@@ -5429,7 +5352,6 @@ function createVM(elm, ctor, renderer, options) {
5429
5352
  cmpSlots: {
5430
5353
  slotAssignments: create(null)
5431
5354
  },
5432
- oar: create(null),
5433
5355
  cmpTemplate: null,
5434
5356
  hydrated: Boolean(hydrated),
5435
5357
  renderMode: def.renderMode,
@@ -6115,96 +6037,168 @@ function setHooks(hooks) {
6115
6037
  // See @lwc/engine-core/src/framework/template.ts
6116
6038
  const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
6117
6039
  // Via https://www.npmjs.com/package/object-observer
6118
- const ARRAY_MUTATION_METHODS = [
6119
- 'pop',
6120
- 'push',
6121
- 'shift',
6122
- 'unshift',
6123
- 'reverse',
6124
- 'sort',
6125
- 'fill',
6126
- 'splice',
6127
- 'copyWithin',
6128
- ];
6040
+ const ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
6041
+ // Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
6042
+ const STYLESHEET_FUNCTION_EXPANDOS = [
6043
+ // SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
6044
+ '$scoped$'];
6129
6045
  function getOriginalArrayMethod(prop) {
6130
- switch (prop) {
6131
- case 'pop':
6132
- return ArrayPop;
6133
- case 'push':
6134
- return ArrayPush$1;
6135
- case 'shift':
6136
- return ArrayShift;
6137
- case 'unshift':
6138
- return ArrayUnshift;
6139
- case 'reverse':
6140
- return ArrayReverse;
6141
- case 'sort':
6142
- return ArraySort;
6143
- case 'fill':
6144
- return ArrayFill;
6145
- case 'splice':
6146
- return ArraySplice;
6147
- case 'copyWithin':
6148
- return ArrayCopyWithin;
6149
- }
6046
+ switch (prop) {
6047
+ case 'pop':
6048
+ return ArrayPop;
6049
+ case 'push':
6050
+ return ArrayPush$1;
6051
+ case 'shift':
6052
+ return ArrayShift;
6053
+ case 'unshift':
6054
+ return ArrayUnshift;
6055
+ case 'reverse':
6056
+ return ArrayReverse;
6057
+ case 'sort':
6058
+ return ArraySort;
6059
+ case 'fill':
6060
+ return ArrayFill;
6061
+ case 'splice':
6062
+ return ArraySplice;
6063
+ case 'copyWithin':
6064
+ return ArrayCopyWithin;
6065
+ }
6150
6066
  }
6151
6067
  let mutationWarningsSilenced = false;
6152
- // Warn if the user tries to mutate tmpl.stylesheets, e.g.:
6068
+ // Warn if the user tries to mutate a stylesheets array, e.g.:
6153
6069
  // `tmpl.stylesheets.push(someStylesheetFunction)`
6154
6070
  function warnOnArrayMutation(stylesheets) {
6155
- // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
6156
- // we can at least warn when they use the most common mutation methods.
6157
- for (const prop of ARRAY_MUTATION_METHODS) {
6158
- const originalArrayMethod = getOriginalArrayMethod(prop);
6159
- stylesheets[prop] = function arrayMutationWarningWrapper() {
6160
- logError(`Mutating the "stylesheets" array on a template function ` +
6161
- `is deprecated and may be removed in a future version of LWC.`);
6162
- // @ts-ignore
6163
- return originalArrayMethod.apply(this, arguments);
6164
- };
6071
+ // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
6072
+ // we can at least warn when they use the most common mutation methods.
6073
+ for (const prop of ARRAY_MUTATION_METHODS) {
6074
+ const originalArrayMethod = getOriginalArrayMethod(prop);
6075
+ stylesheets[prop] = function arrayMutationWarningWrapper() {
6076
+ logError(`Mutating the "stylesheets" array on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6077
+ // @ts-ignore
6078
+ return originalArrayMethod.apply(this, arguments);
6079
+ };
6080
+ }
6081
+ }
6082
+ // Warn if the user tries to mutate a stylesheet factory function, e.g.:
6083
+ // `stylesheet.$scoped$ = true`
6084
+ function warnOnStylesheetFunctionMutation(stylesheet) {
6085
+ // We could warn on other properties, but in practice only certain expandos are meaningful to LWC at runtime
6086
+ for (const prop of STYLESHEET_FUNCTION_EXPANDOS) {
6087
+ let value = stylesheet[prop];
6088
+ defineProperty(stylesheet, prop, {
6089
+ enumerable: true,
6090
+ configurable: true,
6091
+ get() {
6092
+ return value;
6093
+ },
6094
+ set(newValue) {
6095
+ logError(`Dynamically setting the "${prop}" property on a stylesheet function ` + `is deprecated and may be removed in a future version of LWC.`);
6096
+ value = newValue;
6097
+ }
6098
+ });
6099
+ }
6100
+ }
6101
+ // Warn on either array or stylesheet (function) mutation, in a deeply-nested array
6102
+ function warnOnStylesheetsMutation(stylesheets) {
6103
+ traverseStylesheets(stylesheets, subStylesheets => {
6104
+ if (isArray$1(subStylesheets)) {
6105
+ warnOnArrayMutation(subStylesheets);
6106
+ } else {
6107
+ warnOnStylesheetFunctionMutation(subStylesheets);
6108
+ }
6109
+ });
6110
+ }
6111
+ // Deeply freeze the entire array (of arrays) of stylesheet factory functions
6112
+ function deepFreeze(stylesheets) {
6113
+ traverseStylesheets(stylesheets, subStylesheets => {
6114
+ freeze(subStylesheets);
6115
+ });
6116
+ }
6117
+ // Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
6118
+ function traverseStylesheets(stylesheets, callback) {
6119
+ callback(stylesheets);
6120
+ for (let i = 0; i < stylesheets.length; i++) {
6121
+ const stylesheet = stylesheets[i];
6122
+ if (isArray$1(stylesheet)) {
6123
+ traverseStylesheets(stylesheet, callback);
6124
+ } else {
6125
+ callback(stylesheet);
6165
6126
  }
6127
+ }
6166
6128
  }
6167
- // TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
6168
- // just warns on mutation.
6169
6129
  function freezeTemplate(tmpl) {
6130
+ if (lwcRuntimeFlags.ENABLE_FROZEN_TEMPLATE) {
6131
+ // Deep freeze the template
6132
+ freeze(tmpl);
6133
+ if (!isUndefined$1(tmpl.stylesheets)) {
6134
+ deepFreeze(tmpl.stylesheets);
6135
+ }
6136
+ } else {
6137
+ // TODO [#2782]: remove this flag and delete the legacy behavior
6138
+ // When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
6139
+ // is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
6140
+ defineProperty(tmpl, 'stylesheetTokens', {
6141
+ enumerable: true,
6142
+ configurable: true,
6143
+ get() {
6144
+ const {
6145
+ stylesheetToken
6146
+ } = this;
6147
+ if (isUndefined$1(stylesheetToken)) {
6148
+ return stylesheetToken;
6149
+ }
6150
+ // Shim for the old `stylesheetTokens` property
6151
+ // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
6152
+ return {
6153
+ hostAttribute: `${stylesheetToken}-host`,
6154
+ shadowAttribute: stylesheetToken
6155
+ };
6156
+ },
6157
+ set(value) {
6158
+ // If the value is null or some other exotic object, you would be broken anyway in the past
6159
+ // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
6160
+ // However it may be undefined in newer versions of LWC, so we need to guard against that case.
6161
+ this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
6162
+ }
6163
+ });
6164
+ // When ENABLE_FROZEN_TEMPLATE is false, warn in dev mode whenever someone is mutating the template
6170
6165
  if (process.env.NODE_ENV !== 'production') {
6171
- if (!isUndefined$1(tmpl.stylesheets)) {
6172
- warnOnArrayMutation(tmpl.stylesheets);
6173
- }
6174
- for (const prop of TEMPLATE_PROPS) {
6175
- let value = tmpl[prop];
6176
- defineProperty(tmpl, prop, {
6177
- enumerable: true,
6178
- configurable: true,
6179
- get() {
6180
- return value;
6181
- },
6182
- set(newValue) {
6183
- if (!mutationWarningsSilenced) {
6184
- logError(`Dynamically setting the "${prop}" property on a template function ` +
6185
- `is deprecated and may be removed in a future version of LWC.`);
6186
- }
6187
- value = newValue;
6188
- },
6189
- });
6190
- }
6191
- const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
6192
- defineProperty(tmpl, 'stylesheetTokens', {
6193
- enumerable: true,
6194
- configurable: true,
6195
- get: originalDescriptor.get,
6196
- set(value) {
6197
- logError(`Dynamically setting the "stylesheetTokens" property on a template function ` +
6198
- `is deprecated and may be removed in a future version of LWC.`);
6199
- // Avoid logging twice (for both stylesheetToken and stylesheetTokens)
6200
- mutationWarningsSilenced = true;
6201
- originalDescriptor.set.call(this, value);
6202
- mutationWarningsSilenced = false;
6203
- },
6166
+ if (!isUndefined$1(tmpl.stylesheets)) {
6167
+ warnOnStylesheetsMutation(tmpl.stylesheets);
6168
+ }
6169
+ for (const prop of TEMPLATE_PROPS) {
6170
+ let value = tmpl[prop];
6171
+ defineProperty(tmpl, prop, {
6172
+ enumerable: true,
6173
+ configurable: true,
6174
+ get() {
6175
+ return value;
6176
+ },
6177
+ set(newValue) {
6178
+ if (!mutationWarningsSilenced) {
6179
+ logError(`Dynamically setting the "${prop}" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6180
+ }
6181
+ value = newValue;
6182
+ }
6204
6183
  });
6184
+ }
6185
+ const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
6186
+ defineProperty(tmpl, 'stylesheetTokens', {
6187
+ enumerable: true,
6188
+ configurable: true,
6189
+ get: originalDescriptor.get,
6190
+ set(value) {
6191
+ logError(`Dynamically setting the "stylesheetTokens" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6192
+ // Avoid logging twice (for both stylesheetToken and stylesheetTokens)
6193
+ mutationWarningsSilenced = true;
6194
+ originalDescriptor.set.call(this, value);
6195
+ mutationWarningsSilenced = false;
6196
+ }
6197
+ });
6205
6198
  }
6199
+ }
6206
6200
  }
6207
- /* version: 2.31.1 */
6201
+ /* version: 2.32.1 */
6208
6202
 
6209
6203
  /*
6210
6204
  * Copyright (c) 2020, salesforce.com, inc.
@@ -6675,7 +6669,7 @@ function renderComponent(tagName, Ctor, props = {}) {
6675
6669
  */
6676
6670
  freeze(LightningElement);
6677
6671
  seal(LightningElement.prototype);
6678
- /* version: 2.31.1 */
6672
+ /* version: 2.32.1 */
6679
6673
 
6680
6674
  exports.LightningElement = LightningElement;
6681
6675
  exports.api = api$1;