lwc 2.21.1 → 2.23.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 +222 -199
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +222 -199
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +211 -188
  5. package/dist/engine-dom/iife/es5/engine-dom.js +263 -216
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +239 -192
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +222 -199
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +211 -188
  11. package/dist/engine-dom/umd/es5/engine-dom.js +263 -216
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +239 -192
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +116 -403
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +116 -403
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +30 -27
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +30 -27
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +29 -26
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +32 -31
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +31 -30
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +30 -27
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +29 -26
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +32 -31
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +31 -30
  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
@@ -415,9 +415,9 @@ function htmlEscape(str, attrMode = false) {
415
415
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
416
416
  */
417
417
  // Increment whenever the LWC template compiler changes
418
- const LWC_VERSION = "2.21.1";
418
+ const LWC_VERSION = "2.23.1";
419
419
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
420
- /** version: 2.21.1 */
420
+ /** version: 2.23.1 */
421
421
 
422
422
  /*
423
423
  * Copyright (c) 2020, salesforce.com, inc.
@@ -477,7 +477,7 @@ const features = {
477
477
  if (!_globalThis.lwcRuntimeFlags) {
478
478
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
479
479
  }
480
- const runtimeFlags = _globalThis.lwcRuntimeFlags;
480
+ const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
481
481
  /**
482
482
  * Set the value at runtime of a given feature flag. This method only be invoked once per feature
483
483
  * flag. It is meant to be used during the app initialization.
@@ -504,17 +504,17 @@ function setFeatureFlag(name, value) {
504
504
  }
505
505
  if (process.env.NODE_ENV !== 'production') {
506
506
  // Allow the same flag to be set more than once outside of production to enable testing
507
- runtimeFlags[name] = value;
507
+ lwcRuntimeFlags[name] = value;
508
508
  }
509
509
  else {
510
510
  // Disallow the same flag to be set more than once in production
511
- const runtimeValue = runtimeFlags[name];
511
+ const runtimeValue = lwcRuntimeFlags[name];
512
512
  if (!isUndefined$1(runtimeValue)) {
513
513
  // eslint-disable-next-line no-console
514
514
  console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
515
515
  return;
516
516
  }
517
- defineProperty(runtimeFlags, name, { value });
517
+ defineProperty(lwcRuntimeFlags, name, { value });
518
518
  }
519
519
  }
520
520
  /**
@@ -526,7 +526,7 @@ function setFeatureFlagForTest(name, value) {
526
526
  setFeatureFlag(name, value);
527
527
  }
528
528
  }
529
- /** version: 2.21.1 */
529
+ /** version: 2.23.1 */
530
530
 
531
531
  /* proxy-compat-disable */
532
532
 
@@ -542,7 +542,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
542
542
  window.addEventListener('test-dummy-flag', () => {
543
543
  let hasFlag = false;
544
544
 
545
- if (runtimeFlags.DUMMY_TEST_FLAG) {
545
+ if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
546
546
  hasFlag = true;
547
547
  }
548
548
 
@@ -554,40 +554,9 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
554
554
  }));
555
555
  });
556
556
  }
557
-
558
- /*
559
- * Copyright (c) 2018, salesforce.com, inc.
560
- * All rights reserved.
561
- * SPDX-License-Identifier: MIT
562
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
563
- */
564
- let nextTickCallbackQueue = [];
565
557
  const SPACE_CHAR = 32;
566
558
  const EmptyObject = seal(create(null));
567
559
  const EmptyArray = seal([]);
568
- function flushCallbackQueue() {
569
- if (process.env.NODE_ENV !== 'production') {
570
- if (nextTickCallbackQueue.length === 0) {
571
- throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
572
- }
573
- }
574
- const callbacks = nextTickCallbackQueue;
575
- nextTickCallbackQueue = []; // reset to a new queue
576
- for (let i = 0, len = callbacks.length; i < len; i += 1) {
577
- callbacks[i]();
578
- }
579
- }
580
- function addCallbackToNextTick(callback) {
581
- if (process.env.NODE_ENV !== 'production') {
582
- if (!isFunction$1(callback)) {
583
- throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
584
- }
585
- }
586
- if (nextTickCallbackQueue.length === 0) {
587
- Promise.resolve().then(flushCallbackQueue);
588
- }
589
- ArrayPush$1.call(nextTickCallbackQueue, callback);
590
- }
591
560
  function guid() {
592
561
  function s4() {
593
562
  return Math.floor((1 + Math.random()) * 0x10000)
@@ -616,16 +585,6 @@ function flattenStylesheets(stylesheets) {
616
585
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
617
586
  */
618
587
  const TargetToReactiveRecordMap = new WeakMap();
619
- function getReactiveRecord(target) {
620
- let reactiveRecord = TargetToReactiveRecordMap.get(target);
621
- if (isUndefined$1(reactiveRecord)) {
622
- const newRecord = create(null);
623
- reactiveRecord = newRecord;
624
- TargetToReactiveRecordMap.set(target, newRecord);
625
- }
626
- return reactiveRecord;
627
- }
628
- let currentReactiveObserver = null;
629
588
  function valueMutated(target, key) {
630
589
  const reactiveRecord = TargetToReactiveRecordMap.get(target);
631
590
  if (!isUndefined$1(reactiveRecord)) {
@@ -640,71 +599,9 @@ function valueMutated(target, key) {
640
599
  }
641
600
  function valueObserved(target, key) {
642
601
  // We should determine if an active Observing Record is present to track mutations.
643
- if (currentReactiveObserver === null) {
602
+ {
644
603
  return;
645
604
  }
646
- const ro = currentReactiveObserver;
647
- const reactiveRecord = getReactiveRecord(target);
648
- let reactiveObservers = reactiveRecord[key];
649
- if (isUndefined$1(reactiveObservers)) {
650
- reactiveObservers = [];
651
- reactiveRecord[key] = reactiveObservers;
652
- }
653
- else if (reactiveObservers[0] === ro) {
654
- return; // perf optimization considering that most subscriptions will come from the same record
655
- }
656
- if (ArrayIndexOf.call(reactiveObservers, ro) === -1) {
657
- ro.link(reactiveObservers);
658
- }
659
- }
660
- class ReactiveObserver {
661
- constructor(callback) {
662
- this.listeners = [];
663
- this.callback = callback;
664
- }
665
- observe(job) {
666
- const inceptionReactiveRecord = currentReactiveObserver;
667
- currentReactiveObserver = this;
668
- let error;
669
- try {
670
- job();
671
- }
672
- catch (e) {
673
- error = Object(e);
674
- }
675
- finally {
676
- currentReactiveObserver = inceptionReactiveRecord;
677
- if (error !== undefined) {
678
- throw error; // eslint-disable-line no-unsafe-finally
679
- }
680
- }
681
- }
682
- /**
683
- * This method is responsible for disconnecting the Reactive Observer
684
- * from any Reactive Record that has a reference to it, to prevent future
685
- * notifications about previously recorded access.
686
- */
687
- reset() {
688
- const { listeners } = this;
689
- const len = listeners.length;
690
- if (len > 0) {
691
- for (let i = 0; i < len; i += 1) {
692
- const set = listeners[i];
693
- const pos = ArrayIndexOf.call(listeners[i], this);
694
- ArraySplice.call(set, pos, 1);
695
- }
696
- listeners.length = 0;
697
- }
698
- }
699
- // friend methods
700
- notify() {
701
- this.callback.call(undefined, this);
702
- }
703
- link(reactiveObservers) {
704
- ArrayPush$1.call(reactiveObservers, this);
705
- // we keep track of observing records where the observing record was added to so we can do some clean up later on
706
- ArrayPush$1.call(this.listeners, reactiveObservers);
707
- }
708
605
  }
709
606
 
710
607
  /*
@@ -713,11 +610,16 @@ class ReactiveObserver {
713
610
  * SPDX-License-Identifier: MIT
714
611
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
715
612
  */
716
- function componentValueMutated(vm, key) {
717
- valueMutated(vm.component, key);
718
- }
719
- function componentValueObserved(vm, key) {
720
- valueObserved(vm.component, key);
613
+ const DUMMY_REACTIVE_OBSERVER = {
614
+ observe(job) {
615
+ job();
616
+ },
617
+ reset() { },
618
+ link() { },
619
+ };
620
+ function createReactiveObserver(callback) {
621
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
622
+ return DUMMY_REACTIVE_OBSERVER;
721
623
  }
722
624
 
723
625
  /*
@@ -1273,6 +1175,13 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
1273
1175
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1274
1176
  }
1275
1177
 
1178
+ function updateComponentValue(vm, key, newValue) {
1179
+ const { cmpFields } = vm;
1180
+ if (newValue !== cmpFields[key]) {
1181
+ cmpFields[key] = newValue;
1182
+ }
1183
+ }
1184
+
1276
1185
  /**
1277
1186
  * Copyright (C) 2017 salesforce.com, inc.
1278
1187
  */
@@ -1836,7 +1745,17 @@ const reactiveMembrane = new ObservableMembrane({
1836
1745
  * change or being removed.
1837
1746
  */
1838
1747
  function unwrap(value) {
1839
- return reactiveMembrane.unwrapProxy(value);
1748
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1749
+ return value;
1750
+ }
1751
+ function getReadOnlyProxy(value) {
1752
+ // We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
1753
+ // them from their parents. This applies to both the client and server.
1754
+ return reactiveMembrane.getReadOnlyProxy(value);
1755
+ }
1756
+ function getReactiveProxy(value) {
1757
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1758
+ return value;
1840
1759
  }
1841
1760
 
1842
1761
  /*
@@ -1876,7 +1795,6 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1876
1795
  }
1877
1796
  return;
1878
1797
  }
1879
- componentValueObserved(vm, propName);
1880
1798
  return get.call(vm.elm);
1881
1799
  },
1882
1800
  set(newValue) {
@@ -1888,10 +1806,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1888
1806
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1889
1807
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1890
1808
  }
1891
- if (newValue !== vm.cmpProps[propName]) {
1892
- vm.cmpProps[propName] = newValue;
1893
- componentValueMutated(vm, propName);
1894
- }
1809
+ updateComponentValue(vm, propName, newValue);
1895
1810
  return set.call(vm.elm, newValue);
1896
1811
  },
1897
1812
  };
@@ -1926,8 +1841,6 @@ const LightningElement = function () {
1926
1841
  vm.setHook = setHook;
1927
1842
  vm.getHook = getHook;
1928
1843
  }
1929
- // Making the component instance a live value when using Locker to support expandos.
1930
- this[lockerLivePropertyKey] = undefined;
1931
1844
  // Linking elm, shadow root and component with the VM.
1932
1845
  associateVM(component, vm);
1933
1846
  associateVM(elm, vm);
@@ -2182,21 +2095,35 @@ function createObservedFieldPropertyDescriptor(key) {
2182
2095
  return {
2183
2096
  get() {
2184
2097
  const vm = getAssociatedVM(this);
2185
- componentValueObserved(vm, key);
2186
2098
  return vm.cmpFields[key];
2187
2099
  },
2188
2100
  set(newValue) {
2189
2101
  const vm = getAssociatedVM(this);
2190
- if (newValue !== vm.cmpFields[key]) {
2191
- vm.cmpFields[key] = newValue;
2192
- componentValueMutated(vm, key);
2193
- }
2102
+ updateComponentValue(vm, key, newValue);
2194
2103
  },
2195
2104
  enumerable: true,
2196
2105
  configurable: true,
2197
2106
  };
2198
2107
  }
2199
2108
 
2109
+ /*
2110
+ * Copyright (c) 2018, salesforce.com, inc.
2111
+ * All rights reserved.
2112
+ * SPDX-License-Identifier: MIT
2113
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2114
+ */
2115
+ const DUMMY_ACCESSOR_REACTIVE_OBSERVER = {
2116
+ observe(job) {
2117
+ job();
2118
+ },
2119
+ reset() { },
2120
+ link() { },
2121
+ };
2122
+ function createAccessorReactiveObserver(vm, set) {
2123
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
2124
+ return DUMMY_ACCESSOR_REACTIVE_OBSERVER;
2125
+ }
2126
+
2200
2127
  /*
2201
2128
  * Copyright (c) 2018, salesforce.com, inc.
2202
2129
  * All rights reserved.
@@ -2222,8 +2149,6 @@ function createPublicPropertyDescriptor(key) {
2222
2149
 
2223
2150
  return;
2224
2151
  }
2225
-
2226
- componentValueObserved(vm, key);
2227
2152
  return vm.cmpProps[key];
2228
2153
  },
2229
2154
 
@@ -2237,57 +2162,12 @@ function createPublicPropertyDescriptor(key) {
2237
2162
  }
2238
2163
 
2239
2164
  vm.cmpProps[key] = newValue;
2240
- componentValueMutated(vm, key);
2241
2165
  },
2242
2166
 
2243
2167
  enumerable: true,
2244
2168
  configurable: true
2245
2169
  };
2246
2170
  }
2247
- class AccessorReactiveObserver extends ReactiveObserver {
2248
- constructor(vm, set) {
2249
- super(() => {
2250
- if (isFalse(this.debouncing)) {
2251
- this.debouncing = true;
2252
- addCallbackToNextTick(() => {
2253
- if (isTrue(this.debouncing)) {
2254
- const {
2255
- value
2256
- } = this;
2257
- const {
2258
- isDirty: dirtyStateBeforeSetterCall,
2259
- component,
2260
- idx
2261
- } = vm;
2262
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
2263
- // infinity loop if the setter itself is mutating things that
2264
- // were accessed during the previous invocation.
2265
-
2266
- this.debouncing = false;
2267
-
2268
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2269
- // immediate rehydration due to a setter driven mutation, otherwise
2270
- // the component will get rendered on the second tick, which it is not
2271
- // desirable.
2272
- rerenderVM(vm);
2273
- }
2274
- }
2275
- });
2276
- }
2277
- });
2278
- this.debouncing = false;
2279
- }
2280
-
2281
- reset(value) {
2282
- super.reset();
2283
- this.debouncing = false;
2284
-
2285
- if (arguments.length > 0) {
2286
- this.value = value;
2287
- }
2288
- }
2289
-
2290
- }
2291
2171
  function createPublicAccessorDescriptor(key, descriptor) {
2292
2172
  const {
2293
2173
  get,
@@ -2324,11 +2204,11 @@ function createPublicAccessorDescriptor(key, descriptor) {
2324
2204
  }
2325
2205
 
2326
2206
  if (set) {
2327
- if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
2207
+ if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
2328
2208
  let ro = vm.oar[key];
2329
2209
 
2330
2210
  if (isUndefined$1(ro)) {
2331
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
2211
+ ro = vm.oar[key] = createAccessorReactiveObserver();
2332
2212
  } // every time we invoke this setter from outside (through this wrapper setter)
2333
2213
  // we should reset the value and then debounce just in case there is a pending
2334
2214
  // invocation the next tick that is not longer relevant since the value is changing
@@ -2360,7 +2240,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
2360
2240
  */
2361
2241
  function track(target) {
2362
2242
  if (arguments.length === 1) {
2363
- return reactiveMembrane.getProxy(target);
2243
+ return getReactiveProxy(target);
2364
2244
  }
2365
2245
  if (process.env.NODE_ENV !== 'production') {
2366
2246
  assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
@@ -2371,7 +2251,6 @@ function internalTrackDecorator(key) {
2371
2251
  return {
2372
2252
  get() {
2373
2253
  const vm = getAssociatedVM(this);
2374
- componentValueObserved(vm, key);
2375
2254
  return vm.cmpFields[key];
2376
2255
  },
2377
2256
  set(newValue) {
@@ -2381,11 +2260,8 @@ function internalTrackDecorator(key) {
2381
2260
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2382
2261
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2383
2262
  }
2384
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
2385
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2386
- vm.cmpFields[key] = reactiveOrAnyValue;
2387
- componentValueMutated(vm, key);
2388
- }
2263
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
2264
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2389
2265
  },
2390
2266
  enumerable: true,
2391
2267
  configurable: true,
@@ -2413,7 +2289,6 @@ function internalWireFieldDecorator(key) {
2413
2289
  return {
2414
2290
  get() {
2415
2291
  const vm = getAssociatedVM(this);
2416
- componentValueObserved(vm, key);
2417
2292
  return vm.cmpFields[key];
2418
2293
  },
2419
2294
  set(value) {
@@ -2424,10 +2299,7 @@ function internalWireFieldDecorator(key) {
2424
2299
  * letting the author to do the wrong thing, but it will keep our
2425
2300
  * system to be backward compatible.
2426
2301
  */
2427
- if (value !== vm.cmpFields[key]) {
2428
- vm.cmpFields[key] = value;
2429
- componentValueMutated(vm, key);
2430
- }
2302
+ updateComponentValue(vm, key, value);
2431
2303
  },
2432
2304
  enumerable: true,
2433
2305
  configurable: true,
@@ -2773,7 +2645,7 @@ function createSetter(key) {
2773
2645
  fn = cachedSetterByKey[key] = function (newValue) {
2774
2646
  const vm = getAssociatedVM(this);
2775
2647
  const { setHook } = vm;
2776
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
2648
+ newValue = getReadOnlyProxy(newValue);
2777
2649
  setHook(vm.component, key, newValue);
2778
2650
  };
2779
2651
  }
@@ -2911,7 +2783,7 @@ function getTemplateOrSwappedTemplate(tpl) {
2911
2783
  throw new ReferenceError();
2912
2784
  }
2913
2785
 
2914
- if (runtimeFlags.ENABLE_HMR) {
2786
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2915
2787
  const visited = new Set();
2916
2788
 
2917
2789
  while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
@@ -2928,7 +2800,7 @@ function getComponentOrSwappedComponent(Ctor) {
2928
2800
  throw new ReferenceError();
2929
2801
  }
2930
2802
 
2931
- if (runtimeFlags.ENABLE_HMR) {
2803
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2932
2804
  const visited = new Set();
2933
2805
 
2934
2806
  while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
@@ -2945,7 +2817,7 @@ function getStyleOrSwappedStyle(style) {
2945
2817
  throw new ReferenceError();
2946
2818
  }
2947
2819
 
2948
- if (runtimeFlags.ENABLE_HMR) {
2820
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2949
2821
  const visited = new Set();
2950
2822
 
2951
2823
  while (swappedStyleMap.has(style) && !visited.has(style)) {
@@ -2962,7 +2834,7 @@ function setActiveVM(vm) {
2962
2834
  throw new ReferenceError();
2963
2835
  }
2964
2836
 
2965
- if (runtimeFlags.ENABLE_HMR) {
2837
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2966
2838
  // tracking active component
2967
2839
  const Ctor = vm.def.ctor;
2968
2840
  let componentVMs = activeComponents.get(Ctor);
@@ -3019,7 +2891,7 @@ function removeActiveVM(vm) {
3019
2891
  throw new ReferenceError();
3020
2892
  }
3021
2893
 
3022
- if (runtimeFlags.ENABLE_HMR) {
2894
+ if (lwcRuntimeFlags.ENABLE_HMR) {
3023
2895
  // tracking inactive component
3024
2896
  const Ctor = vm.def.ctor;
3025
2897
  let list = activeComponents.get(Ctor);
@@ -3385,38 +3257,20 @@ function getScopeTokenClass(owner) {
3385
3257
  const { cmpTemplate, context } = owner;
3386
3258
  return (context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) || null;
3387
3259
  }
3388
- function getNearestNativeShadowComponent(vm) {
3389
- const owner = getNearestShadowComponent(vm);
3390
- if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
3391
- // Synthetic-within-native is impossible. So if the nearest shadow component is
3392
- // synthetic, we know we won't find a native component if we go any further.
3393
- return null;
3394
- }
3395
- return owner;
3396
- }
3397
3260
  function createStylesheet(vm, stylesheets) {
3398
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3261
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3399
3262
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3400
3263
  for (let i = 0; i < stylesheets.length; i++) {
3401
3264
  insertStylesheet(stylesheets[i]);
3402
3265
  }
3403
3266
  }
3404
- else if (ssr || vm.hydrated) {
3267
+ else {
3405
3268
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3406
3269
  // This works in the client, because the stylesheets are created, and cached in the VM
3407
3270
  // the first time the VM renders.
3408
3271
  // native shadow or light DOM, SSR
3409
3272
  return ArrayMap.call(stylesheets, createInlineStyleVNode);
3410
3273
  }
3411
- else {
3412
- // native shadow or light DOM, DOM renderer
3413
- const root = getNearestNativeShadowComponent(vm);
3414
- // null root means a global style
3415
- const target = isNull(root) ? undefined : root.shadowRoot;
3416
- for (let i = 0; i < stylesheets.length; i++) {
3417
- insertStylesheet(stylesheets[i], target);
3418
- }
3419
- }
3420
3274
  return null;
3421
3275
  }
3422
3276
 
@@ -3702,7 +3556,7 @@ function patchChildren(c1, c2, parent, renderer) {
3702
3556
  updateStaticChildren(c1, c2, parent, renderer);
3703
3557
  }
3704
3558
  }
3705
- function patch(n1, n2, renderer) {
3559
+ function patch(n1, n2, parent, renderer) {
3706
3560
  var _a, _b;
3707
3561
  if (n1 === n2) {
3708
3562
  return;
@@ -3731,7 +3585,7 @@ function patch(n1, n2, renderer) {
3731
3585
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3732
3586
  break;
3733
3587
  case 3 /* VNodeType.CustomElement */:
3734
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3588
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3735
3589
  break;
3736
3590
  }
3737
3591
  }
@@ -3858,22 +3712,32 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3858
3712
  appendVM(vm);
3859
3713
  }
3860
3714
  }
3861
- function patchCustomElement(n1, n2, renderer) {
3862
- const elm = (n2.elm = n1.elm);
3863
- const vm = (n2.vm = n1.vm);
3864
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3865
- if (!isUndefined$1(vm)) {
3866
- // in fallback mode, the allocation will always set children to
3867
- // empty and delegate the real allocation to the slot elements
3868
- allocateChildren(n2, vm);
3715
+ function patchCustomElement(n1, n2, parent, renderer) {
3716
+ if (n1.ctor !== n2.ctor) {
3717
+ // If the constructor, unmount the current component and mount a new one using the new
3718
+ // constructor.
3719
+ const anchor = renderer.nextSibling(n1.elm);
3720
+ unmount(n1, parent, renderer, true);
3721
+ mountCustomElement(n2, parent, anchor, renderer);
3869
3722
  }
3870
- // in fallback mode, the children will be always empty, so, nothing
3871
- // will happen, but in native, it does allocate the light dom
3872
- patchChildren(n1.children, n2.children, elm, renderer);
3873
- if (!isUndefined$1(vm)) {
3874
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3875
- // this is important to preserve the top to bottom synchronous rendering phase.
3876
- rerenderVM(vm);
3723
+ else {
3724
+ // Otherwise patch the existing component with new props/attrs/etc.
3725
+ const elm = (n2.elm = n1.elm);
3726
+ const vm = (n2.vm = n1.vm);
3727
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3728
+ if (!isUndefined$1(vm)) {
3729
+ // in fallback mode, the allocation will always set children to
3730
+ // empty and delegate the real allocation to the slot elements
3731
+ allocateChildren(n2, vm);
3732
+ }
3733
+ // in fallback mode, the children will be always empty, so, nothing
3734
+ // will happen, but in native, it does allocate the light dom
3735
+ patchChildren(n1.children, n2.children, elm, renderer);
3736
+ if (!isUndefined$1(vm)) {
3737
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3738
+ // this is important to preserve the top to bottom synchronous rendering phase.
3739
+ rerenderVM(vm);
3740
+ }
3877
3741
  }
3878
3742
  }
3879
3743
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -4143,25 +4007,25 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4143
4007
  newEndVnode = newCh[--newEndIdx];
4144
4008
  }
4145
4009
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4146
- patch(oldStartVnode, newStartVnode, renderer);
4010
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4147
4011
  oldStartVnode = oldCh[++oldStartIdx];
4148
4012
  newStartVnode = newCh[++newStartIdx];
4149
4013
  }
4150
4014
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4151
- patch(oldEndVnode, newEndVnode, renderer);
4015
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4152
4016
  oldEndVnode = oldCh[--oldEndIdx];
4153
4017
  newEndVnode = newCh[--newEndIdx];
4154
4018
  }
4155
4019
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4156
4020
  // Vnode moved right
4157
- patch(oldStartVnode, newEndVnode, renderer);
4021
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4158
4022
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4159
4023
  oldStartVnode = oldCh[++oldStartIdx];
4160
4024
  newEndVnode = newCh[--newEndIdx];
4161
4025
  }
4162
4026
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4163
4027
  // Vnode moved left
4164
- patch(oldEndVnode, newStartVnode, renderer);
4028
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4165
4029
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4166
4030
  oldEndVnode = oldCh[--oldEndIdx];
4167
4031
  newStartVnode = newCh[++newStartIdx];
@@ -4184,7 +4048,7 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4184
4048
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4185
4049
  }
4186
4050
  else {
4187
- patch(elmToMove, newStartVnode, renderer);
4051
+ patch(elmToMove, newStartVnode, parent, renderer);
4188
4052
  // Delete the old child, but copy the array since it is read-only.
4189
4053
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4190
4054
  // so we only care about the `oldCh` object inside this function.
@@ -4244,7 +4108,7 @@ function updateStaticChildren(c1, c2, parent, renderer) {
4244
4108
  if (isVNode(n1)) {
4245
4109
  if (isVNode(n2)) {
4246
4110
  // both vnodes are equivalent, and we just need to patch them
4247
- patch(n1, n2, renderer);
4111
+ patch(n1, n2, parent, renderer);
4248
4112
  anchor = n2.elm;
4249
4113
  }
4250
4114
  else {
@@ -4578,13 +4442,6 @@ function fid(url) {
4578
4442
  }
4579
4443
  return url;
4580
4444
  }
4581
- /**
4582
- * Map to store an index value assigned to any dynamic component reference ingested
4583
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4584
- * component reference to avoid diffing algo mismatches.
4585
- */
4586
- const DynamicImportedComponentMap = new Map();
4587
- let dynamicImportedComponentCounter = 0;
4588
4445
  /**
4589
4446
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4590
4447
  */
@@ -4601,18 +4458,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
4601
4458
  if (!isComponentConstructor(Ctor)) {
4602
4459
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4603
4460
  }
4604
- let idx = DynamicImportedComponentMap.get(Ctor);
4605
- if (isUndefined$1(idx)) {
4606
- idx = dynamicImportedComponentCounter++;
4607
- DynamicImportedComponentMap.set(Ctor, idx);
4608
- }
4609
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4610
- // to identify different constructors as vnodes with different keys to avoid reusing the
4611
- // element used for previous constructors.
4612
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4613
- // hoisting optimization.
4614
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4615
- return c(sel, Ctor, newData, children);
4461
+ return c(sel, Ctor, data, children);
4616
4462
  }
4617
4463
  /**
4618
4464
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5049,13 +4895,7 @@ function getComponentRegisteredTemplate(Ctor) {
5049
4895
  return signedTemplateMap.get(Ctor);
5050
4896
  }
5051
4897
  function getTemplateReactiveObserver(vm) {
5052
- return new ReactiveObserver(() => {
5053
- const { isDirty } = vm;
5054
- if (isFalse(isDirty)) {
5055
- markComponentAsDirty(vm);
5056
- scheduleRehydration(vm);
5057
- }
5058
- });
4898
+ return createReactiveObserver();
5059
4899
  }
5060
4900
  function renderComponent$1(vm) {
5061
4901
  if (process.env.NODE_ENV !== 'production') {
@@ -5292,14 +5132,14 @@ function createVM(elm, ctor, renderer, options) {
5292
5132
  renderer
5293
5133
  };
5294
5134
  vm.shadowMode = computeShadowMode(vm, renderer);
5295
- vm.tro = getTemplateReactiveObserver(vm);
5135
+ vm.tro = getTemplateReactiveObserver();
5296
5136
 
5297
5137
  if (process.env.NODE_ENV !== 'production') {
5298
5138
  vm.toString = () => {
5299
5139
  return `[object:vm ${def.name} (${vm.idx})]`;
5300
5140
  };
5301
5141
 
5302
- if (runtimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5142
+ if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5303
5143
  vm.shadowMode = 0
5304
5144
  /* ShadowMode.Native */
5305
5145
  ;
@@ -5338,7 +5178,7 @@ function computeShadowMode(vm, renderer) {
5338
5178
  } else if (isNativeShadowDefined) {
5339
5179
  // Not combined with above condition because @lwc/features only supports identifiers in
5340
5180
  // the if-condition.
5341
- if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5181
+ if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5342
5182
  if (def.shadowSupportMode === "any"
5343
5183
  /* ShadowSupportMode.Any */
5344
5184
  ) {
@@ -5454,89 +5294,7 @@ function patchShadowRoot(vm, newCh) {
5454
5294
 
5455
5295
  if (vm.state === 1
5456
5296
  /* VMState.connected */
5457
- ) {
5458
- // If the element is connected, that means connectedCallback was already issued, and
5459
- // any successive rendering should finish with the call to renderedCallback, otherwise
5460
- // the connectedCallback will take care of calling it in the right order at the end of
5461
- // the current rehydration process.
5462
- runRenderedCallback(vm);
5463
- }
5464
- }
5465
-
5466
- function runRenderedCallback(vm) {
5467
- const {
5468
- def: {
5469
- renderedCallback
5470
- },
5471
- renderer: {
5472
- ssr
5473
- }
5474
- } = vm;
5475
-
5476
- if (isTrue(ssr)) {
5477
- return;
5478
- }
5479
-
5480
- const {
5481
- rendered
5482
- } = Services;
5483
-
5484
- if (rendered) {
5485
- invokeServiceHook(vm, rendered);
5486
- }
5487
-
5488
- if (!isUndefined$1(renderedCallback)) {
5489
- logOperationStart(4
5490
- /* OperationId.RenderedCallback */
5491
- , vm);
5492
- invokeComponentCallback(vm, renderedCallback);
5493
- logOperationEnd(4
5494
- /* OperationId.RenderedCallback */
5495
- , vm);
5496
- }
5497
- }
5498
- let rehydrateQueue = [];
5499
-
5500
- function flushRehydrationQueue() {
5501
- logGlobalOperationStart(8
5502
- /* OperationId.GlobalRehydrate */
5503
- );
5504
-
5505
- if (process.env.NODE_ENV !== 'production') {
5506
- assert.invariant(rehydrateQueue.length, `If rehydrateQueue was scheduled, it is because there must be at least one VM on this pending queue instead of ${rehydrateQueue}.`);
5507
- }
5508
-
5509
- const vms = rehydrateQueue.sort((a, b) => a.idx - b.idx);
5510
- rehydrateQueue = []; // reset to a new queue
5511
-
5512
- for (let i = 0, len = vms.length; i < len; i += 1) {
5513
- const vm = vms[i];
5514
-
5515
- try {
5516
- rehydrate(vm);
5517
- } catch (error) {
5518
- if (i + 1 < len) {
5519
- // pieces of the queue are still pending to be rehydrated, those should have priority
5520
- if (rehydrateQueue.length === 0) {
5521
- addCallbackToNextTick(flushRehydrationQueue);
5522
- }
5523
-
5524
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, i + 1));
5525
- } // we need to end the measure before throwing.
5526
-
5527
-
5528
- logGlobalOperationEnd(8
5529
- /* OperationId.GlobalRehydrate */
5530
- ); // re-throwing the original error will break the current tick, but since the next tick is
5531
- // already scheduled, it should continue patching the rest.
5532
-
5533
- throw error; // eslint-disable-line no-unsafe-finally
5534
- }
5535
- }
5536
-
5537
- logGlobalOperationEnd(8
5538
- /* OperationId.GlobalRehydrate */
5539
- );
5297
+ ) ;
5540
5298
  }
5541
5299
 
5542
5300
  function runConnectedCallback(vm) {
@@ -5725,25 +5483,6 @@ function resetComponentRoot(vm) {
5725
5483
  runChildNodesDisconnectedCallback(vm);
5726
5484
  vm.velements = EmptyArray;
5727
5485
  }
5728
- function scheduleRehydration(vm) {
5729
- const {
5730
- renderer: {
5731
- ssr
5732
- }
5733
- } = vm;
5734
-
5735
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5736
- return;
5737
- }
5738
-
5739
- vm.isScheduled = true;
5740
-
5741
- if (rehydrateQueue.length === 0) {
5742
- addCallbackToNextTick(flushRehydrationQueue);
5743
- }
5744
-
5745
- ArrayPush$1.call(rehydrateQueue, vm);
5746
- }
5747
5486
 
5748
5487
  function getErrorBoundaryVM(vm) {
5749
5488
  let currentVm = vm;
@@ -5822,15 +5561,8 @@ class WireContextRegistrationEvent extends CustomEvent {
5822
5561
  }
5823
5562
 
5824
5563
  function createFieldDataCallback(vm, name) {
5825
- const {
5826
- cmpFields
5827
- } = vm;
5828
5564
  return value => {
5829
- if (value !== vm.cmpFields[name]) {
5830
- // storing the value in the underlying storage
5831
- cmpFields[name] = value;
5832
- componentValueMutated(vm, name);
5833
- }
5565
+ updateComponentValue(vm, name, value);
5834
5566
  };
5835
5567
  }
5836
5568
 
@@ -5845,21 +5577,8 @@ function createMethodDataCallback(vm, method) {
5845
5577
  }
5846
5578
 
5847
5579
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
5848
- let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
5849
5580
 
5850
- const ro = new ReactiveObserver(() => {
5851
- if (hasPendingConfig === false) {
5852
- hasPendingConfig = true; // collect new config in the micro-task
5853
-
5854
- Promise.resolve().then(() => {
5855
- hasPendingConfig = false; // resetting current reactive params
5856
-
5857
- ro.reset(); // dispatching a new config due to a change in the configuration
5858
-
5859
- computeConfigAndUpdate();
5860
- });
5861
- }
5862
- });
5581
+ const ro = createReactiveObserver();
5863
5582
 
5864
5583
  const computeConfigAndUpdate = () => {
5865
5584
  let config;
@@ -6048,7 +5767,7 @@ function installWireAdapters(vm) {
6048
5767
  ArrayPush$1.call(wiredConnecting, () => {
6049
5768
  connector.connect();
6050
5769
 
6051
- if (!runtimeFlags.ENABLE_WIRE_SYNC_EMIT) {
5770
+ if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
6052
5771
  if (hasDynamicParams) {
6053
5772
  Promise.resolve().then(computeConfigAndUpdate);
6054
5773
  return;
@@ -6143,7 +5862,7 @@ function readonly(obj) {
6143
5862
  assert.fail('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
6144
5863
  }
6145
5864
  }
6146
- return reactiveMembrane.getReadOnlyProxy(obj);
5865
+ return getReadOnlyProxy(obj);
6147
5866
  }
6148
5867
 
6149
5868
  /*
@@ -6257,7 +5976,7 @@ function freezeTemplate(tmpl) {
6257
5976
  });
6258
5977
  }
6259
5978
  }
6260
- /* version: 2.21.1 */
5979
+ /* version: 2.23.1 */
6261
5980
 
6262
5981
  /*
6263
5982
  * Copyright (c) 2020, salesforce.com, inc.
@@ -6340,10 +6059,6 @@ class HTMLElementImpl {
6340
6059
  return createElement(tagName);
6341
6060
  }
6342
6061
  }
6343
- const ssr = true;
6344
- function isHydrating() {
6345
- return false;
6346
- }
6347
6062
  const isNativeShadowDefined = false;
6348
6063
  const isSyntheticShadowDefined = false;
6349
6064
  function insert(node, parent, anchor) {
@@ -6582,11 +6297,9 @@ const HTMLElementExported = HTMLElementImpl;
6582
6297
  /* noop */
6583
6298
  const assertInstanceOfHTMLElement = noop;
6584
6299
  const renderer = {
6585
- ssr,
6586
6300
  isNativeShadowDefined,
6587
6301
  isSyntheticShadowDefined,
6588
6302
  HTMLElementExported,
6589
- isHydrating,
6590
6303
  insert,
6591
6304
  remove,
6592
6305
  cloneNode,
@@ -6733,6 +6446,6 @@ function renderComponent(tagName, Ctor, props = {}) {
6733
6446
  */
6734
6447
  freeze(LightningElement);
6735
6448
  seal(LightningElement.prototype);
6736
- /* version: 2.21.1 */
6449
+ /* version: 2.23.1 */
6737
6450
 
6738
6451
  export { LightningElement, api$1 as api, createContextProvider, freezeTemplate, getComponentDef, isComponentConstructor, parseFragment, parseFragment as parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderComponent, renderer, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, track, unwrap, wire };