@lwc/engine-core 2.32.0 → 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.
@@ -562,7 +562,7 @@ function patchElementWithRestrictions(elm, options) {
562
562
  }),
563
563
  };
564
564
  // Apply extra restriction related to DOM manipulation if the element is not a portal.
565
- if (!options.isLight && !options.isPortal) {
565
+ if (!options.isLight && options.isSynthetic && !options.isPortal) {
566
566
  const { appendChild, insertBefore, removeChild, replaceChild } = elm;
567
567
  const originalNodeValueDescriptor = shared.getPropertyDescriptor(elm, 'nodeValue');
568
568
  const originalInnerHTMLDescriptor = shared.getPropertyDescriptor(elm, 'innerHTML');
@@ -1816,60 +1816,6 @@ function createObservedFieldPropertyDescriptor(key) {
1816
1816
  };
1817
1817
  }
1818
1818
 
1819
- /*
1820
- * Copyright (c) 2018, salesforce.com, inc.
1821
- * All rights reserved.
1822
- * SPDX-License-Identifier: MIT
1823
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1824
- */
1825
- const DUMMY_ACCESSOR_REACTIVE_OBSERVER = {
1826
- observe(job) {
1827
- job();
1828
- },
1829
- reset() { },
1830
- link() { },
1831
- };
1832
- class AccessorReactiveObserver extends ReactiveObserver {
1833
- constructor(vm, set) {
1834
- super(() => {
1835
- if (shared.isFalse(this.debouncing)) {
1836
- this.debouncing = true;
1837
- addCallbackToNextTick(() => {
1838
- if (shared.isTrue(this.debouncing)) {
1839
- const { value } = this;
1840
- const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
1841
- set.call(component, value);
1842
- // de-bouncing after the call to the original setter to prevent
1843
- // infinity loop if the setter itself is mutating things that
1844
- // were accessed during the previous invocation.
1845
- this.debouncing = false;
1846
- if (shared.isTrue(vm.isDirty) && shared.isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
1847
- // immediate rehydration due to a setter driven mutation, otherwise
1848
- // the component will get rendered on the second tick, which it is not
1849
- // desirable.
1850
- rerenderVM(vm);
1851
- }
1852
- }
1853
- });
1854
- }
1855
- });
1856
- this.debouncing = false;
1857
- }
1858
- reset(value) {
1859
- super.reset();
1860
- this.debouncing = false;
1861
- if (arguments.length > 0) {
1862
- this.value = value;
1863
- }
1864
- }
1865
- }
1866
- function createAccessorReactiveObserver(vm, set) {
1867
- // On the server side, we don't need mutation tracking. Skipping it improves performance.
1868
- return process.env.IS_BROWSER
1869
- ? new AccessorReactiveObserver(vm, set)
1870
- : DUMMY_ACCESSOR_REACTIVE_OBSERVER;
1871
- }
1872
-
1873
1819
  /*
1874
1820
  * Copyright (c) 2018, salesforce.com, inc.
1875
1821
  * All rights reserved.
@@ -1877,90 +1823,71 @@ function createAccessorReactiveObserver(vm, set) {
1877
1823
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1878
1824
  */
1879
1825
  function api$1() {
1880
- if (process.env.NODE_ENV !== 'production') {
1881
- shared.assert.fail(`@api decorator can only be used as a decorator function.`);
1882
- }
1883
- throw new Error();
1826
+ if (process.env.NODE_ENV !== 'production') {
1827
+ shared.assert.fail(`@api decorator can only be used as a decorator function.`);
1828
+ }
1829
+ throw new Error();
1884
1830
  }
1885
1831
  function createPublicPropertyDescriptor(key) {
1886
- return {
1887
- get() {
1888
- const vm = getAssociatedVM(this);
1889
- if (isBeingConstructed(vm)) {
1890
- if (process.env.NODE_ENV !== 'production') {
1891
- logError(`Can’t read the value of property \`${shared.toString(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);
1892
- }
1893
- return;
1894
- }
1895
- componentValueObserved(vm, key);
1896
- return vm.cmpProps[key];
1897
- },
1898
- set(newValue) {
1899
- const vm = getAssociatedVM(this);
1900
- if (process.env.NODE_ENV !== 'production') {
1901
- const vmBeingRendered = getVMBeingRendered();
1902
- shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
1903
- shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
1904
- }
1905
- vm.cmpProps[key] = newValue;
1906
- componentValueMutated(vm, key);
1907
- },
1908
- enumerable: true,
1909
- configurable: true
1910
- };
1832
+ return {
1833
+ get() {
1834
+ const vm = getAssociatedVM(this);
1835
+ if (isBeingConstructed(vm)) {
1836
+ if (process.env.NODE_ENV !== 'production') {
1837
+ logError(`Can’t read the value of property \`${shared.toString(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);
1838
+ }
1839
+ return;
1840
+ }
1841
+ componentValueObserved(vm, key);
1842
+ return vm.cmpProps[key];
1843
+ },
1844
+ set(newValue) {
1845
+ const vm = getAssociatedVM(this);
1846
+ if (process.env.NODE_ENV !== 'production') {
1847
+ const vmBeingRendered = getVMBeingRendered();
1848
+ shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
1849
+ shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
1850
+ }
1851
+ vm.cmpProps[key] = newValue;
1852
+ componentValueMutated(vm, key);
1853
+ },
1854
+ enumerable: true,
1855
+ configurable: true,
1856
+ };
1911
1857
  }
1912
1858
  function createPublicAccessorDescriptor(key, descriptor) {
1913
- const {
1914
- get,
1915
- set,
1916
- enumerable,
1917
- configurable
1918
- } = descriptor;
1919
- if (!shared.isFunction(get)) {
1920
- if (process.env.NODE_ENV !== 'production') {
1921
- shared.assert.invariant(shared.isFunction(get), `Invalid compiler output for public accessor ${shared.toString(key)} decorated with @api`);
1922
- }
1923
- throw new Error();
1924
- }
1925
- return {
1926
- get() {
1927
- if (process.env.NODE_ENV !== 'production') {
1928
- // Assert that the this value is an actual Component with an associated VM.
1929
- getAssociatedVM(this);
1930
- }
1931
- return get.call(this);
1932
- },
1933
- set(newValue) {
1934
- const vm = getAssociatedVM(this);
1935
- if (process.env.NODE_ENV !== 'production') {
1936
- const vmBeingRendered = getVMBeingRendered();
1937
- shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
1938
- shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
1939
- }
1940
- if (set) {
1941
- if (features.lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
1942
- let ro = vm.oar[key];
1943
- if (shared.isUndefined(ro)) {
1944
- ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
1945
- }
1946
- // every time we invoke this setter from outside (through this wrapper setter)
1947
- // we should reset the value and then debounce just in case there is a pending
1948
- // invocation the next tick that is not longer relevant since the value is changing
1949
- // from outside.
1950
- ro.reset(newValue);
1951
- ro.observe(() => {
1952
- set.call(this, newValue);
1953
- });
1954
- } else {
1955
- set.call(this, newValue);
1859
+ const { get, set, enumerable, configurable } = descriptor;
1860
+ if (!shared.isFunction(get)) {
1861
+ if (process.env.NODE_ENV !== 'production') {
1862
+ shared.assert.invariant(shared.isFunction(get), `Invalid compiler output for public accessor ${shared.toString(key)} decorated with @api`);
1956
1863
  }
1957
- } else if (process.env.NODE_ENV !== 'production') {
1958
- shared.assert.fail(`Invalid attempt to set a new value for property ${shared.toString(key)} of ${vm} that does not has a setter decorated with @api.`);
1959
- }
1960
- },
1961
- enumerable,
1962
- configurable
1963
- };
1864
+ throw new Error();
1865
+ }
1866
+ return {
1867
+ get() {
1868
+ if (process.env.NODE_ENV !== 'production') {
1869
+ // Assert that the this value is an actual Component with an associated VM.
1870
+ getAssociatedVM(this);
1871
+ }
1872
+ return get.call(this);
1873
+ },
1874
+ set(newValue) {
1875
+ const vm = getAssociatedVM(this);
1876
+ if (process.env.NODE_ENV !== 'production') {
1877
+ const vmBeingRendered = getVMBeingRendered();
1878
+ shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
1879
+ shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
1880
+ }
1881
+ if (set) {
1882
+ set.call(this, newValue);
1883
+ }
1884
+ else if (process.env.NODE_ENV !== 'production') {
1885
+ shared.assert.fail(`Invalid attempt to set a new value for property ${shared.toString(key)} of ${vm} that does not has a setter decorated with @api.`);
1886
+ }
1887
+ },
1888
+ enumerable,
1889
+ configurable,
1890
+ };
1964
1891
  }
1965
1892
 
1966
1893
  /*
@@ -2286,12 +2213,6 @@ function checkVersionMismatch(func, type) {
2286
2213
  }
2287
2214
  }
2288
2215
 
2289
- /*
2290
- * Copyright (c) 2018, salesforce.com, inc.
2291
- * All rights reserved.
2292
- * SPDX-License-Identifier: MIT
2293
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2294
- */
2295
2216
  const signedTemplateSet = new Set();
2296
2217
  function defaultEmptyTemplate() {
2297
2218
  return [];
@@ -2309,32 +2230,6 @@ function registerTemplate(tpl) {
2309
2230
  checkVersionMismatch(tpl, 'template');
2310
2231
  }
2311
2232
  signedTemplateSet.add(tpl);
2312
- // FIXME[@W-10950976]: the template object should be frozen, and it should not be possible to set
2313
- // the stylesheets or stylesheetToken(s). For backwards compat, though, we shim stylesheetTokens
2314
- // on top of stylesheetToken for anyone who is accessing the old internal API.
2315
- // Details: https://salesforce.quip.com/v1rmAFu2cKAr
2316
- shared.defineProperty(tpl, 'stylesheetTokens', {
2317
- enumerable: true,
2318
- configurable: true,
2319
- get() {
2320
- const { stylesheetToken } = this;
2321
- if (shared.isUndefined(stylesheetToken)) {
2322
- return stylesheetToken;
2323
- }
2324
- // Shim for the old `stylesheetTokens` property
2325
- // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
2326
- return {
2327
- hostAttribute: `${stylesheetToken}-host`,
2328
- shadowAttribute: stylesheetToken,
2329
- };
2330
- },
2331
- set(value) {
2332
- // If the value is null or some other exotic object, you would be broken anyway in the past
2333
- // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
2334
- // However it may be undefined in newer versions of LWC, so we need to guard against that case.
2335
- this.stylesheetToken = shared.isUndefined(value) ? undefined : value.shadowAttribute;
2336
- },
2337
- });
2338
2233
  // chaining this method as a way to wrap existing
2339
2234
  // assignment of templates easily, without too much transformation
2340
2235
  return tpl;
@@ -3875,11 +3770,13 @@ function applyDomManual(elm, vnode) {
3875
3770
  function applyElementRestrictions(elm, vnode) {
3876
3771
  var _a, _b;
3877
3772
  if (process.env.NODE_ENV !== 'production') {
3773
+ const isSynthetic = vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
3878
3774
  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 */;
3879
3775
  const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
3880
3776
  patchElementWithRestrictions(elm, {
3881
3777
  isPortal,
3882
- isLight
3778
+ isLight,
3779
+ isSynthetic
3883
3780
  });
3884
3781
  }
3885
3782
  }
@@ -4295,7 +4192,7 @@ function s(slotName, data, children, slotset) {
4295
4192
  // undefined is for root components, but root components cannot accept slotted content
4296
4193
  setVMBeingRendered(slotset.owner);
4297
4194
  try {
4298
- shared.ArrayPush.apply(newChildren, vnode.factory(data.slotData));
4195
+ shared.ArrayPush.call(newChildren, vnode.factory(data.slotData, data.key));
4299
4196
  }
4300
4197
  finally {
4301
4198
  setVMBeingRendered(vmBeingRenderedInception);
@@ -5175,15 +5072,10 @@ function resetComponentStateWhenRemoved(vm) {
5175
5072
  } = vm;
5176
5073
  if (state !== 2 /* VMState.disconnected */) {
5177
5074
  const {
5178
- oar,
5179
5075
  tro
5180
5076
  } = vm;
5181
5077
  // Making sure that any observing record will not trigger the rehydrated on this vm
5182
5078
  tro.reset();
5183
- // Making sure that any observing accessor record will not trigger the setter to be reinvoked
5184
- for (const key in oar) {
5185
- oar[key].reset();
5186
- }
5187
5079
  runDisconnectedCallback(vm);
5188
5080
  // Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
5189
5081
  runChildNodesDisconnectedCallback(vm);
@@ -5236,7 +5128,6 @@ function createVM(elm, ctor, renderer, options) {
5236
5128
  cmpSlots: {
5237
5129
  slotAssignments: shared.create(null)
5238
5130
  },
5239
- oar: shared.create(null),
5240
5131
  cmpTemplate: null,
5241
5132
  hydrated: Boolean(hydrated),
5242
5133
  renderMode: def.renderMode,
@@ -6420,94 +6311,166 @@ function setHooks(hooks) {
6420
6311
  // See @lwc/engine-core/src/framework/template.ts
6421
6312
  const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
6422
6313
  // Via https://www.npmjs.com/package/object-observer
6423
- const ARRAY_MUTATION_METHODS = [
6424
- 'pop',
6425
- 'push',
6426
- 'shift',
6427
- 'unshift',
6428
- 'reverse',
6429
- 'sort',
6430
- 'fill',
6431
- 'splice',
6432
- 'copyWithin',
6433
- ];
6314
+ const ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
6315
+ // Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
6316
+ const STYLESHEET_FUNCTION_EXPANDOS = [
6317
+ // SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
6318
+ '$scoped$'];
6434
6319
  function getOriginalArrayMethod(prop) {
6435
- switch (prop) {
6436
- case 'pop':
6437
- return shared.ArrayPop;
6438
- case 'push':
6439
- return shared.ArrayPush;
6440
- case 'shift':
6441
- return shared.ArrayShift;
6442
- case 'unshift':
6443
- return shared.ArrayUnshift;
6444
- case 'reverse':
6445
- return shared.ArrayReverse;
6446
- case 'sort':
6447
- return shared.ArraySort;
6448
- case 'fill':
6449
- return shared.ArrayFill;
6450
- case 'splice':
6451
- return shared.ArraySplice;
6452
- case 'copyWithin':
6453
- return shared.ArrayCopyWithin;
6454
- }
6320
+ switch (prop) {
6321
+ case 'pop':
6322
+ return shared.ArrayPop;
6323
+ case 'push':
6324
+ return shared.ArrayPush;
6325
+ case 'shift':
6326
+ return shared.ArrayShift;
6327
+ case 'unshift':
6328
+ return shared.ArrayUnshift;
6329
+ case 'reverse':
6330
+ return shared.ArrayReverse;
6331
+ case 'sort':
6332
+ return shared.ArraySort;
6333
+ case 'fill':
6334
+ return shared.ArrayFill;
6335
+ case 'splice':
6336
+ return shared.ArraySplice;
6337
+ case 'copyWithin':
6338
+ return shared.ArrayCopyWithin;
6339
+ }
6455
6340
  }
6456
6341
  let mutationWarningsSilenced = false;
6457
- // Warn if the user tries to mutate tmpl.stylesheets, e.g.:
6342
+ // Warn if the user tries to mutate a stylesheets array, e.g.:
6458
6343
  // `tmpl.stylesheets.push(someStylesheetFunction)`
6459
6344
  function warnOnArrayMutation(stylesheets) {
6460
- // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
6461
- // we can at least warn when they use the most common mutation methods.
6462
- for (const prop of ARRAY_MUTATION_METHODS) {
6463
- const originalArrayMethod = getOriginalArrayMethod(prop);
6464
- stylesheets[prop] = function arrayMutationWarningWrapper() {
6465
- logError(`Mutating the "stylesheets" array on a template function ` +
6466
- `is deprecated and may be removed in a future version of LWC.`);
6467
- // @ts-ignore
6468
- return originalArrayMethod.apply(this, arguments);
6469
- };
6345
+ // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
6346
+ // we can at least warn when they use the most common mutation methods.
6347
+ for (const prop of ARRAY_MUTATION_METHODS) {
6348
+ const originalArrayMethod = getOriginalArrayMethod(prop);
6349
+ stylesheets[prop] = function arrayMutationWarningWrapper() {
6350
+ logError(`Mutating the "stylesheets" array on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6351
+ // @ts-ignore
6352
+ return originalArrayMethod.apply(this, arguments);
6353
+ };
6354
+ }
6355
+ }
6356
+ // Warn if the user tries to mutate a stylesheet factory function, e.g.:
6357
+ // `stylesheet.$scoped$ = true`
6358
+ function warnOnStylesheetFunctionMutation(stylesheet) {
6359
+ // We could warn on other properties, but in practice only certain expandos are meaningful to LWC at runtime
6360
+ for (const prop of STYLESHEET_FUNCTION_EXPANDOS) {
6361
+ let value = stylesheet[prop];
6362
+ shared.defineProperty(stylesheet, prop, {
6363
+ enumerable: true,
6364
+ configurable: true,
6365
+ get() {
6366
+ return value;
6367
+ },
6368
+ set(newValue) {
6369
+ logError(`Dynamically setting the "${prop}" property on a stylesheet function ` + `is deprecated and may be removed in a future version of LWC.`);
6370
+ value = newValue;
6371
+ }
6372
+ });
6373
+ }
6374
+ }
6375
+ // Warn on either array or stylesheet (function) mutation, in a deeply-nested array
6376
+ function warnOnStylesheetsMutation(stylesheets) {
6377
+ traverseStylesheets(stylesheets, subStylesheets => {
6378
+ if (shared.isArray(subStylesheets)) {
6379
+ warnOnArrayMutation(subStylesheets);
6380
+ } else {
6381
+ warnOnStylesheetFunctionMutation(subStylesheets);
6470
6382
  }
6383
+ });
6384
+ }
6385
+ // Deeply freeze the entire array (of arrays) of stylesheet factory functions
6386
+ function deepFreeze(stylesheets) {
6387
+ traverseStylesheets(stylesheets, subStylesheets => {
6388
+ shared.freeze(subStylesheets);
6389
+ });
6390
+ }
6391
+ // Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
6392
+ function traverseStylesheets(stylesheets, callback) {
6393
+ callback(stylesheets);
6394
+ for (let i = 0; i < stylesheets.length; i++) {
6395
+ const stylesheet = stylesheets[i];
6396
+ if (shared.isArray(stylesheet)) {
6397
+ traverseStylesheets(stylesheet, callback);
6398
+ } else {
6399
+ callback(stylesheet);
6400
+ }
6401
+ }
6471
6402
  }
6472
- // TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
6473
- // just warns on mutation.
6474
6403
  function freezeTemplate(tmpl) {
6404
+ if (features.lwcRuntimeFlags.ENABLE_FROZEN_TEMPLATE) {
6405
+ // Deep freeze the template
6406
+ shared.freeze(tmpl);
6407
+ if (!shared.isUndefined(tmpl.stylesheets)) {
6408
+ deepFreeze(tmpl.stylesheets);
6409
+ }
6410
+ } else {
6411
+ // TODO [#2782]: remove this flag and delete the legacy behavior
6412
+ // When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
6413
+ // is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
6414
+ shared.defineProperty(tmpl, 'stylesheetTokens', {
6415
+ enumerable: true,
6416
+ configurable: true,
6417
+ get() {
6418
+ const {
6419
+ stylesheetToken
6420
+ } = this;
6421
+ if (shared.isUndefined(stylesheetToken)) {
6422
+ return stylesheetToken;
6423
+ }
6424
+ // Shim for the old `stylesheetTokens` property
6425
+ // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
6426
+ return {
6427
+ hostAttribute: `${stylesheetToken}-host`,
6428
+ shadowAttribute: stylesheetToken
6429
+ };
6430
+ },
6431
+ set(value) {
6432
+ // If the value is null or some other exotic object, you would be broken anyway in the past
6433
+ // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
6434
+ // However it may be undefined in newer versions of LWC, so we need to guard against that case.
6435
+ this.stylesheetToken = shared.isUndefined(value) ? undefined : value.shadowAttribute;
6436
+ }
6437
+ });
6438
+ // When ENABLE_FROZEN_TEMPLATE is false, warn in dev mode whenever someone is mutating the template
6475
6439
  if (process.env.NODE_ENV !== 'production') {
6476
- if (!shared.isUndefined(tmpl.stylesheets)) {
6477
- warnOnArrayMutation(tmpl.stylesheets);
6478
- }
6479
- for (const prop of TEMPLATE_PROPS) {
6480
- let value = tmpl[prop];
6481
- shared.defineProperty(tmpl, prop, {
6482
- enumerable: true,
6483
- configurable: true,
6484
- get() {
6485
- return value;
6486
- },
6487
- set(newValue) {
6488
- if (!mutationWarningsSilenced) {
6489
- logError(`Dynamically setting the "${prop}" property on a template function ` +
6490
- `is deprecated and may be removed in a future version of LWC.`);
6491
- }
6492
- value = newValue;
6493
- },
6494
- });
6495
- }
6496
- const originalDescriptor = shared.getOwnPropertyDescriptor(tmpl, 'stylesheetTokens');
6497
- shared.defineProperty(tmpl, 'stylesheetTokens', {
6498
- enumerable: true,
6499
- configurable: true,
6500
- get: originalDescriptor.get,
6501
- set(value) {
6502
- logError(`Dynamically setting the "stylesheetTokens" property on a template function ` +
6503
- `is deprecated and may be removed in a future version of LWC.`);
6504
- // Avoid logging twice (for both stylesheetToken and stylesheetTokens)
6505
- mutationWarningsSilenced = true;
6506
- originalDescriptor.set.call(this, value);
6507
- mutationWarningsSilenced = false;
6508
- },
6440
+ if (!shared.isUndefined(tmpl.stylesheets)) {
6441
+ warnOnStylesheetsMutation(tmpl.stylesheets);
6442
+ }
6443
+ for (const prop of TEMPLATE_PROPS) {
6444
+ let value = tmpl[prop];
6445
+ shared.defineProperty(tmpl, prop, {
6446
+ enumerable: true,
6447
+ configurable: true,
6448
+ get() {
6449
+ return value;
6450
+ },
6451
+ set(newValue) {
6452
+ if (!mutationWarningsSilenced) {
6453
+ logError(`Dynamically setting the "${prop}" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6454
+ }
6455
+ value = newValue;
6456
+ }
6509
6457
  });
6458
+ }
6459
+ const originalDescriptor = shared.getOwnPropertyDescriptor(tmpl, 'stylesheetTokens');
6460
+ shared.defineProperty(tmpl, 'stylesheetTokens', {
6461
+ enumerable: true,
6462
+ configurable: true,
6463
+ get: originalDescriptor.get,
6464
+ set(value) {
6465
+ logError(`Dynamically setting the "stylesheetTokens" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
6466
+ // Avoid logging twice (for both stylesheetToken and stylesheetTokens)
6467
+ mutationWarningsSilenced = true;
6468
+ originalDescriptor.set.call(this, value);
6469
+ mutationWarningsSilenced = false;
6470
+ }
6471
+ });
6510
6472
  }
6473
+ }
6511
6474
  }
6512
6475
 
6513
6476
  /*
@@ -6570,4 +6533,4 @@ exports.swapTemplate = swapTemplate;
6570
6533
  exports.track = track;
6571
6534
  exports.unwrap = unwrap;
6572
6535
  exports.wire = wire;
6573
- /* version: 2.32.0 */
6536
+ /* version: 2.32.1 */