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
@@ -419,9 +419,9 @@ function htmlEscape(str, attrMode = false) {
419
419
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
420
420
  */
421
421
  // Increment whenever the LWC template compiler changes
422
- const LWC_VERSION = "2.21.1";
422
+ const LWC_VERSION = "2.23.1";
423
423
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
424
- /** version: 2.21.1 */
424
+ /** version: 2.23.1 */
425
425
 
426
426
  /*
427
427
  * Copyright (c) 2020, salesforce.com, inc.
@@ -481,7 +481,7 @@ const features = {
481
481
  if (!_globalThis.lwcRuntimeFlags) {
482
482
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
483
483
  }
484
- const runtimeFlags = _globalThis.lwcRuntimeFlags;
484
+ const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
485
485
  /**
486
486
  * Set the value at runtime of a given feature flag. This method only be invoked once per feature
487
487
  * flag. It is meant to be used during the app initialization.
@@ -508,17 +508,17 @@ function setFeatureFlag(name, value) {
508
508
  }
509
509
  if (process.env.NODE_ENV !== 'production') {
510
510
  // Allow the same flag to be set more than once outside of production to enable testing
511
- runtimeFlags[name] = value;
511
+ lwcRuntimeFlags[name] = value;
512
512
  }
513
513
  else {
514
514
  // Disallow the same flag to be set more than once in production
515
- const runtimeValue = runtimeFlags[name];
515
+ const runtimeValue = lwcRuntimeFlags[name];
516
516
  if (!isUndefined$1(runtimeValue)) {
517
517
  // eslint-disable-next-line no-console
518
518
  console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
519
519
  return;
520
520
  }
521
- defineProperty(runtimeFlags, name, { value });
521
+ defineProperty(lwcRuntimeFlags, name, { value });
522
522
  }
523
523
  }
524
524
  /**
@@ -530,7 +530,7 @@ function setFeatureFlagForTest(name, value) {
530
530
  setFeatureFlag(name, value);
531
531
  }
532
532
  }
533
- /** version: 2.21.1 */
533
+ /** version: 2.23.1 */
534
534
 
535
535
  /* proxy-compat-disable */
536
536
 
@@ -546,7 +546,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
546
546
  window.addEventListener('test-dummy-flag', () => {
547
547
  let hasFlag = false;
548
548
 
549
- if (runtimeFlags.DUMMY_TEST_FLAG) {
549
+ if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
550
550
  hasFlag = true;
551
551
  }
552
552
 
@@ -558,40 +558,9 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
558
558
  }));
559
559
  });
560
560
  }
561
-
562
- /*
563
- * Copyright (c) 2018, salesforce.com, inc.
564
- * All rights reserved.
565
- * SPDX-License-Identifier: MIT
566
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
567
- */
568
- let nextTickCallbackQueue = [];
569
561
  const SPACE_CHAR = 32;
570
562
  const EmptyObject = seal(create(null));
571
563
  const EmptyArray = seal([]);
572
- function flushCallbackQueue() {
573
- if (process.env.NODE_ENV !== 'production') {
574
- if (nextTickCallbackQueue.length === 0) {
575
- throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
576
- }
577
- }
578
- const callbacks = nextTickCallbackQueue;
579
- nextTickCallbackQueue = []; // reset to a new queue
580
- for (let i = 0, len = callbacks.length; i < len; i += 1) {
581
- callbacks[i]();
582
- }
583
- }
584
- function addCallbackToNextTick(callback) {
585
- if (process.env.NODE_ENV !== 'production') {
586
- if (!isFunction$1(callback)) {
587
- throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
588
- }
589
- }
590
- if (nextTickCallbackQueue.length === 0) {
591
- Promise.resolve().then(flushCallbackQueue);
592
- }
593
- ArrayPush$1.call(nextTickCallbackQueue, callback);
594
- }
595
564
  function guid() {
596
565
  function s4() {
597
566
  return Math.floor((1 + Math.random()) * 0x10000)
@@ -620,16 +589,6 @@ function flattenStylesheets(stylesheets) {
620
589
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
621
590
  */
622
591
  const TargetToReactiveRecordMap = new WeakMap();
623
- function getReactiveRecord(target) {
624
- let reactiveRecord = TargetToReactiveRecordMap.get(target);
625
- if (isUndefined$1(reactiveRecord)) {
626
- const newRecord = create(null);
627
- reactiveRecord = newRecord;
628
- TargetToReactiveRecordMap.set(target, newRecord);
629
- }
630
- return reactiveRecord;
631
- }
632
- let currentReactiveObserver = null;
633
592
  function valueMutated(target, key) {
634
593
  const reactiveRecord = TargetToReactiveRecordMap.get(target);
635
594
  if (!isUndefined$1(reactiveRecord)) {
@@ -644,71 +603,9 @@ function valueMutated(target, key) {
644
603
  }
645
604
  function valueObserved(target, key) {
646
605
  // We should determine if an active Observing Record is present to track mutations.
647
- if (currentReactiveObserver === null) {
606
+ {
648
607
  return;
649
608
  }
650
- const ro = currentReactiveObserver;
651
- const reactiveRecord = getReactiveRecord(target);
652
- let reactiveObservers = reactiveRecord[key];
653
- if (isUndefined$1(reactiveObservers)) {
654
- reactiveObservers = [];
655
- reactiveRecord[key] = reactiveObservers;
656
- }
657
- else if (reactiveObservers[0] === ro) {
658
- return; // perf optimization considering that most subscriptions will come from the same record
659
- }
660
- if (ArrayIndexOf.call(reactiveObservers, ro) === -1) {
661
- ro.link(reactiveObservers);
662
- }
663
- }
664
- class ReactiveObserver {
665
- constructor(callback) {
666
- this.listeners = [];
667
- this.callback = callback;
668
- }
669
- observe(job) {
670
- const inceptionReactiveRecord = currentReactiveObserver;
671
- currentReactiveObserver = this;
672
- let error;
673
- try {
674
- job();
675
- }
676
- catch (e) {
677
- error = Object(e);
678
- }
679
- finally {
680
- currentReactiveObserver = inceptionReactiveRecord;
681
- if (error !== undefined) {
682
- throw error; // eslint-disable-line no-unsafe-finally
683
- }
684
- }
685
- }
686
- /**
687
- * This method is responsible for disconnecting the Reactive Observer
688
- * from any Reactive Record that has a reference to it, to prevent future
689
- * notifications about previously recorded access.
690
- */
691
- reset() {
692
- const { listeners } = this;
693
- const len = listeners.length;
694
- if (len > 0) {
695
- for (let i = 0; i < len; i += 1) {
696
- const set = listeners[i];
697
- const pos = ArrayIndexOf.call(listeners[i], this);
698
- ArraySplice.call(set, pos, 1);
699
- }
700
- listeners.length = 0;
701
- }
702
- }
703
- // friend methods
704
- notify() {
705
- this.callback.call(undefined, this);
706
- }
707
- link(reactiveObservers) {
708
- ArrayPush$1.call(reactiveObservers, this);
709
- // we keep track of observing records where the observing record was added to so we can do some clean up later on
710
- ArrayPush$1.call(this.listeners, reactiveObservers);
711
- }
712
609
  }
713
610
 
714
611
  /*
@@ -717,11 +614,16 @@ class ReactiveObserver {
717
614
  * SPDX-License-Identifier: MIT
718
615
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
719
616
  */
720
- function componentValueMutated(vm, key) {
721
- valueMutated(vm.component, key);
722
- }
723
- function componentValueObserved(vm, key) {
724
- valueObserved(vm.component, key);
617
+ const DUMMY_REACTIVE_OBSERVER = {
618
+ observe(job) {
619
+ job();
620
+ },
621
+ reset() { },
622
+ link() { },
623
+ };
624
+ function createReactiveObserver(callback) {
625
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
626
+ return DUMMY_REACTIVE_OBSERVER;
725
627
  }
726
628
 
727
629
  /*
@@ -1277,6 +1179,13 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
1277
1179
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1278
1180
  }
1279
1181
 
1182
+ function updateComponentValue(vm, key, newValue) {
1183
+ const { cmpFields } = vm;
1184
+ if (newValue !== cmpFields[key]) {
1185
+ cmpFields[key] = newValue;
1186
+ }
1187
+ }
1188
+
1280
1189
  /**
1281
1190
  * Copyright (C) 2017 salesforce.com, inc.
1282
1191
  */
@@ -1840,7 +1749,17 @@ const reactiveMembrane = new ObservableMembrane({
1840
1749
  * change or being removed.
1841
1750
  */
1842
1751
  function unwrap(value) {
1843
- return reactiveMembrane.unwrapProxy(value);
1752
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1753
+ return value;
1754
+ }
1755
+ function getReadOnlyProxy(value) {
1756
+ // We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
1757
+ // them from their parents. This applies to both the client and server.
1758
+ return reactiveMembrane.getReadOnlyProxy(value);
1759
+ }
1760
+ function getReactiveProxy(value) {
1761
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1762
+ return value;
1844
1763
  }
1845
1764
 
1846
1765
  /*
@@ -1880,7 +1799,6 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1880
1799
  }
1881
1800
  return;
1882
1801
  }
1883
- componentValueObserved(vm, propName);
1884
1802
  return get.call(vm.elm);
1885
1803
  },
1886
1804
  set(newValue) {
@@ -1892,10 +1810,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1892
1810
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1893
1811
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1894
1812
  }
1895
- if (newValue !== vm.cmpProps[propName]) {
1896
- vm.cmpProps[propName] = newValue;
1897
- componentValueMutated(vm, propName);
1898
- }
1813
+ updateComponentValue(vm, propName, newValue);
1899
1814
  return set.call(vm.elm, newValue);
1900
1815
  },
1901
1816
  };
@@ -1930,8 +1845,6 @@ const LightningElement = function () {
1930
1845
  vm.setHook = setHook;
1931
1846
  vm.getHook = getHook;
1932
1847
  }
1933
- // Making the component instance a live value when using Locker to support expandos.
1934
- this[lockerLivePropertyKey] = undefined;
1935
1848
  // Linking elm, shadow root and component with the VM.
1936
1849
  associateVM(component, vm);
1937
1850
  associateVM(elm, vm);
@@ -2186,21 +2099,35 @@ function createObservedFieldPropertyDescriptor(key) {
2186
2099
  return {
2187
2100
  get() {
2188
2101
  const vm = getAssociatedVM(this);
2189
- componentValueObserved(vm, key);
2190
2102
  return vm.cmpFields[key];
2191
2103
  },
2192
2104
  set(newValue) {
2193
2105
  const vm = getAssociatedVM(this);
2194
- if (newValue !== vm.cmpFields[key]) {
2195
- vm.cmpFields[key] = newValue;
2196
- componentValueMutated(vm, key);
2197
- }
2106
+ updateComponentValue(vm, key, newValue);
2198
2107
  },
2199
2108
  enumerable: true,
2200
2109
  configurable: true,
2201
2110
  };
2202
2111
  }
2203
2112
 
2113
+ /*
2114
+ * Copyright (c) 2018, salesforce.com, inc.
2115
+ * All rights reserved.
2116
+ * SPDX-License-Identifier: MIT
2117
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2118
+ */
2119
+ const DUMMY_ACCESSOR_REACTIVE_OBSERVER = {
2120
+ observe(job) {
2121
+ job();
2122
+ },
2123
+ reset() { },
2124
+ link() { },
2125
+ };
2126
+ function createAccessorReactiveObserver(vm, set) {
2127
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
2128
+ return DUMMY_ACCESSOR_REACTIVE_OBSERVER;
2129
+ }
2130
+
2204
2131
  /*
2205
2132
  * Copyright (c) 2018, salesforce.com, inc.
2206
2133
  * All rights reserved.
@@ -2226,8 +2153,6 @@ function createPublicPropertyDescriptor(key) {
2226
2153
 
2227
2154
  return;
2228
2155
  }
2229
-
2230
- componentValueObserved(vm, key);
2231
2156
  return vm.cmpProps[key];
2232
2157
  },
2233
2158
 
@@ -2241,57 +2166,12 @@ function createPublicPropertyDescriptor(key) {
2241
2166
  }
2242
2167
 
2243
2168
  vm.cmpProps[key] = newValue;
2244
- componentValueMutated(vm, key);
2245
2169
  },
2246
2170
 
2247
2171
  enumerable: true,
2248
2172
  configurable: true
2249
2173
  };
2250
2174
  }
2251
- class AccessorReactiveObserver extends ReactiveObserver {
2252
- constructor(vm, set) {
2253
- super(() => {
2254
- if (isFalse(this.debouncing)) {
2255
- this.debouncing = true;
2256
- addCallbackToNextTick(() => {
2257
- if (isTrue(this.debouncing)) {
2258
- const {
2259
- value
2260
- } = this;
2261
- const {
2262
- isDirty: dirtyStateBeforeSetterCall,
2263
- component,
2264
- idx
2265
- } = vm;
2266
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
2267
- // infinity loop if the setter itself is mutating things that
2268
- // were accessed during the previous invocation.
2269
-
2270
- this.debouncing = false;
2271
-
2272
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2273
- // immediate rehydration due to a setter driven mutation, otherwise
2274
- // the component will get rendered on the second tick, which it is not
2275
- // desirable.
2276
- rerenderVM(vm);
2277
- }
2278
- }
2279
- });
2280
- }
2281
- });
2282
- this.debouncing = false;
2283
- }
2284
-
2285
- reset(value) {
2286
- super.reset();
2287
- this.debouncing = false;
2288
-
2289
- if (arguments.length > 0) {
2290
- this.value = value;
2291
- }
2292
- }
2293
-
2294
- }
2295
2175
  function createPublicAccessorDescriptor(key, descriptor) {
2296
2176
  const {
2297
2177
  get,
@@ -2328,11 +2208,11 @@ function createPublicAccessorDescriptor(key, descriptor) {
2328
2208
  }
2329
2209
 
2330
2210
  if (set) {
2331
- if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
2211
+ if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
2332
2212
  let ro = vm.oar[key];
2333
2213
 
2334
2214
  if (isUndefined$1(ro)) {
2335
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
2215
+ ro = vm.oar[key] = createAccessorReactiveObserver();
2336
2216
  } // every time we invoke this setter from outside (through this wrapper setter)
2337
2217
  // we should reset the value and then debounce just in case there is a pending
2338
2218
  // invocation the next tick that is not longer relevant since the value is changing
@@ -2364,7 +2244,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
2364
2244
  */
2365
2245
  function track(target) {
2366
2246
  if (arguments.length === 1) {
2367
- return reactiveMembrane.getProxy(target);
2247
+ return getReactiveProxy(target);
2368
2248
  }
2369
2249
  if (process.env.NODE_ENV !== 'production') {
2370
2250
  assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
@@ -2375,7 +2255,6 @@ function internalTrackDecorator(key) {
2375
2255
  return {
2376
2256
  get() {
2377
2257
  const vm = getAssociatedVM(this);
2378
- componentValueObserved(vm, key);
2379
2258
  return vm.cmpFields[key];
2380
2259
  },
2381
2260
  set(newValue) {
@@ -2385,11 +2264,8 @@ function internalTrackDecorator(key) {
2385
2264
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2386
2265
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2387
2266
  }
2388
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
2389
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2390
- vm.cmpFields[key] = reactiveOrAnyValue;
2391
- componentValueMutated(vm, key);
2392
- }
2267
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
2268
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2393
2269
  },
2394
2270
  enumerable: true,
2395
2271
  configurable: true,
@@ -2417,7 +2293,6 @@ function internalWireFieldDecorator(key) {
2417
2293
  return {
2418
2294
  get() {
2419
2295
  const vm = getAssociatedVM(this);
2420
- componentValueObserved(vm, key);
2421
2296
  return vm.cmpFields[key];
2422
2297
  },
2423
2298
  set(value) {
@@ -2428,10 +2303,7 @@ function internalWireFieldDecorator(key) {
2428
2303
  * letting the author to do the wrong thing, but it will keep our
2429
2304
  * system to be backward compatible.
2430
2305
  */
2431
- if (value !== vm.cmpFields[key]) {
2432
- vm.cmpFields[key] = value;
2433
- componentValueMutated(vm, key);
2434
- }
2306
+ updateComponentValue(vm, key, value);
2435
2307
  },
2436
2308
  enumerable: true,
2437
2309
  configurable: true,
@@ -2777,7 +2649,7 @@ function createSetter(key) {
2777
2649
  fn = cachedSetterByKey[key] = function (newValue) {
2778
2650
  const vm = getAssociatedVM(this);
2779
2651
  const { setHook } = vm;
2780
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
2652
+ newValue = getReadOnlyProxy(newValue);
2781
2653
  setHook(vm.component, key, newValue);
2782
2654
  };
2783
2655
  }
@@ -2915,7 +2787,7 @@ function getTemplateOrSwappedTemplate(tpl) {
2915
2787
  throw new ReferenceError();
2916
2788
  }
2917
2789
 
2918
- if (runtimeFlags.ENABLE_HMR) {
2790
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2919
2791
  const visited = new Set();
2920
2792
 
2921
2793
  while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
@@ -2932,7 +2804,7 @@ function getComponentOrSwappedComponent(Ctor) {
2932
2804
  throw new ReferenceError();
2933
2805
  }
2934
2806
 
2935
- if (runtimeFlags.ENABLE_HMR) {
2807
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2936
2808
  const visited = new Set();
2937
2809
 
2938
2810
  while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
@@ -2949,7 +2821,7 @@ function getStyleOrSwappedStyle(style) {
2949
2821
  throw new ReferenceError();
2950
2822
  }
2951
2823
 
2952
- if (runtimeFlags.ENABLE_HMR) {
2824
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2953
2825
  const visited = new Set();
2954
2826
 
2955
2827
  while (swappedStyleMap.has(style) && !visited.has(style)) {
@@ -2966,7 +2838,7 @@ function setActiveVM(vm) {
2966
2838
  throw new ReferenceError();
2967
2839
  }
2968
2840
 
2969
- if (runtimeFlags.ENABLE_HMR) {
2841
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2970
2842
  // tracking active component
2971
2843
  const Ctor = vm.def.ctor;
2972
2844
  let componentVMs = activeComponents.get(Ctor);
@@ -3023,7 +2895,7 @@ function removeActiveVM(vm) {
3023
2895
  throw new ReferenceError();
3024
2896
  }
3025
2897
 
3026
- if (runtimeFlags.ENABLE_HMR) {
2898
+ if (lwcRuntimeFlags.ENABLE_HMR) {
3027
2899
  // tracking inactive component
3028
2900
  const Ctor = vm.def.ctor;
3029
2901
  let list = activeComponents.get(Ctor);
@@ -3389,38 +3261,20 @@ function getScopeTokenClass(owner) {
3389
3261
  const { cmpTemplate, context } = owner;
3390
3262
  return (context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) || null;
3391
3263
  }
3392
- function getNearestNativeShadowComponent(vm) {
3393
- const owner = getNearestShadowComponent(vm);
3394
- if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
3395
- // Synthetic-within-native is impossible. So if the nearest shadow component is
3396
- // synthetic, we know we won't find a native component if we go any further.
3397
- return null;
3398
- }
3399
- return owner;
3400
- }
3401
3264
  function createStylesheet(vm, stylesheets) {
3402
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3265
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3403
3266
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3404
3267
  for (let i = 0; i < stylesheets.length; i++) {
3405
3268
  insertStylesheet(stylesheets[i]);
3406
3269
  }
3407
3270
  }
3408
- else if (ssr || vm.hydrated) {
3271
+ else {
3409
3272
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3410
3273
  // This works in the client, because the stylesheets are created, and cached in the VM
3411
3274
  // the first time the VM renders.
3412
3275
  // native shadow or light DOM, SSR
3413
3276
  return ArrayMap.call(stylesheets, createInlineStyleVNode);
3414
3277
  }
3415
- else {
3416
- // native shadow or light DOM, DOM renderer
3417
- const root = getNearestNativeShadowComponent(vm);
3418
- // null root means a global style
3419
- const target = isNull(root) ? undefined : root.shadowRoot;
3420
- for (let i = 0; i < stylesheets.length; i++) {
3421
- insertStylesheet(stylesheets[i], target);
3422
- }
3423
- }
3424
3278
  return null;
3425
3279
  }
3426
3280
 
@@ -3706,7 +3560,7 @@ function patchChildren(c1, c2, parent, renderer) {
3706
3560
  updateStaticChildren(c1, c2, parent, renderer);
3707
3561
  }
3708
3562
  }
3709
- function patch(n1, n2, renderer) {
3563
+ function patch(n1, n2, parent, renderer) {
3710
3564
  var _a, _b;
3711
3565
  if (n1 === n2) {
3712
3566
  return;
@@ -3735,7 +3589,7 @@ function patch(n1, n2, renderer) {
3735
3589
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3736
3590
  break;
3737
3591
  case 3 /* VNodeType.CustomElement */:
3738
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3592
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3739
3593
  break;
3740
3594
  }
3741
3595
  }
@@ -3862,22 +3716,32 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3862
3716
  appendVM(vm);
3863
3717
  }
3864
3718
  }
3865
- function patchCustomElement(n1, n2, renderer) {
3866
- const elm = (n2.elm = n1.elm);
3867
- const vm = (n2.vm = n1.vm);
3868
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3869
- if (!isUndefined$1(vm)) {
3870
- // in fallback mode, the allocation will always set children to
3871
- // empty and delegate the real allocation to the slot elements
3872
- allocateChildren(n2, vm);
3719
+ function patchCustomElement(n1, n2, parent, renderer) {
3720
+ if (n1.ctor !== n2.ctor) {
3721
+ // If the constructor, unmount the current component and mount a new one using the new
3722
+ // constructor.
3723
+ const anchor = renderer.nextSibling(n1.elm);
3724
+ unmount(n1, parent, renderer, true);
3725
+ mountCustomElement(n2, parent, anchor, renderer);
3873
3726
  }
3874
- // in fallback mode, the children will be always empty, so, nothing
3875
- // will happen, but in native, it does allocate the light dom
3876
- patchChildren(n1.children, n2.children, elm, renderer);
3877
- if (!isUndefined$1(vm)) {
3878
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3879
- // this is important to preserve the top to bottom synchronous rendering phase.
3880
- rerenderVM(vm);
3727
+ else {
3728
+ // Otherwise patch the existing component with new props/attrs/etc.
3729
+ const elm = (n2.elm = n1.elm);
3730
+ const vm = (n2.vm = n1.vm);
3731
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3732
+ if (!isUndefined$1(vm)) {
3733
+ // in fallback mode, the allocation will always set children to
3734
+ // empty and delegate the real allocation to the slot elements
3735
+ allocateChildren(n2, vm);
3736
+ }
3737
+ // in fallback mode, the children will be always empty, so, nothing
3738
+ // will happen, but in native, it does allocate the light dom
3739
+ patchChildren(n1.children, n2.children, elm, renderer);
3740
+ if (!isUndefined$1(vm)) {
3741
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3742
+ // this is important to preserve the top to bottom synchronous rendering phase.
3743
+ rerenderVM(vm);
3744
+ }
3881
3745
  }
3882
3746
  }
3883
3747
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -4147,25 +4011,25 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4147
4011
  newEndVnode = newCh[--newEndIdx];
4148
4012
  }
4149
4013
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4150
- patch(oldStartVnode, newStartVnode, renderer);
4014
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4151
4015
  oldStartVnode = oldCh[++oldStartIdx];
4152
4016
  newStartVnode = newCh[++newStartIdx];
4153
4017
  }
4154
4018
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4155
- patch(oldEndVnode, newEndVnode, renderer);
4019
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4156
4020
  oldEndVnode = oldCh[--oldEndIdx];
4157
4021
  newEndVnode = newCh[--newEndIdx];
4158
4022
  }
4159
4023
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4160
4024
  // Vnode moved right
4161
- patch(oldStartVnode, newEndVnode, renderer);
4025
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4162
4026
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4163
4027
  oldStartVnode = oldCh[++oldStartIdx];
4164
4028
  newEndVnode = newCh[--newEndIdx];
4165
4029
  }
4166
4030
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4167
4031
  // Vnode moved left
4168
- patch(oldEndVnode, newStartVnode, renderer);
4032
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4169
4033
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4170
4034
  oldEndVnode = oldCh[--oldEndIdx];
4171
4035
  newStartVnode = newCh[++newStartIdx];
@@ -4188,7 +4052,7 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4188
4052
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4189
4053
  }
4190
4054
  else {
4191
- patch(elmToMove, newStartVnode, renderer);
4055
+ patch(elmToMove, newStartVnode, parent, renderer);
4192
4056
  // Delete the old child, but copy the array since it is read-only.
4193
4057
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4194
4058
  // so we only care about the `oldCh` object inside this function.
@@ -4248,7 +4112,7 @@ function updateStaticChildren(c1, c2, parent, renderer) {
4248
4112
  if (isVNode(n1)) {
4249
4113
  if (isVNode(n2)) {
4250
4114
  // both vnodes are equivalent, and we just need to patch them
4251
- patch(n1, n2, renderer);
4115
+ patch(n1, n2, parent, renderer);
4252
4116
  anchor = n2.elm;
4253
4117
  }
4254
4118
  else {
@@ -4582,13 +4446,6 @@ function fid(url) {
4582
4446
  }
4583
4447
  return url;
4584
4448
  }
4585
- /**
4586
- * Map to store an index value assigned to any dynamic component reference ingested
4587
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4588
- * component reference to avoid diffing algo mismatches.
4589
- */
4590
- const DynamicImportedComponentMap = new Map();
4591
- let dynamicImportedComponentCounter = 0;
4592
4449
  /**
4593
4450
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4594
4451
  */
@@ -4605,18 +4462,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
4605
4462
  if (!isComponentConstructor(Ctor)) {
4606
4463
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4607
4464
  }
4608
- let idx = DynamicImportedComponentMap.get(Ctor);
4609
- if (isUndefined$1(idx)) {
4610
- idx = dynamicImportedComponentCounter++;
4611
- DynamicImportedComponentMap.set(Ctor, idx);
4612
- }
4613
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4614
- // to identify different constructors as vnodes with different keys to avoid reusing the
4615
- // element used for previous constructors.
4616
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4617
- // hoisting optimization.
4618
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4619
- return c(sel, Ctor, newData, children);
4465
+ return c(sel, Ctor, data, children);
4620
4466
  }
4621
4467
  /**
4622
4468
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5053,13 +4899,7 @@ function getComponentRegisteredTemplate(Ctor) {
5053
4899
  return signedTemplateMap.get(Ctor);
5054
4900
  }
5055
4901
  function getTemplateReactiveObserver(vm) {
5056
- return new ReactiveObserver(() => {
5057
- const { isDirty } = vm;
5058
- if (isFalse(isDirty)) {
5059
- markComponentAsDirty(vm);
5060
- scheduleRehydration(vm);
5061
- }
5062
- });
4902
+ return createReactiveObserver();
5063
4903
  }
5064
4904
  function renderComponent$1(vm) {
5065
4905
  if (process.env.NODE_ENV !== 'production') {
@@ -5296,14 +5136,14 @@ function createVM(elm, ctor, renderer, options) {
5296
5136
  renderer
5297
5137
  };
5298
5138
  vm.shadowMode = computeShadowMode(vm, renderer);
5299
- vm.tro = getTemplateReactiveObserver(vm);
5139
+ vm.tro = getTemplateReactiveObserver();
5300
5140
 
5301
5141
  if (process.env.NODE_ENV !== 'production') {
5302
5142
  vm.toString = () => {
5303
5143
  return `[object:vm ${def.name} (${vm.idx})]`;
5304
5144
  };
5305
5145
 
5306
- if (runtimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5146
+ if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5307
5147
  vm.shadowMode = 0
5308
5148
  /* ShadowMode.Native */
5309
5149
  ;
@@ -5342,7 +5182,7 @@ function computeShadowMode(vm, renderer) {
5342
5182
  } else if (isNativeShadowDefined) {
5343
5183
  // Not combined with above condition because @lwc/features only supports identifiers in
5344
5184
  // the if-condition.
5345
- if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5185
+ if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5346
5186
  if (def.shadowSupportMode === "any"
5347
5187
  /* ShadowSupportMode.Any */
5348
5188
  ) {
@@ -5458,89 +5298,7 @@ function patchShadowRoot(vm, newCh) {
5458
5298
 
5459
5299
  if (vm.state === 1
5460
5300
  /* VMState.connected */
5461
- ) {
5462
- // If the element is connected, that means connectedCallback was already issued, and
5463
- // any successive rendering should finish with the call to renderedCallback, otherwise
5464
- // the connectedCallback will take care of calling it in the right order at the end of
5465
- // the current rehydration process.
5466
- runRenderedCallback(vm);
5467
- }
5468
- }
5469
-
5470
- function runRenderedCallback(vm) {
5471
- const {
5472
- def: {
5473
- renderedCallback
5474
- },
5475
- renderer: {
5476
- ssr
5477
- }
5478
- } = vm;
5479
-
5480
- if (isTrue(ssr)) {
5481
- return;
5482
- }
5483
-
5484
- const {
5485
- rendered
5486
- } = Services;
5487
-
5488
- if (rendered) {
5489
- invokeServiceHook(vm, rendered);
5490
- }
5491
-
5492
- if (!isUndefined$1(renderedCallback)) {
5493
- logOperationStart(4
5494
- /* OperationId.RenderedCallback */
5495
- , vm);
5496
- invokeComponentCallback(vm, renderedCallback);
5497
- logOperationEnd(4
5498
- /* OperationId.RenderedCallback */
5499
- , vm);
5500
- }
5501
- }
5502
- let rehydrateQueue = [];
5503
-
5504
- function flushRehydrationQueue() {
5505
- logGlobalOperationStart(8
5506
- /* OperationId.GlobalRehydrate */
5507
- );
5508
-
5509
- if (process.env.NODE_ENV !== 'production') {
5510
- 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}.`);
5511
- }
5512
-
5513
- const vms = rehydrateQueue.sort((a, b) => a.idx - b.idx);
5514
- rehydrateQueue = []; // reset to a new queue
5515
-
5516
- for (let i = 0, len = vms.length; i < len; i += 1) {
5517
- const vm = vms[i];
5518
-
5519
- try {
5520
- rehydrate(vm);
5521
- } catch (error) {
5522
- if (i + 1 < len) {
5523
- // pieces of the queue are still pending to be rehydrated, those should have priority
5524
- if (rehydrateQueue.length === 0) {
5525
- addCallbackToNextTick(flushRehydrationQueue);
5526
- }
5527
-
5528
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, i + 1));
5529
- } // we need to end the measure before throwing.
5530
-
5531
-
5532
- logGlobalOperationEnd(8
5533
- /* OperationId.GlobalRehydrate */
5534
- ); // re-throwing the original error will break the current tick, but since the next tick is
5535
- // already scheduled, it should continue patching the rest.
5536
-
5537
- throw error; // eslint-disable-line no-unsafe-finally
5538
- }
5539
- }
5540
-
5541
- logGlobalOperationEnd(8
5542
- /* OperationId.GlobalRehydrate */
5543
- );
5301
+ ) ;
5544
5302
  }
5545
5303
 
5546
5304
  function runConnectedCallback(vm) {
@@ -5729,25 +5487,6 @@ function resetComponentRoot(vm) {
5729
5487
  runChildNodesDisconnectedCallback(vm);
5730
5488
  vm.velements = EmptyArray;
5731
5489
  }
5732
- function scheduleRehydration(vm) {
5733
- const {
5734
- renderer: {
5735
- ssr
5736
- }
5737
- } = vm;
5738
-
5739
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5740
- return;
5741
- }
5742
-
5743
- vm.isScheduled = true;
5744
-
5745
- if (rehydrateQueue.length === 0) {
5746
- addCallbackToNextTick(flushRehydrationQueue);
5747
- }
5748
-
5749
- ArrayPush$1.call(rehydrateQueue, vm);
5750
- }
5751
5490
 
5752
5491
  function getErrorBoundaryVM(vm) {
5753
5492
  let currentVm = vm;
@@ -5826,15 +5565,8 @@ class WireContextRegistrationEvent extends CustomEvent {
5826
5565
  }
5827
5566
 
5828
5567
  function createFieldDataCallback(vm, name) {
5829
- const {
5830
- cmpFields
5831
- } = vm;
5832
5568
  return value => {
5833
- if (value !== vm.cmpFields[name]) {
5834
- // storing the value in the underlying storage
5835
- cmpFields[name] = value;
5836
- componentValueMutated(vm, name);
5837
- }
5569
+ updateComponentValue(vm, name, value);
5838
5570
  };
5839
5571
  }
5840
5572
 
@@ -5849,21 +5581,8 @@ function createMethodDataCallback(vm, method) {
5849
5581
  }
5850
5582
 
5851
5583
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
5852
- let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
5853
5584
 
5854
- const ro = new ReactiveObserver(() => {
5855
- if (hasPendingConfig === false) {
5856
- hasPendingConfig = true; // collect new config in the micro-task
5857
-
5858
- Promise.resolve().then(() => {
5859
- hasPendingConfig = false; // resetting current reactive params
5860
-
5861
- ro.reset(); // dispatching a new config due to a change in the configuration
5862
-
5863
- computeConfigAndUpdate();
5864
- });
5865
- }
5866
- });
5585
+ const ro = createReactiveObserver();
5867
5586
 
5868
5587
  const computeConfigAndUpdate = () => {
5869
5588
  let config;
@@ -6052,7 +5771,7 @@ function installWireAdapters(vm) {
6052
5771
  ArrayPush$1.call(wiredConnecting, () => {
6053
5772
  connector.connect();
6054
5773
 
6055
- if (!runtimeFlags.ENABLE_WIRE_SYNC_EMIT) {
5774
+ if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
6056
5775
  if (hasDynamicParams) {
6057
5776
  Promise.resolve().then(computeConfigAndUpdate);
6058
5777
  return;
@@ -6147,7 +5866,7 @@ function readonly(obj) {
6147
5866
  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.');
6148
5867
  }
6149
5868
  }
6150
- return reactiveMembrane.getReadOnlyProxy(obj);
5869
+ return getReadOnlyProxy(obj);
6151
5870
  }
6152
5871
 
6153
5872
  /*
@@ -6261,7 +5980,7 @@ function freezeTemplate(tmpl) {
6261
5980
  });
6262
5981
  }
6263
5982
  }
6264
- /* version: 2.21.1 */
5983
+ /* version: 2.23.1 */
6265
5984
 
6266
5985
  /*
6267
5986
  * Copyright (c) 2020, salesforce.com, inc.
@@ -6344,10 +6063,6 @@ class HTMLElementImpl {
6344
6063
  return createElement(tagName);
6345
6064
  }
6346
6065
  }
6347
- const ssr = true;
6348
- function isHydrating() {
6349
- return false;
6350
- }
6351
6066
  const isNativeShadowDefined = false;
6352
6067
  const isSyntheticShadowDefined = false;
6353
6068
  function insert(node, parent, anchor) {
@@ -6586,11 +6301,9 @@ const HTMLElementExported = HTMLElementImpl;
6586
6301
  /* noop */
6587
6302
  const assertInstanceOfHTMLElement = noop;
6588
6303
  const renderer = {
6589
- ssr,
6590
6304
  isNativeShadowDefined,
6591
6305
  isSyntheticShadowDefined,
6592
6306
  HTMLElementExported,
6593
- isHydrating,
6594
6307
  insert,
6595
6308
  remove,
6596
6309
  cloneNode,
@@ -6737,7 +6450,7 @@ function renderComponent(tagName, Ctor, props = {}) {
6737
6450
  */
6738
6451
  freeze(LightningElement);
6739
6452
  seal(LightningElement.prototype);
6740
- /* version: 2.21.1 */
6453
+ /* version: 2.23.1 */
6741
6454
 
6742
6455
  exports.LightningElement = LightningElement;
6743
6456
  exports.api = api$1;