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
@@ -7,8 +7,6 @@
7
7
  function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf2(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
8
8
  function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
9
9
  function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
10
- function _get2() { if (typeof Reflect !== "undefined" && Reflect.get) { _get2 = Reflect.get.bind(); } else { _get2 = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get2.apply(this, arguments); }
11
- function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf2(object); if (object === null) break; } return object; }
12
10
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
11
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
14
12
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
@@ -349,9 +347,9 @@
349
347
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
350
348
  */
351
349
  // Increment whenever the LWC template compiler changes
352
- var LWC_VERSION = "2.31.1";
350
+ var LWC_VERSION = "2.32.1";
353
351
  var LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
354
- /** version: 2.31.1 */
352
+ /** version: 2.32.1 */
355
353
 
356
354
  /**
357
355
  * Copyright (C) 2018 salesforce.com, inc.
@@ -432,7 +430,7 @@
432
430
  patch$1(propName);
433
431
  }
434
432
  }
435
- /** version: 2.31.1 */
433
+ /** version: 2.32.1 */
436
434
 
437
435
  /**
438
436
  * Copyright (C) 2018 salesforce.com, inc.
@@ -446,19 +444,14 @@
446
444
  */
447
445
  var features = {
448
446
  DUMMY_TEST_FLAG: null,
449
- ENABLE_ELEMENT_PATCH: null,
450
447
  ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
451
- ENABLE_HTML_COLLECTIONS_PATCH: null,
452
- ENABLE_INNER_OUTER_TEXT_PATCH: null,
453
448
  ENABLE_MIXED_SHADOW_MODE: null,
454
449
  ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
455
- ENABLE_NODE_LIST_PATCH: null,
456
- ENABLE_NODE_PATCH: null,
457
- ENABLE_REACTIVE_SETTER: null,
458
450
  ENABLE_WIRE_SYNC_EMIT: null,
459
451
  ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
460
452
  DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
461
- ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null
453
+ ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
454
+ ENABLE_FROZEN_TEMPLATE: null
462
455
  };
463
456
  if (!_globalThis.lwcRuntimeFlags) {
464
457
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
@@ -514,7 +507,7 @@
514
507
  setFeatureFlag(name, value);
515
508
  }
516
509
  }
517
- /** version: 2.31.1 */
510
+ /** version: 2.32.1 */
518
511
 
519
512
  /*
520
513
  * Copyright (c) 2018, salesforce.com, inc.
@@ -1102,7 +1095,7 @@
1102
1095
  })
1103
1096
  };
1104
1097
  // Apply extra restriction related to DOM manipulation if the element is not a portal.
1105
- if (!options.isLight && !options.isPortal) {
1098
+ if (!options.isLight && options.isSynthetic && !options.isPortal) {
1106
1099
  var appendChild = elm.appendChild,
1107
1100
  insertBefore = elm.insertBefore,
1108
1101
  removeChild = elm.removeChild,
@@ -2498,56 +2491,6 @@
2498
2491
  configurable: true
2499
2492
  };
2500
2493
  }
2501
- var AccessorReactiveObserver = /*#__PURE__*/function (_ReactiveObserver) {
2502
- _inherits(AccessorReactiveObserver, _ReactiveObserver);
2503
- var _super3 = _createSuper(AccessorReactiveObserver);
2504
- function AccessorReactiveObserver(vm, set) {
2505
- var _this2;
2506
- _classCallCheck(this, AccessorReactiveObserver);
2507
- _this2 = _super3.call(this, function () {
2508
- if (isFalse(_this2.debouncing)) {
2509
- _this2.debouncing = true;
2510
- addCallbackToNextTick(function () {
2511
- if (isTrue(_this2.debouncing)) {
2512
- var _assertThisInitialize = _assertThisInitialized(_this2),
2513
- value = _assertThisInitialize.value;
2514
- var dirtyStateBeforeSetterCall = vm.isDirty,
2515
- component = vm.component,
2516
- _idx = vm.idx;
2517
- set.call(component, value);
2518
- // de-bouncing after the call to the original setter to prevent
2519
- // infinity loop if the setter itself is mutating things that
2520
- // were accessed during the previous invocation.
2521
- _this2.debouncing = false;
2522
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && _idx > 0) {
2523
- // immediate rehydration due to a setter driven mutation, otherwise
2524
- // the component will get rendered on the second tick, which it is not
2525
- // desirable.
2526
- rerenderVM(vm);
2527
- }
2528
- }
2529
- });
2530
- }
2531
- });
2532
- _this2.debouncing = false;
2533
- return _this2;
2534
- }
2535
- _createClass(AccessorReactiveObserver, [{
2536
- key: "reset",
2537
- value: function reset(value) {
2538
- _get2(_getPrototypeOf2(AccessorReactiveObserver.prototype), "reset", this).call(this);
2539
- this.debouncing = false;
2540
- if (arguments.length > 0) {
2541
- this.value = value;
2542
- }
2543
- }
2544
- }]);
2545
- return AccessorReactiveObserver;
2546
- }(ReactiveObserver);
2547
- function createAccessorReactiveObserver(vm, set) {
2548
- // On the server side, we don't need mutation tracking. Skipping it improves performance.
2549
- return new AccessorReactiveObserver(vm, set);
2550
- }
2551
2494
 
2552
2495
  /*
2553
2496
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2589,13 +2532,13 @@
2589
2532
  };
2590
2533
  }
2591
2534
  function createPublicAccessorDescriptor(key, descriptor) {
2592
- var _get3 = descriptor.get,
2535
+ var _get2 = descriptor.get,
2593
2536
  _set2 = descriptor.set,
2594
2537
  enumerable = descriptor.enumerable,
2595
2538
  configurable = descriptor.configurable;
2596
- if (!isFunction$1(_get3)) {
2539
+ if (!isFunction$1(_get2)) {
2597
2540
  if (process.env.NODE_ENV !== 'production') {
2598
- assert.invariant(isFunction$1(_get3), "Invalid compiler output for public accessor ".concat(toString$1(key), " decorated with @api"));
2541
+ assert.invariant(isFunction$1(_get2), "Invalid compiler output for public accessor ".concat(toString$1(key), " decorated with @api"));
2599
2542
  }
2600
2543
  throw new Error();
2601
2544
  }
@@ -2605,10 +2548,9 @@
2605
2548
  // Assert that the this value is an actual Component with an associated VM.
2606
2549
  getAssociatedVM(this);
2607
2550
  }
2608
- return _get3.call(this);
2551
+ return _get2.call(this);
2609
2552
  },
2610
2553
  set: function set(newValue) {
2611
- var _this3 = this;
2612
2554
  var vm = getAssociatedVM(this);
2613
2555
  if (process.env.NODE_ENV !== 'production') {
2614
2556
  var _vmBeingRendered4 = getVMBeingRendered();
@@ -2616,22 +2558,7 @@
2616
2558
  assert.invariant(!isUpdatingTemplate, "Updating the template of ".concat(_vmBeingRendered4, " has side effects on the state of ").concat(vm, ".").concat(toString$1(key)));
2617
2559
  }
2618
2560
  if (_set2) {
2619
- if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
2620
- var ro = vm.oar[key];
2621
- if (isUndefined$1(ro)) {
2622
- ro = vm.oar[key] = createAccessorReactiveObserver(vm, _set2);
2623
- }
2624
- // every time we invoke this setter from outside (through this wrapper setter)
2625
- // we should reset the value and then debounce just in case there is a pending
2626
- // invocation the next tick that is not longer relevant since the value is changing
2627
- // from outside.
2628
- ro.reset(newValue);
2629
- ro.observe(function () {
2630
- _set2.call(_this3, newValue);
2631
- });
2632
- } else {
2633
- _set2.call(this, newValue);
2634
- }
2561
+ _set2.call(this, newValue);
2635
2562
  } else if (process.env.NODE_ENV !== 'production') {
2636
2563
  assert.fail("Invalid attempt to set a new value for property ".concat(toString$1(key), " of ").concat(vm, " that does not has a setter decorated with @api."));
2637
2564
  }
@@ -2970,13 +2897,6 @@
2970
2897
  }
2971
2898
  }
2972
2899
  }
2973
-
2974
- /*
2975
- * Copyright (c) 2018, salesforce.com, inc.
2976
- * All rights reserved.
2977
- * SPDX-License-Identifier: MIT
2978
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2979
- */
2980
2900
  var signedTemplateSet = new Set();
2981
2901
  function defaultEmptyTemplate() {
2982
2902
  return [];
@@ -2994,32 +2914,6 @@
2994
2914
  checkVersionMismatch(tpl, 'template');
2995
2915
  }
2996
2916
  signedTemplateSet.add(tpl);
2997
- // FIXME[@W-10950976]: the template object should be frozen, and it should not be possible to set
2998
- // the stylesheets or stylesheetToken(s). For backwards compat, though, we shim stylesheetTokens
2999
- // on top of stylesheetToken for anyone who is accessing the old internal API.
3000
- // Details: https://salesforce.quip.com/v1rmAFu2cKAr
3001
- defineProperty(tpl, 'stylesheetTokens', {
3002
- enumerable: true,
3003
- configurable: true,
3004
- get: function get() {
3005
- var stylesheetToken = this.stylesheetToken;
3006
- if (isUndefined$1(stylesheetToken)) {
3007
- return stylesheetToken;
3008
- }
3009
- // Shim for the old `stylesheetTokens` property
3010
- // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
3011
- return {
3012
- hostAttribute: "".concat(stylesheetToken, "-host"),
3013
- shadowAttribute: stylesheetToken
3014
- };
3015
- },
3016
- set: function set(value) {
3017
- // If the value is null or some other exotic object, you would be broken anyway in the past
3018
- // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
3019
- // However it may be undefined in newer versions of LWC, so we need to guard against that case.
3020
- this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
3021
- }
3022
- });
3023
2917
  // chaining this method as a way to wrap existing
3024
2918
  // assignment of templates easily, without too much transformation
3025
2919
  return tpl;
@@ -3120,10 +3014,10 @@
3120
3014
  if (isFunction$1(SuperClass)) {
3121
3015
  HTMLBridgeElement = /*#__PURE__*/function (_SuperClass) {
3122
3016
  _inherits(HTMLBridgeElement, _SuperClass);
3123
- var _super4 = _createSuper(HTMLBridgeElement);
3017
+ var _super3 = _createSuper(HTMLBridgeElement);
3124
3018
  function HTMLBridgeElement() {
3125
3019
  _classCallCheck(this, HTMLBridgeElement);
3126
- return _super4.apply(this, arguments);
3020
+ return _super3.apply(this, arguments);
3127
3021
  }
3128
3022
  return _createClass(HTMLBridgeElement);
3129
3023
  }(SuperClass);
@@ -4521,11 +4415,13 @@
4521
4415
  function applyElementRestrictions(elm, vnode) {
4522
4416
  var _a, _b;
4523
4417
  if (process.env.NODE_ENV !== 'production') {
4418
+ var isSynthetic = vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
4524
4419
  var 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 */;
4525
4420
  var isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
4526
4421
  patchElementWithRestrictions(elm, {
4527
4422
  isPortal: isPortal,
4528
- isLight: isLight
4423
+ isLight: isLight,
4424
+ isSynthetic: isSynthetic
4529
4425
  });
4530
4426
  }
4531
4427
  }
@@ -4929,7 +4825,7 @@
4929
4825
  // undefined is for root components, but root components cannot accept slotted content
4930
4826
  setVMBeingRendered(slotset.owner);
4931
4827
  try {
4932
- ArrayPush$1.apply(newChildren, vnode.factory(data.slotData));
4828
+ ArrayPush$1.call(newChildren, vnode.factory(data.slotData, data.key));
4933
4829
  } finally {
4934
4830
  setVMBeingRendered(vmBeingRenderedInception);
4935
4831
  }
@@ -5815,14 +5711,9 @@
5815
5711
  function resetComponentStateWhenRemoved(vm) {
5816
5712
  var state = vm.state;
5817
5713
  if (state !== 2 /* VMState.disconnected */) {
5818
- var oar = vm.oar,
5819
- tro = vm.tro;
5714
+ var tro = vm.tro;
5820
5715
  // Making sure that any observing record will not trigger the rehydrated on this vm
5821
5716
  tro.reset();
5822
- // Making sure that any observing accessor record will not trigger the setter to be reinvoked
5823
- for (var key in oar) {
5824
- oar[key].reset();
5825
- }
5826
5717
  runDisconnectedCallback(vm);
5827
5718
  // Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
5828
5719
  runChildNodesDisconnectedCallback(vm);
@@ -5873,7 +5764,6 @@
5873
5764
  cmpSlots: {
5874
5765
  slotAssignments: create(null)
5875
5766
  },
5876
- oar: create(null),
5877
5767
  cmpTemplate: null,
5878
5768
  hydrated: Boolean(hydrated),
5879
5769
  renderMode: def.renderMode,
@@ -6265,17 +6155,17 @@
6265
6155
  var WireMetaMap = new Map();
6266
6156
  var WireContextRegistrationEvent = /*#__PURE__*/function (_CustomEvent) {
6267
6157
  _inherits(WireContextRegistrationEvent, _CustomEvent);
6268
- var _super5 = _createSuper(WireContextRegistrationEvent);
6158
+ var _super4 = _createSuper(WireContextRegistrationEvent);
6269
6159
  function WireContextRegistrationEvent(adapterToken, _ref4) {
6270
- var _this4;
6160
+ var _this2;
6271
6161
  var setNewContext = _ref4.setNewContext,
6272
6162
  setDisconnectedCallback = _ref4.setDisconnectedCallback;
6273
6163
  _classCallCheck(this, WireContextRegistrationEvent);
6274
- _this4 = _super5.call(this, adapterToken, {
6164
+ _this2 = _super4.call(this, adapterToken, {
6275
6165
  bubbles: true,
6276
6166
  composed: true
6277
6167
  });
6278
- defineProperties(_assertThisInitialized(_this4), {
6168
+ defineProperties(_assertThisInitialized(_this2), {
6279
6169
  setNewContext: {
6280
6170
  value: setNewContext
6281
6171
  },
@@ -6283,7 +6173,7 @@
6283
6173
  value: setDisconnectedCallback
6284
6174
  }
6285
6175
  });
6286
- return _this4;
6176
+ return _this2;
6287
6177
  }
6288
6178
  return _createClass(WireContextRegistrationEvent);
6289
6179
  }( /*#__PURE__*/_wrapNativeSuper(CustomEvent));
@@ -7034,6 +6924,10 @@
7034
6924
  var TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
7035
6925
  // Via https://www.npmjs.com/package/object-observer
7036
6926
  var ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
6927
+ // Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
6928
+ var STYLESHEET_FUNCTION_EXPANDOS = [
6929
+ // SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
6930
+ '$scoped$'];
7037
6931
  function getOriginalArrayMethod(prop) {
7038
6932
  switch (prop) {
7039
6933
  case 'pop':
@@ -7057,7 +6951,7 @@
7057
6951
  }
7058
6952
  }
7059
6953
  var mutationWarningsSilenced = false;
7060
- // Warn if the user tries to mutate tmpl.stylesheets, e.g.:
6954
+ // Warn if the user tries to mutate a stylesheets array, e.g.:
7061
6955
  // `tmpl.stylesheets.push(someStylesheetFunction)`
7062
6956
  function warnOnArrayMutation(stylesheets) {
7063
6957
  // We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
@@ -7083,54 +6977,145 @@
7083
6977
  _iterator4.f();
7084
6978
  }
7085
6979
  }
7086
- // TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
7087
- // just warns on mutation.
6980
+ // Warn if the user tries to mutate a stylesheet factory function, e.g.:
6981
+ // `stylesheet.$scoped$ = true`
6982
+ function warnOnStylesheetFunctionMutation(stylesheet) {
6983
+ // We could warn on other properties, but in practice only certain expandos are meaningful to LWC at runtime
6984
+ var _iterator5 = _createForOfIteratorHelper(STYLESHEET_FUNCTION_EXPANDOS),
6985
+ _step5;
6986
+ try {
6987
+ var _loop3 = function _loop3() {
6988
+ var prop = _step5.value;
6989
+ var value = stylesheet[prop];
6990
+ defineProperty(stylesheet, prop, {
6991
+ enumerable: true,
6992
+ configurable: true,
6993
+ get: function get() {
6994
+ return value;
6995
+ },
6996
+ set: function set(newValue) {
6997
+ logError("Dynamically setting the \"".concat(prop, "\" property on a stylesheet function ") + "is deprecated and may be removed in a future version of LWC.");
6998
+ value = newValue;
6999
+ }
7000
+ });
7001
+ };
7002
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
7003
+ _loop3();
7004
+ }
7005
+ } catch (err) {
7006
+ _iterator5.e(err);
7007
+ } finally {
7008
+ _iterator5.f();
7009
+ }
7010
+ }
7011
+ // Warn on either array or stylesheet (function) mutation, in a deeply-nested array
7012
+ function warnOnStylesheetsMutation(stylesheets) {
7013
+ traverseStylesheets(stylesheets, function (subStylesheets) {
7014
+ if (isArray$1(subStylesheets)) {
7015
+ warnOnArrayMutation(subStylesheets);
7016
+ } else {
7017
+ warnOnStylesheetFunctionMutation(subStylesheets);
7018
+ }
7019
+ });
7020
+ }
7021
+ // Deeply freeze the entire array (of arrays) of stylesheet factory functions
7022
+ function deepFreeze(stylesheets) {
7023
+ traverseStylesheets(stylesheets, function (subStylesheets) {
7024
+ freeze(subStylesheets);
7025
+ });
7026
+ }
7027
+ // Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
7028
+ function traverseStylesheets(stylesheets, callback) {
7029
+ callback(stylesheets);
7030
+ for (var _i33 = 0; _i33 < stylesheets.length; _i33++) {
7031
+ var stylesheet = stylesheets[_i33];
7032
+ if (isArray$1(stylesheet)) {
7033
+ traverseStylesheets(stylesheet, callback);
7034
+ } else {
7035
+ callback(stylesheet);
7036
+ }
7037
+ }
7038
+ }
7088
7039
  function freezeTemplate(tmpl) {
7089
- if (process.env.NODE_ENV !== 'production') {
7040
+ if (lwcRuntimeFlags.ENABLE_FROZEN_TEMPLATE) {
7041
+ // Deep freeze the template
7042
+ freeze(tmpl);
7090
7043
  if (!isUndefined$1(tmpl.stylesheets)) {
7091
- warnOnArrayMutation(tmpl.stylesheets);
7092
- }
7093
- var _iterator5 = _createForOfIteratorHelper(TEMPLATE_PROPS),
7094
- _step5;
7095
- try {
7096
- var _loop3 = function _loop3() {
7097
- var prop = _step5.value;
7098
- var value = tmpl[prop];
7099
- defineProperty(tmpl, prop, {
7100
- enumerable: true,
7101
- configurable: true,
7102
- get: function get() {
7103
- return value;
7104
- },
7105
- set: function set(newValue) {
7106
- if (!mutationWarningsSilenced) {
7107
- logError("Dynamically setting the \"".concat(prop, "\" property on a template function ") + "is deprecated and may be removed in a future version of LWC.");
7108
- }
7109
- value = newValue;
7110
- }
7111
- });
7112
- };
7113
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
7114
- _loop3();
7115
- }
7116
- } catch (err) {
7117
- _iterator5.e(err);
7118
- } finally {
7119
- _iterator5.f();
7044
+ deepFreeze(tmpl.stylesheets);
7120
7045
  }
7121
- var originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
7046
+ } else {
7047
+ // TODO [#2782]: remove this flag and delete the legacy behavior
7048
+ // When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
7049
+ // is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
7122
7050
  defineProperty(tmpl, 'stylesheetTokens', {
7123
7051
  enumerable: true,
7124
7052
  configurable: true,
7125
- get: originalDescriptor.get,
7053
+ get: function get() {
7054
+ var stylesheetToken = this.stylesheetToken;
7055
+ if (isUndefined$1(stylesheetToken)) {
7056
+ return stylesheetToken;
7057
+ }
7058
+ // Shim for the old `stylesheetTokens` property
7059
+ // See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
7060
+ return {
7061
+ hostAttribute: "".concat(stylesheetToken, "-host"),
7062
+ shadowAttribute: stylesheetToken
7063
+ };
7064
+ },
7126
7065
  set: function set(value) {
7127
- logError("Dynamically setting the \"stylesheetTokens\" property on a template function " + "is deprecated and may be removed in a future version of LWC.");
7128
- // Avoid logging twice (for both stylesheetToken and stylesheetTokens)
7129
- mutationWarningsSilenced = true;
7130
- originalDescriptor.set.call(this, value);
7131
- mutationWarningsSilenced = false;
7066
+ // If the value is null or some other exotic object, you would be broken anyway in the past
7067
+ // because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
7068
+ // However it may be undefined in newer versions of LWC, so we need to guard against that case.
7069
+ this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
7132
7070
  }
7133
7071
  });
7072
+ // When ENABLE_FROZEN_TEMPLATE is false, warn in dev mode whenever someone is mutating the template
7073
+ if (process.env.NODE_ENV !== 'production') {
7074
+ if (!isUndefined$1(tmpl.stylesheets)) {
7075
+ warnOnStylesheetsMutation(tmpl.stylesheets);
7076
+ }
7077
+ var _iterator6 = _createForOfIteratorHelper(TEMPLATE_PROPS),
7078
+ _step6;
7079
+ try {
7080
+ var _loop4 = function _loop4() {
7081
+ var prop = _step6.value;
7082
+ var value = tmpl[prop];
7083
+ defineProperty(tmpl, prop, {
7084
+ enumerable: true,
7085
+ configurable: true,
7086
+ get: function get() {
7087
+ return value;
7088
+ },
7089
+ set: function set(newValue) {
7090
+ if (!mutationWarningsSilenced) {
7091
+ logError("Dynamically setting the \"".concat(prop, "\" property on a template function ") + "is deprecated and may be removed in a future version of LWC.");
7092
+ }
7093
+ value = newValue;
7094
+ }
7095
+ });
7096
+ };
7097
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
7098
+ _loop4();
7099
+ }
7100
+ } catch (err) {
7101
+ _iterator6.e(err);
7102
+ } finally {
7103
+ _iterator6.f();
7104
+ }
7105
+ var originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
7106
+ defineProperty(tmpl, 'stylesheetTokens', {
7107
+ enumerable: true,
7108
+ configurable: true,
7109
+ get: originalDescriptor.get,
7110
+ set: function set(value) {
7111
+ logError("Dynamically setting the \"stylesheetTokens\" property on a template function " + "is deprecated and may be removed in a future version of LWC.");
7112
+ // Avoid logging twice (for both stylesheetToken and stylesheetTokens)
7113
+ mutationWarningsSilenced = true;
7114
+ originalDescriptor.set.call(this, value);
7115
+ mutationWarningsSilenced = false;
7116
+ }
7117
+ });
7118
+ }
7134
7119
  }
7135
7120
  }
7136
7121
 
@@ -7156,7 +7141,7 @@
7156
7141
  }
7157
7142
  return ctor;
7158
7143
  }
7159
- /* version: 2.31.1 */
7144
+ /* version: 2.32.1 */
7160
7145
 
7161
7146
  /*
7162
7147
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7393,10 +7378,10 @@
7393
7378
  // which are not equipped to be initialized that way.
7394
7379
  var clazz = /*#__PURE__*/function (_HTMLElementAlias) {
7395
7380
  _inherits(clazz, _HTMLElementAlias);
7396
- var _super6 = _createSuper(clazz);
7381
+ var _super5 = _createSuper(clazz);
7397
7382
  function clazz() {
7398
7383
  _classCallCheck(this, clazz);
7399
- return _super6.apply(this, arguments);
7384
+ return _super5.apply(this, arguments);
7400
7385
  }
7401
7386
  return _createClass(clazz);
7402
7387
  }(HTMLElementAlias);
@@ -7442,24 +7427,24 @@
7442
7427
  // TODO [#2972]: this class should expose observedAttributes as necessary
7443
7428
  var UpgradableConstructor = /*#__PURE__*/function (_HTMLElement) {
7444
7429
  _inherits(UpgradableConstructor, _HTMLElement);
7445
- var _super7 = _createSuper(UpgradableConstructor);
7430
+ var _super6 = _createSuper(UpgradableConstructor);
7446
7431
  function UpgradableConstructor(upgradeCallback) {
7447
- var _this5;
7432
+ var _this3;
7448
7433
  _classCallCheck(this, UpgradableConstructor);
7449
- _this5 = _super7.call(this);
7434
+ _this3 = _super6.call(this);
7450
7435
  // If the element is not created using lwc.createElement(), e.g. `document.createElement('x-foo')`,
7451
7436
  // then elementBeingUpgraded will be false
7452
7437
  if (elementBeingUpgradedByLWC) {
7453
- upgradeCallback(_assertThisInitialized(_this5));
7438
+ upgradeCallback(_assertThisInitialized(_this3));
7454
7439
  } else if (hasConnectedCallback || hasDisconnectedCallback) {
7455
7440
  // If this element has connected or disconnected callbacks, then we need to keep track of
7456
7441
  // instances that were created outside LWC (i.e. not created by `lwc.createElement()`).
7457
7442
  // If the element has no connected or disconnected callbacks, then we don't need to track this.
7458
- elementsUpgradedOutsideLWC.add(_assertThisInitialized(_this5));
7443
+ elementsUpgradedOutsideLWC.add(_assertThisInitialized(_this3));
7459
7444
  // TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
7460
7445
  // Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
7461
7446
  }
7462
- return _this5;
7447
+ return _this3;
7463
7448
  }
7464
7449
  return _createClass(UpgradableConstructor);
7465
7450
  }( /*#__PURE__*/_wrapNativeSuper(HTMLElement)); // Do not unnecessarily add a connectedCallback/disconnectedCallback, as it introduces perf overhead
@@ -7568,9 +7553,9 @@
7568
7553
  function createPivotingClass(tagName, registeredDefinition) {
7569
7554
  var PivotCtor = /*#__PURE__*/function (_NativeHTMLElement) {
7570
7555
  _inherits(PivotCtor, _NativeHTMLElement);
7571
- var _super8 = _createSuper(PivotCtor);
7556
+ var _super7 = _createSuper(PivotCtor);
7572
7557
  function PivotCtor(UserCtor) {
7573
- var _this6;
7558
+ var _this4;
7574
7559
  _classCallCheck(this, PivotCtor);
7575
7560
  // This constructor can only be invoked by:
7576
7561
  // a) the browser instantiating an element from parsing or via document.createElement.
@@ -7580,7 +7565,7 @@
7580
7565
  // If the caller signals via UserCtor that this is in fact a controlled
7581
7566
  // definition, we use that one, otherwise fallback to the global
7582
7567
  // internal registry.
7583
- _this6 = _super8.call(this);
7568
+ _this4 = _super7.call(this);
7584
7569
  var userCtorIsDefined = !isUndefined$1(UserCtor);
7585
7570
  if (userCtorIsDefined) {
7586
7571
  if (!isConstructor(UserCtor)) {
@@ -7592,15 +7577,15 @@
7592
7577
  }
7593
7578
  var definition = userCtorIsDefined ? getOrCreateDefinitionForConstructor(UserCtor) : globalDefinitionsByTag.get(tagName);
7594
7579
  if (!isUndefined$1(definition)) {
7595
- internalUpgrade(_assertThisInitialized(_this6), registeredDefinition, definition);
7580
+ internalUpgrade(_assertThisInitialized(_this4), registeredDefinition, definition);
7596
7581
  } else {
7597
7582
  // This is the case in which there is no global definition, and
7598
7583
  // it is not handled by LWC (otherwise it will have a valid UserCtor)
7599
7584
  // so we need to add it to the pending queue just in case it eventually
7600
7585
  // gets defined in the global registry.
7601
- pendingRegistryForElement.set(_assertThisInitialized(_this6), registeredDefinition);
7586
+ pendingRegistryForElement.set(_assertThisInitialized(_this4), registeredDefinition);
7602
7587
  }
7603
- return _this6;
7588
+ return _this4;
7604
7589
  }
7605
7590
  _createClass(PivotCtor, [{
7606
7591
  key: "connectedCallback",
@@ -7838,17 +7823,17 @@
7838
7823
  function flushPendingWhenDefinedCallbacks(tagName, ctor) {
7839
7824
  var resolvers = pendingWhenDefinedCallbacks.get(tagName);
7840
7825
  if (!isUndefined$1(resolvers)) {
7841
- var _iterator6 = _createForOfIteratorHelper(resolvers),
7842
- _step6;
7826
+ var _iterator7 = _createForOfIteratorHelper(resolvers),
7827
+ _step7;
7843
7828
  try {
7844
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
7845
- var resolver = _step6.value;
7829
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
7830
+ var resolver = _step7.value;
7846
7831
  resolver(ctor);
7847
7832
  }
7848
7833
  } catch (err) {
7849
- _iterator6.e(err);
7834
+ _iterator7.e(err);
7850
7835
  } finally {
7851
- _iterator6.f();
7836
+ _iterator7.f();
7852
7837
  }
7853
7838
  }
7854
7839
  pendingWhenDefinedCallbacks.delete(tagName);
@@ -7898,11 +7883,11 @@
7898
7883
  var awaiting = awaitingUpgrade.get(tagName);
7899
7884
  if (!isUndefined$1(awaiting)) {
7900
7885
  awaitingUpgrade.delete(tagName);
7901
- var _iterator7 = _createForOfIteratorHelper(awaiting),
7902
- _step7;
7886
+ var _iterator8 = _createForOfIteratorHelper(awaiting),
7887
+ _step8;
7903
7888
  try {
7904
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
7905
- var element = _step7.value;
7889
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
7890
+ var element = _step8.value;
7906
7891
  var registeredDefinition = pendingRegistryForElement.get(element);
7907
7892
  // At this point, registeredDefinition should never be undefined because awaitingUpgrade
7908
7893
  // is only populated when we haven't run internalUpgrade yet, and we only populate
@@ -7914,9 +7899,9 @@
7914
7899
  }
7915
7900
  }
7916
7901
  } catch (err) {
7917
- _iterator7.e(err);
7902
+ _iterator8.e(err);
7918
7903
  } finally {
7919
- _iterator7.f();
7904
+ _iterator8.f();
7920
7905
  }
7921
7906
  }
7922
7907
  // If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
@@ -8060,32 +8045,38 @@
8060
8045
  // Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
8061
8046
  // In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
8062
8047
  // multiple times per tag name.
8063
- var createUserConstructor = function createUserConstructor(HTMLElementToExtend, upgradeCallback, connectedCallback, disconnectedCallback) {
8048
+ var createUserConstructor = function createUserConstructor(HTMLElementToExtend, upgradeCallback, _connectedCallback, _disconnectedCallback) {
8064
8049
  // TODO [#2972]: this class should expose observedAttributes as necessary
8065
- var UserConstructor = /*#__PURE__*/function (_HTMLElementToExtend) {
8050
+ return /*#__PURE__*/function (_HTMLElementToExtend) {
8066
8051
  _inherits(UserConstructor, _HTMLElementToExtend);
8067
- var _super9 = _createSuper(UserConstructor);
8052
+ var _super8 = _createSuper(UserConstructor);
8068
8053
  function UserConstructor() {
8069
- var _this7;
8054
+ var _this5;
8070
8055
  _classCallCheck(this, UserConstructor);
8071
- _this7 = _super9.call(this);
8072
- upgradeCallback(_assertThisInitialized(_this7));
8073
- return _this7;
8056
+ _this5 = _super8.call(this);
8057
+ upgradeCallback(_assertThisInitialized(_this5));
8058
+ return _this5;
8074
8059
  }
8075
- return _createClass(UserConstructor);
8076
- }(HTMLElementToExtend); // Do not unnecessarily add a connectedCallback/disconnectedCallback, as it introduces perf overhead
8077
- // See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
8078
- if (!isUndefined$1(connectedCallback)) {
8079
- UserConstructor.prototype.connectedCallback = function () {
8080
- connectedCallback(this);
8081
- };
8082
- }
8083
- if (!isUndefined$1(disconnectedCallback)) {
8084
- UserConstructor.prototype.disconnectedCallback = function () {
8085
- disconnectedCallback(this);
8086
- };
8087
- }
8088
- return UserConstructor;
8060
+ // Note that there is no need to do the "avoid defining connectedCallback/disconnectedCallback" optimization
8061
+ // here, because in create-scoped-registry.ts, the registered class will always have these callbacks anyway.
8062
+ // See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
8063
+ _createClass(UserConstructor, [{
8064
+ key: "connectedCallback",
8065
+ value: function connectedCallback() {
8066
+ if (!isUndefined$1(_connectedCallback)) {
8067
+ _connectedCallback(this);
8068
+ }
8069
+ }
8070
+ }, {
8071
+ key: "disconnectedCallback",
8072
+ value: function disconnectedCallback() {
8073
+ if (!isUndefined$1(_disconnectedCallback)) {
8074
+ _disconnectedCallback(this);
8075
+ }
8076
+ }
8077
+ }]);
8078
+ return UserConstructor;
8079
+ }(HTMLElementToExtend);
8089
8080
  };
8090
8081
  function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
8091
8082
  if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
@@ -8187,7 +8178,7 @@
8187
8178
  function isNull(obj) {
8188
8179
  return obj === null;
8189
8180
  }
8190
- /** version: 2.31.1 */
8181
+ /** version: 2.32.1 */
8191
8182
 
8192
8183
  /*
8193
8184
  * Copyright (c) 2018, salesforce.com, inc.
@@ -8246,17 +8237,17 @@
8246
8237
  exports.createFragment = function (html) {
8247
8238
  var wrapperTags = topLevelWrappingMap[getTagName(html)];
8248
8239
  if (!isUndefined(wrapperTags)) {
8249
- var _iterator8 = _createForOfIteratorHelper(wrapperTags),
8250
- _step8;
8240
+ var _iterator9 = _createForOfIteratorHelper(wrapperTags),
8241
+ _step9;
8251
8242
  try {
8252
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
8253
- var wrapperTag = _step8.value;
8243
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
8244
+ var wrapperTag = _step9.value;
8254
8245
  html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
8255
8246
  }
8256
8247
  } catch (err) {
8257
- _iterator8.e(err);
8248
+ _iterator9.e(err);
8258
8249
  } finally {
8259
- _iterator8.f();
8250
+ _iterator9.f();
8260
8251
  }
8261
8252
  }
8262
8253
  // For IE11, the document title must not be undefined, but it can be an empty string
@@ -8265,7 +8256,7 @@
8265
8256
  doc.body.innerHTML = html;
8266
8257
  var content = doc.body;
8267
8258
  if (!isUndefined(wrapperTags)) {
8268
- for (var _i33 = 0; _i33 < wrapperTags.length; _i33++) {
8259
+ for (var _i34 = 0; _i34 < wrapperTags.length; _i34++) {
8269
8260
  content = content.firstChild;
8270
8261
  }
8271
8262
  }
@@ -8458,8 +8449,8 @@
8458
8449
  tagName: element.tagName.toLowerCase(),
8459
8450
  hydrated: true
8460
8451
  });
8461
- for (var _i34 = 0, _Object$entries2 = Object.entries(props); _i34 < _Object$entries2.length; _i34++) {
8462
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i34], 2),
8452
+ for (var _i35 = 0, _Object$entries2 = Object.entries(props); _i35 < _Object$entries2.length; _i35++) {
8453
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i35], 2),
8463
8454
  key = _Object$entries2$_i[0],
8464
8455
  value = _Object$entries2$_i[1];
8465
8456
  element[key] = value;
@@ -8536,23 +8527,23 @@
8536
8527
  var _attributeChangedCallback = HtmlPrototype.prototype.attributeChangedCallback;
8537
8528
  return _a = /*#__PURE__*/function (_HTMLElement2) {
8538
8529
  _inherits(_a, _HTMLElement2);
8539
- var _super10 = _createSuper(_a);
8530
+ var _super9 = _createSuper(_a);
8540
8531
  function _a() {
8541
- var _this8;
8532
+ var _this6;
8542
8533
  _classCallCheck(this, _a);
8543
- _this8 = _super10.call(this);
8544
- if (_this8.isConnected) {
8534
+ _this6 = _super9.call(this);
8535
+ if (_this6.isConnected) {
8545
8536
  // this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
8546
- hydrateComponent(_assertThisInitialized(_this8), Ctor, {});
8547
- hydratedCustomElements.add(_assertThisInitialized(_this8));
8537
+ hydrateComponent(_assertThisInitialized(_this6), Ctor, {});
8538
+ hydratedCustomElements.add(_assertThisInitialized(_this6));
8548
8539
  } else {
8549
- createVM(_assertThisInitialized(_this8), Ctor, renderer, {
8540
+ createVM(_assertThisInitialized(_this6), Ctor, renderer, {
8550
8541
  mode: 'open',
8551
8542
  owner: null,
8552
- tagName: _this8.tagName
8543
+ tagName: _this6.tagName
8553
8544
  });
8554
8545
  }
8555
- return _this8;
8546
+ return _this6;
8556
8547
  }
8557
8548
  _createClass(_a, [{
8558
8549
  key: "connectedCallback",
@@ -8753,7 +8744,7 @@
8753
8744
  });
8754
8745
  freeze(LightningElement);
8755
8746
  seal(LightningElement.prototype);
8756
- /* version: 2.31.1 */
8747
+ /* version: 2.32.1 */
8757
8748
 
8758
8749
  exports.LightningElement = LightningElement;
8759
8750
  exports.__unstable__ProfilerControl = profilerControl;