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
@@ -344,9 +344,9 @@ var LWC = (function (exports) {
344
344
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
345
345
  */
346
346
  // Increment whenever the LWC template compiler changes
347
- const LWC_VERSION = "2.31.1";
347
+ const LWC_VERSION = "2.32.1";
348
348
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
349
- /** version: 2.31.1 */
349
+ /** version: 2.32.1 */
350
350
 
351
351
  /**
352
352
  * Copyright (C) 2018 salesforce.com, inc.
@@ -428,7 +428,7 @@ var LWC = (function (exports) {
428
428
  patch$1(propName);
429
429
  }
430
430
  }
431
- /** version: 2.31.1 */
431
+ /** version: 2.32.1 */
432
432
 
433
433
  /**
434
434
  * Copyright (C) 2018 salesforce.com, inc.
@@ -442,19 +442,14 @@ var LWC = (function (exports) {
442
442
  */
443
443
  const features = {
444
444
  DUMMY_TEST_FLAG: null,
445
- ENABLE_ELEMENT_PATCH: null,
446
445
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
447
- ENABLE_HTML_COLLECTIONS_PATCH: null,
448
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
449
446
  ENABLE_MIXED_SHADOW_MODE: null,
450
447
  ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
451
- ENABLE_NODE_LIST_PATCH: null,
452
- ENABLE_NODE_PATCH: null,
453
- ENABLE_REACTIVE_SETTER: null,
454
448
  ENABLE_WIRE_SYNC_EMIT: null,
455
449
  ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
456
450
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
457
451
  ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
452
+ ENABLE_FROZEN_TEMPLATE: null,
458
453
  };
459
454
  if (!_globalThis.lwcRuntimeFlags) {
460
455
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
@@ -508,7 +503,7 @@ var LWC = (function (exports) {
508
503
  setFeatureFlag(name, value);
509
504
  }
510
505
  }
511
- /** version: 2.31.1 */
506
+ /** version: 2.32.1 */
512
507
 
513
508
  /*
514
509
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1079,7 +1074,7 @@ var LWC = (function (exports) {
1079
1074
  }),
1080
1075
  };
1081
1076
  // Apply extra restriction related to DOM manipulation if the element is not a portal.
1082
- if (!options.isLight && !options.isPortal) {
1077
+ if (!options.isLight && options.isSynthetic && !options.isPortal) {
1083
1078
  const { appendChild, insertBefore, removeChild, replaceChild } = elm;
1084
1079
  const originalNodeValueDescriptor = getPropertyDescriptor(elm, 'nodeValue');
1085
1080
  const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
@@ -2332,45 +2327,6 @@ var LWC = (function (exports) {
2332
2327
  configurable: true,
2333
2328
  };
2334
2329
  }
2335
- class AccessorReactiveObserver extends ReactiveObserver {
2336
- constructor(vm, set) {
2337
- super(() => {
2338
- if (isFalse(this.debouncing)) {
2339
- this.debouncing = true;
2340
- addCallbackToNextTick(() => {
2341
- if (isTrue(this.debouncing)) {
2342
- const { value } = this;
2343
- const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
2344
- set.call(component, value);
2345
- // de-bouncing after the call to the original setter to prevent
2346
- // infinity loop if the setter itself is mutating things that
2347
- // were accessed during the previous invocation.
2348
- this.debouncing = false;
2349
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2350
- // immediate rehydration due to a setter driven mutation, otherwise
2351
- // the component will get rendered on the second tick, which it is not
2352
- // desirable.
2353
- rerenderVM(vm);
2354
- }
2355
- }
2356
- });
2357
- }
2358
- });
2359
- this.debouncing = false;
2360
- }
2361
- reset(value) {
2362
- super.reset();
2363
- this.debouncing = false;
2364
- if (arguments.length > 0) {
2365
- this.value = value;
2366
- }
2367
- }
2368
- }
2369
- function createAccessorReactiveObserver(vm, set) {
2370
- // On the server side, we don't need mutation tracking. Skipping it improves performance.
2371
- return new AccessorReactiveObserver(vm, set)
2372
- ;
2373
- }
2374
2330
 
2375
2331
  /*
2376
2332
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2379,90 +2335,71 @@ var LWC = (function (exports) {
2379
2335
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2380
2336
  */
2381
2337
  function api$1() {
2382
- if (process.env.NODE_ENV !== 'production') {
2383
- assert.fail(`@api decorator can only be used as a decorator function.`);
2384
- }
2385
- throw new Error();
2338
+ if (process.env.NODE_ENV !== 'production') {
2339
+ assert.fail(`@api decorator can only be used as a decorator function.`);
2340
+ }
2341
+ throw new Error();
2386
2342
  }
2387
2343
  function createPublicPropertyDescriptor(key) {
2388
- return {
2389
- get() {
2390
- const vm = getAssociatedVM(this);
2391
- if (isBeingConstructed(vm)) {
2392
- if (process.env.NODE_ENV !== 'production') {
2393
- 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);
2394
- }
2395
- return;
2396
- }
2397
- componentValueObserved(vm, key);
2398
- return vm.cmpProps[key];
2399
- },
2400
- set(newValue) {
2401
- const vm = getAssociatedVM(this);
2402
- if (process.env.NODE_ENV !== 'production') {
2403
- const vmBeingRendered = getVMBeingRendered();
2404
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2405
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2406
- }
2407
- vm.cmpProps[key] = newValue;
2408
- componentValueMutated(vm, key);
2409
- },
2410
- enumerable: true,
2411
- configurable: true
2412
- };
2344
+ return {
2345
+ get() {
2346
+ const vm = getAssociatedVM(this);
2347
+ if (isBeingConstructed(vm)) {
2348
+ if (process.env.NODE_ENV !== 'production') {
2349
+ 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);
2350
+ }
2351
+ return;
2352
+ }
2353
+ componentValueObserved(vm, key);
2354
+ return vm.cmpProps[key];
2355
+ },
2356
+ set(newValue) {
2357
+ const vm = getAssociatedVM(this);
2358
+ if (process.env.NODE_ENV !== 'production') {
2359
+ const vmBeingRendered = getVMBeingRendered();
2360
+ assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2361
+ assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2362
+ }
2363
+ vm.cmpProps[key] = newValue;
2364
+ componentValueMutated(vm, key);
2365
+ },
2366
+ enumerable: true,
2367
+ configurable: true,
2368
+ };
2413
2369
  }
2414
2370
  function createPublicAccessorDescriptor(key, descriptor) {
2415
- const {
2416
- get,
2417
- set,
2418
- enumerable,
2419
- configurable
2420
- } = descriptor;
2421
- if (!isFunction$1(get)) {
2422
- if (process.env.NODE_ENV !== 'production') {
2423
- assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
2424
- }
2425
- throw new Error();
2426
- }
2427
- return {
2428
- get() {
2429
- if (process.env.NODE_ENV !== 'production') {
2430
- // Assert that the this value is an actual Component with an associated VM.
2431
- getAssociatedVM(this);
2432
- }
2433
- return get.call(this);
2434
- },
2435
- set(newValue) {
2436
- const vm = getAssociatedVM(this);
2437
- if (process.env.NODE_ENV !== 'production') {
2438
- const vmBeingRendered = getVMBeingRendered();
2439
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2440
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2441
- }
2442
- if (set) {
2443
- if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
2444
- let ro = vm.oar[key];
2445
- if (isUndefined$1(ro)) {
2446
- ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
2447
- }
2448
- // every time we invoke this setter from outside (through this wrapper setter)
2449
- // we should reset the value and then debounce just in case there is a pending
2450
- // invocation the next tick that is not longer relevant since the value is changing
2451
- // from outside.
2452
- ro.reset(newValue);
2453
- ro.observe(() => {
2454
- set.call(this, newValue);
2455
- });
2456
- } else {
2457
- set.call(this, newValue);
2371
+ const { get, set, enumerable, configurable } = descriptor;
2372
+ if (!isFunction$1(get)) {
2373
+ if (process.env.NODE_ENV !== 'production') {
2374
+ assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
2458
2375
  }
2459
- } else if (process.env.NODE_ENV !== 'production') {
2460
- 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.`);
2461
- }
2462
- },
2463
- enumerable,
2464
- configurable
2465
- };
2376
+ throw new Error();
2377
+ }
2378
+ return {
2379
+ get() {
2380
+ if (process.env.NODE_ENV !== 'production') {
2381
+ // Assert that the this value is an actual Component with an associated VM.
2382
+ getAssociatedVM(this);
2383
+ }
2384
+ return get.call(this);
2385
+ },
2386
+ set(newValue) {
2387
+ const vm = getAssociatedVM(this);
2388
+ if (process.env.NODE_ENV !== 'production') {
2389
+ const vmBeingRendered = getVMBeingRendered();
2390
+ assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2391
+ assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2392
+ }
2393
+ if (set) {
2394
+ set.call(this, newValue);
2395
+ }
2396
+ else if (process.env.NODE_ENV !== 'production') {
2397
+ 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.`);
2398
+ }
2399
+ },
2400
+ enumerable,
2401
+ configurable,
2402
+ };
2466
2403
  }
2467
2404
 
2468
2405
  /*
@@ -2788,12 +2725,6 @@ var LWC = (function (exports) {
2788
2725
  }
2789
2726
  }
2790
2727
 
2791
- /*
2792
- * Copyright (c) 2018, salesforce.com, inc.
2793
- * All rights reserved.
2794
- * SPDX-License-Identifier: MIT
2795
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2796
- */
2797
2728
  const signedTemplateSet = new Set();
2798
2729
  function defaultEmptyTemplate() {
2799
2730
  return [];
@@ -2811,32 +2742,6 @@ var LWC = (function (exports) {
2811
2742
  checkVersionMismatch(tpl, 'template');
2812
2743
  }
2813
2744
  signedTemplateSet.add(tpl);
2814
- // FIXME[@W-10950976]: the template object should be frozen, and it should not be possible to set
2815
- // the stylesheets or stylesheetToken(s). For backwards compat, though, we shim stylesheetTokens
2816
- // on top of stylesheetToken for anyone who is accessing the old internal API.
2817
- // Details: https://salesforce.quip.com/v1rmAFu2cKAr
2818
- defineProperty(tpl, 'stylesheetTokens', {
2819
- enumerable: true,
2820
- configurable: true,
2821
- get() {
2822
- const { stylesheetToken } = this;
2823
- if (isUndefined$1(stylesheetToken)) {
2824
- return stylesheetToken;
2825
- }
2826
- // Shim for the old `stylesheetTokens` property
2827
- // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
2828
- return {
2829
- hostAttribute: `${stylesheetToken}-host`,
2830
- shadowAttribute: stylesheetToken,
2831
- };
2832
- },
2833
- set(value) {
2834
- // If the value is null or some other exotic object, you would be broken anyway in the past
2835
- // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
2836
- // However it may be undefined in newer versions of LWC, so we need to guard against that case.
2837
- this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
2838
- },
2839
- });
2840
2745
  // chaining this method as a way to wrap existing
2841
2746
  // assignment of templates easily, without too much transformation
2842
2747
  return tpl;
@@ -4373,11 +4278,13 @@ var LWC = (function (exports) {
4373
4278
  function applyElementRestrictions(elm, vnode) {
4374
4279
  var _a, _b;
4375
4280
  if (process.env.NODE_ENV !== 'production') {
4281
+ const isSynthetic = vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
4376
4282
  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 */;
4377
4283
  const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
4378
4284
  patchElementWithRestrictions(elm, {
4379
4285
  isPortal,
4380
- isLight
4286
+ isLight,
4287
+ isSynthetic
4381
4288
  });
4382
4289
  }
4383
4290
  }
@@ -4793,7 +4700,7 @@ var LWC = (function (exports) {
4793
4700
  // undefined is for root components, but root components cannot accept slotted content
4794
4701
  setVMBeingRendered(slotset.owner);
4795
4702
  try {
4796
- ArrayPush$1.apply(newChildren, vnode.factory(data.slotData));
4703
+ ArrayPush$1.call(newChildren, vnode.factory(data.slotData, data.key));
4797
4704
  }
4798
4705
  finally {
4799
4706
  setVMBeingRendered(vmBeingRenderedInception);
@@ -5673,15 +5580,10 @@ var LWC = (function (exports) {
5673
5580
  } = vm;
5674
5581
  if (state !== 2 /* VMState.disconnected */) {
5675
5582
  const {
5676
- oar,
5677
5583
  tro
5678
5584
  } = vm;
5679
5585
  // Making sure that any observing record will not trigger the rehydrated on this vm
5680
5586
  tro.reset();
5681
- // Making sure that any observing accessor record will not trigger the setter to be reinvoked
5682
- for (const key in oar) {
5683
- oar[key].reset();
5684
- }
5685
5587
  runDisconnectedCallback(vm);
5686
5588
  // Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
5687
5589
  runChildNodesDisconnectedCallback(vm);
@@ -5734,7 +5636,6 @@ var LWC = (function (exports) {
5734
5636
  cmpSlots: {
5735
5637
  slotAssignments: create(null)
5736
5638
  },
5737
- oar: create(null),
5738
5639
  cmpTemplate: null,
5739
5640
  hydrated: Boolean(hydrated),
5740
5641
  renderMode: def.renderMode,
@@ -6915,94 +6816,166 @@ var LWC = (function (exports) {
6915
6816
  // See @lwc/engine-core/src/framework/template.ts
6916
6817
  const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
6917
6818
  // Via https://www.npmjs.com/package/object-observer
6918
- const ARRAY_MUTATION_METHODS = [
6919
- 'pop',
6920
- 'push',
6921
- 'shift',
6922
- 'unshift',
6923
- 'reverse',
6924
- 'sort',
6925
- 'fill',
6926
- 'splice',
6927
- 'copyWithin',
6928
- ];
6819
+ const ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
6820
+ // Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
6821
+ const STYLESHEET_FUNCTION_EXPANDOS = [
6822
+ // SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
6823
+ '$scoped$'];
6929
6824
  function getOriginalArrayMethod(prop) {
6930
- switch (prop) {
6931
- case 'pop':
6932
- return ArrayPop;
6933
- case 'push':
6934
- return ArrayPush$1;
6935
- case 'shift':
6936
- return ArrayShift;
6937
- case 'unshift':
6938
- return ArrayUnshift;
6939
- case 'reverse':
6940
- return ArrayReverse;
6941
- case 'sort':
6942
- return ArraySort;
6943
- case 'fill':
6944
- return ArrayFill;
6945
- case 'splice':
6946
- return ArraySplice;
6947
- case 'copyWithin':
6948
- return ArrayCopyWithin;
6949
- }
6825
+ switch (prop) {
6826
+ case 'pop':
6827
+ return ArrayPop;
6828
+ case 'push':
6829
+ return ArrayPush$1;
6830
+ case 'shift':
6831
+ return ArrayShift;
6832
+ case 'unshift':
6833
+ return ArrayUnshift;
6834
+ case 'reverse':
6835
+ return ArrayReverse;
6836
+ case 'sort':
6837
+ return ArraySort;
6838
+ case 'fill':
6839
+ return ArrayFill;
6840
+ case 'splice':
6841
+ return ArraySplice;
6842
+ case 'copyWithin':
6843
+ return ArrayCopyWithin;
6844
+ }
6950
6845
  }
6951
6846
  let mutationWarningsSilenced = false;
6952
- // Warn if the user tries to mutate tmpl.stylesheets, e.g.:
6847
+ // Warn if the user tries to mutate a stylesheets array, e.g.:
6953
6848
  // `tmpl.stylesheets.push(someStylesheetFunction)`
6954
6849
  function warnOnArrayMutation(stylesheets) {
6955
- // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
6956
- // we can at least warn when they use the most common mutation methods.
6957
- for (const prop of ARRAY_MUTATION_METHODS) {
6958
- const originalArrayMethod = getOriginalArrayMethod(prop);
6959
- stylesheets[prop] = function arrayMutationWarningWrapper() {
6960
- logError(`Mutating the "stylesheets" array on a template function ` +
6961
- `is deprecated and may be removed in a future version of LWC.`);
6962
- // @ts-ignore
6963
- return originalArrayMethod.apply(this, arguments);
6964
- };
6850
+ // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
6851
+ // we can at least warn when they use the most common mutation methods.
6852
+ for (const prop of ARRAY_MUTATION_METHODS) {
6853
+ const originalArrayMethod = getOriginalArrayMethod(prop);
6854
+ stylesheets[prop] = function arrayMutationWarningWrapper() {
6855
+ logError(`Mutating the "stylesheets" array on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6856
+ // @ts-ignore
6857
+ return originalArrayMethod.apply(this, arguments);
6858
+ };
6859
+ }
6860
+ }
6861
+ // Warn if the user tries to mutate a stylesheet factory function, e.g.:
6862
+ // `stylesheet.$scoped$ = true`
6863
+ function warnOnStylesheetFunctionMutation(stylesheet) {
6864
+ // We could warn on other properties, but in practice only certain expandos are meaningful to LWC at runtime
6865
+ for (const prop of STYLESHEET_FUNCTION_EXPANDOS) {
6866
+ let value = stylesheet[prop];
6867
+ defineProperty(stylesheet, prop, {
6868
+ enumerable: true,
6869
+ configurable: true,
6870
+ get() {
6871
+ return value;
6872
+ },
6873
+ set(newValue) {
6874
+ logError(`Dynamically setting the "${prop}" property on a stylesheet function ` + `is deprecated and may be removed in a future version of LWC.`);
6875
+ value = newValue;
6876
+ }
6877
+ });
6878
+ }
6879
+ }
6880
+ // Warn on either array or stylesheet (function) mutation, in a deeply-nested array
6881
+ function warnOnStylesheetsMutation(stylesheets) {
6882
+ traverseStylesheets(stylesheets, subStylesheets => {
6883
+ if (isArray$1(subStylesheets)) {
6884
+ warnOnArrayMutation(subStylesheets);
6885
+ } else {
6886
+ warnOnStylesheetFunctionMutation(subStylesheets);
6965
6887
  }
6888
+ });
6889
+ }
6890
+ // Deeply freeze the entire array (of arrays) of stylesheet factory functions
6891
+ function deepFreeze(stylesheets) {
6892
+ traverseStylesheets(stylesheets, subStylesheets => {
6893
+ freeze(subStylesheets);
6894
+ });
6895
+ }
6896
+ // Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
6897
+ function traverseStylesheets(stylesheets, callback) {
6898
+ callback(stylesheets);
6899
+ for (let i = 0; i < stylesheets.length; i++) {
6900
+ const stylesheet = stylesheets[i];
6901
+ if (isArray$1(stylesheet)) {
6902
+ traverseStylesheets(stylesheet, callback);
6903
+ } else {
6904
+ callback(stylesheet);
6905
+ }
6906
+ }
6966
6907
  }
6967
- // TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
6968
- // just warns on mutation.
6969
6908
  function freezeTemplate(tmpl) {
6970
- if (process.env.NODE_ENV !== 'production') {
6971
- if (!isUndefined$1(tmpl.stylesheets)) {
6972
- warnOnArrayMutation(tmpl.stylesheets);
6973
- }
6974
- for (const prop of TEMPLATE_PROPS) {
6975
- let value = tmpl[prop];
6976
- defineProperty(tmpl, prop, {
6977
- enumerable: true,
6978
- configurable: true,
6979
- get() {
6980
- return value;
6981
- },
6982
- set(newValue) {
6983
- if (!mutationWarningsSilenced) {
6984
- logError(`Dynamically setting the "${prop}" property on a template function ` +
6985
- `is deprecated and may be removed in a future version of LWC.`);
6986
- }
6987
- value = newValue;
6988
- },
6989
- });
6909
+ if (lwcRuntimeFlags.ENABLE_FROZEN_TEMPLATE) {
6910
+ // Deep freeze the template
6911
+ freeze(tmpl);
6912
+ if (!isUndefined$1(tmpl.stylesheets)) {
6913
+ deepFreeze(tmpl.stylesheets);
6914
+ }
6915
+ } else {
6916
+ // TODO [#2782]: remove this flag and delete the legacy behavior
6917
+ // When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
6918
+ // is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
6919
+ defineProperty(tmpl, 'stylesheetTokens', {
6920
+ enumerable: true,
6921
+ configurable: true,
6922
+ get() {
6923
+ const {
6924
+ stylesheetToken
6925
+ } = this;
6926
+ if (isUndefined$1(stylesheetToken)) {
6927
+ return stylesheetToken;
6990
6928
  }
6991
- const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
6992
- defineProperty(tmpl, 'stylesheetTokens', {
6993
- enumerable: true,
6994
- configurable: true,
6995
- get: originalDescriptor.get,
6996
- set(value) {
6997
- logError(`Dynamically setting the "stylesheetTokens" property on a template function ` +
6998
- `is deprecated and may be removed in a future version of LWC.`);
6999
- // Avoid logging twice (for both stylesheetToken and stylesheetTokens)
7000
- mutationWarningsSilenced = true;
7001
- originalDescriptor.set.call(this, value);
7002
- mutationWarningsSilenced = false;
7003
- },
6929
+ // Shim for the old `stylesheetTokens` property
6930
+ // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
6931
+ return {
6932
+ hostAttribute: `${stylesheetToken}-host`,
6933
+ shadowAttribute: stylesheetToken
6934
+ };
6935
+ },
6936
+ set(value) {
6937
+ // If the value is null or some other exotic object, you would be broken anyway in the past
6938
+ // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
6939
+ // However it may be undefined in newer versions of LWC, so we need to guard against that case.
6940
+ this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
6941
+ }
6942
+ });
6943
+ // When ENABLE_FROZEN_TEMPLATE is false, warn in dev mode whenever someone is mutating the template
6944
+ if (process.env.NODE_ENV !== 'production') {
6945
+ if (!isUndefined$1(tmpl.stylesheets)) {
6946
+ warnOnStylesheetsMutation(tmpl.stylesheets);
6947
+ }
6948
+ for (const prop of TEMPLATE_PROPS) {
6949
+ let value = tmpl[prop];
6950
+ defineProperty(tmpl, prop, {
6951
+ enumerable: true,
6952
+ configurable: true,
6953
+ get() {
6954
+ return value;
6955
+ },
6956
+ set(newValue) {
6957
+ if (!mutationWarningsSilenced) {
6958
+ logError(`Dynamically setting the "${prop}" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6959
+ }
6960
+ value = newValue;
6961
+ }
7004
6962
  });
6963
+ }
6964
+ const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
6965
+ defineProperty(tmpl, 'stylesheetTokens', {
6966
+ enumerable: true,
6967
+ configurable: true,
6968
+ get: originalDescriptor.get,
6969
+ set(value) {
6970
+ logError(`Dynamically setting the "stylesheetTokens" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6971
+ // Avoid logging twice (for both stylesheetToken and stylesheetTokens)
6972
+ mutationWarningsSilenced = true;
6973
+ originalDescriptor.set.call(this, value);
6974
+ mutationWarningsSilenced = false;
6975
+ }
6976
+ });
7005
6977
  }
6978
+ }
7006
6979
  }
7007
6980
 
7008
6981
  /*
@@ -7027,7 +7000,7 @@ var LWC = (function (exports) {
7027
7000
  }
7028
7001
  return ctor;
7029
7002
  }
7030
- /* version: 2.31.1 */
7003
+ /* version: 2.32.1 */
7031
7004
 
7032
7005
  /*
7033
7006
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7878,25 +7851,25 @@ var LWC = (function (exports) {
7878
7851
  // multiple times per tag name.
7879
7852
  const createUserConstructor = (HTMLElementToExtend, upgradeCallback, connectedCallback, disconnectedCallback) => {
7880
7853
  // TODO [#2972]: this class should expose observedAttributes as necessary
7881
- class UserConstructor extends HTMLElementToExtend {
7854
+ return class UserConstructor extends HTMLElementToExtend {
7882
7855
  constructor() {
7883
7856
  super();
7884
7857
  upgradeCallback(this);
7885
7858
  }
7886
- }
7887
- // Do not unnecessarily add a connectedCallback/disconnectedCallback, as it introduces perf overhead
7888
- // See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
7889
- if (!isUndefined$1(connectedCallback)) {
7890
- UserConstructor.prototype.connectedCallback = function () {
7891
- connectedCallback(this);
7892
- };
7893
- }
7894
- if (!isUndefined$1(disconnectedCallback)) {
7895
- UserConstructor.prototype.disconnectedCallback = function () {
7896
- disconnectedCallback(this);
7897
- };
7898
- }
7899
- return UserConstructor;
7859
+ // Note that there is no need to do the "avoid defining connectedCallback/disconnectedCallback" optimization
7860
+ // here, because in create-scoped-registry.ts, the registered class will always have these callbacks anyway.
7861
+ // See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
7862
+ connectedCallback() {
7863
+ if (!isUndefined$1(connectedCallback)) {
7864
+ connectedCallback(this);
7865
+ }
7866
+ }
7867
+ disconnectedCallback() {
7868
+ if (!isUndefined$1(disconnectedCallback)) {
7869
+ disconnectedCallback(this);
7870
+ }
7871
+ }
7872
+ };
7900
7873
  };
7901
7874
  function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
7902
7875
  if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
@@ -8000,7 +7973,7 @@ var LWC = (function (exports) {
8000
7973
  function isNull(obj) {
8001
7974
  return obj === null;
8002
7975
  }
8003
- /** version: 2.31.1 */
7976
+ /** version: 2.32.1 */
8004
7977
 
8005
7978
  /*
8006
7979
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8561,7 +8534,7 @@ var LWC = (function (exports) {
8561
8534
  });
8562
8535
  freeze(LightningElement);
8563
8536
  seal(LightningElement.prototype);
8564
- /* version: 2.31.1 */
8537
+ /* version: 2.32.1 */
8565
8538
 
8566
8539
  exports.LightningElement = LightningElement;
8567
8540
  exports.__unstable__ProfilerControl = profilerControl;