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