lwc 2.21.0 → 2.23.0

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 +234 -236
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +234 -236
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +221 -224
  5. package/dist/engine-dom/iife/es5/engine-dom.js +282 -265
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +257 -237
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +234 -236
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +221 -224
  11. package/dist/engine-dom/umd/es5/engine-dom.js +282 -265
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +257 -237
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +138 -445
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +138 -445
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +13 -10
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +13 -10
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +13 -10
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +15 -14
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +15 -14
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +13 -10
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +13 -10
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +15 -14
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +15 -14
  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.0";
422
+ const LWC_VERSION = "2.23.0";
423
423
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
424
- /** version: 2.21.0 */
424
+ /** version: 2.23.0 */
425
425
 
426
426
  /*
427
427
  * Copyright (c) 2020, salesforce.com, inc.
@@ -530,7 +530,7 @@ function setFeatureFlagForTest(name, value) {
530
530
  setFeatureFlag(name, value);
531
531
  }
532
532
  }
533
- /** version: 2.21.0 */
533
+ /** version: 2.23.0 */
534
534
 
535
535
  /* proxy-compat-disable */
536
536
 
@@ -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,
@@ -2332,7 +2212,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
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
  }
@@ -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
  }
@@ -3796,10 +3650,11 @@ function mountElement(vnode, parent, anchor, renderer) {
3796
3650
  const { sel, owner, data: { svg }, } = vnode;
3797
3651
  const { createElement } = renderer;
3798
3652
  const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3799
- const elm = createElement(sel, namespace);
3653
+ const elm = (vnode.elm = createElement(sel, namespace));
3800
3654
  linkNodeToShadow(elm, owner, renderer);
3801
- fallbackElmHook(elm, vnode, renderer);
3802
- vnode.elm = elm;
3655
+ applyStyleScoping(elm, owner, renderer);
3656
+ applyDomManual(elm, vnode);
3657
+ applyElementRestrictions(elm, vnode);
3803
3658
  patchElementPropsAndAttrs$1(null, vnode, renderer);
3804
3659
  insertNode(elm, parent, anchor, renderer);
3805
3660
  mountVNodes(vnode.children, elm, renderer, null);
@@ -3814,6 +3669,7 @@ function mountStatic(vnode, parent, anchor, renderer) {
3814
3669
  const { cloneNode, isSyntheticShadowDefined } = renderer;
3815
3670
  const elm = (vnode.elm = cloneNode(vnode.fragment, true));
3816
3671
  linkNodeToShadow(elm, owner, renderer);
3672
+ applyElementRestrictions(elm, vnode);
3817
3673
  // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3818
3674
  const { renderMode, shadowMode } = owner;
3819
3675
  if (isSyntheticShadowDefined) {
@@ -3821,10 +3677,6 @@ function mountStatic(vnode, parent, anchor, renderer) {
3821
3677
  elm[KEY__SHADOW_STATIC] = true;
3822
3678
  }
3823
3679
  }
3824
- if (process.env.NODE_ENV !== 'production') {
3825
- const isLight = renderMode === 0 /* RenderMode.Light */;
3826
- patchElementWithRestrictions(elm, { isPortal: false, isLight });
3827
- }
3828
3680
  insertNode(elm, parent, anchor, renderer);
3829
3681
  }
3830
3682
  function mountCustomElement(vnode, parent, anchor, renderer) {
@@ -3841,9 +3693,10 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3841
3693
  // the custom element from the registry is expecting an upgrade callback
3842
3694
  vm = createViewModelHook(elm, vnode, renderer);
3843
3695
  });
3844
- linkNodeToShadow(elm, owner, renderer);
3845
3696
  vnode.elm = elm;
3846
3697
  vnode.vm = vm;
3698
+ linkNodeToShadow(elm, owner, renderer);
3699
+ applyStyleScoping(elm, owner, renderer);
3847
3700
  if (vm) {
3848
3701
  allocateChildren(vnode, vm);
3849
3702
  }
@@ -3863,22 +3716,32 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3863
3716
  appendVM(vm);
3864
3717
  }
3865
3718
  }
3866
- function patchCustomElement(n1, n2, renderer) {
3867
- const elm = (n2.elm = n1.elm);
3868
- const vm = (n2.vm = n1.vm);
3869
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3870
- if (!isUndefined$1(vm)) {
3871
- // in fallback mode, the allocation will always set children to
3872
- // empty and delegate the real allocation to the slot elements
3873
- 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);
3874
3726
  }
3875
- // in fallback mode, the children will be always empty, so, nothing
3876
- // will happen, but in native, it does allocate the light dom
3877
- patchChildren(n1.children, n2.children, elm, renderer);
3878
- if (!isUndefined$1(vm)) {
3879
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3880
- // this is important to preserve the top to bottom synchronous rendering phase.
3881
- 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
+ }
3882
3745
  }
3883
3746
  }
3884
3747
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -3927,22 +3790,6 @@ function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, en
3927
3790
  function isVNode(vnode) {
3928
3791
  return vnode != null;
3929
3792
  }
3930
- function observeElementChildNodes(elm) {
3931
- elm.$domManual$ = true;
3932
- }
3933
- function setElementShadowToken(elm, token) {
3934
- elm.$shadowToken$ = token;
3935
- }
3936
- // Set the scope token class for *.scoped.css styles
3937
- function setScopeTokenClassIfNecessary(elm, owner, renderer) {
3938
- const token = getScopeTokenClass(owner);
3939
- if (!isNull(token)) {
3940
- const { getClassList } = renderer;
3941
- // TODO [#2762]: this dot notation with add is probably problematic
3942
- // probably we should have a renderer api for just the add operation
3943
- getClassList(elm).add(token);
3944
- }
3945
- }
3946
3793
  function linkNodeToShadow(elm, owner, renderer) {
3947
3794
  const { renderRoot, renderMode, shadowMode } = owner;
3948
3795
  const { isSyntheticShadowDefined } = renderer;
@@ -3995,31 +3842,37 @@ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
3995
3842
  patchAttributes(oldVnode, vnode, renderer);
3996
3843
  patchProps(oldVnode, vnode, renderer);
3997
3844
  }
3998
- function fallbackElmHook(elm, vnode, renderer) {
3999
- const { owner } = vnode;
4000
- setScopeTokenClassIfNecessary(elm, owner, renderer);
4001
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
4002
- const { data: { context }, } = vnode;
4003
- const { stylesheetToken } = owner.context;
4004
- if (!isUndefined$1(context) &&
4005
- !isUndefined$1(context.lwc) &&
4006
- context.lwc.dom === "manual" /* LwcDomMode.Manual */) {
4007
- // this element will now accept any manual content inserted into it
4008
- observeElementChildNodes(elm);
4009
- }
4010
- if (!isUndefined$1(stylesheetToken)) {
4011
- // when running in synthetic shadow mode, we need to set the shadowToken value
4012
- // into each element from the template, so they can be styled accordingly.
4013
- setElementShadowToken(elm, stylesheetToken);
4014
- }
3845
+ function applyStyleScoping(elm, owner, renderer) {
3846
+ // Set the class name for `*.scoped.css` style scoping.
3847
+ const scopeToken = getScopeTokenClass(owner);
3848
+ if (!isNull(scopeToken)) {
3849
+ const { getClassList } = renderer;
3850
+ // TODO [#2762]: this dot notation with add is probably problematic
3851
+ // probably we should have a renderer api for just the add operation
3852
+ getClassList(elm).add(scopeToken);
4015
3853
  }
3854
+ // Set property element for synthetic shadow DOM style scoping.
3855
+ const { stylesheetToken: syntheticToken } = owner.context;
3856
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
3857
+ elm.$shadowToken$ = syntheticToken;
3858
+ }
3859
+ }
3860
+ function applyDomManual(elm, vnode) {
3861
+ var _a;
3862
+ const { owner, data: { context }, } = vnode;
3863
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
3864
+ elm.$domManual$ = true;
3865
+ }
3866
+ }
3867
+ function applyElementRestrictions(elm, vnode) {
3868
+ var _a, _b;
4016
3869
  if (process.env.NODE_ENV !== 'production') {
4017
- const { data: { context }, } = vnode;
4018
- const isPortal = !isUndefined$1(context) &&
4019
- !isUndefined$1(context.lwc) &&
4020
- context.lwc.dom === "manual" /* LwcDomMode.Manual */;
4021
- const isLight = owner.renderMode === 0 /* RenderMode.Light */;
4022
- patchElementWithRestrictions(elm, { isPortal, isLight });
3870
+ const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
3871
+ const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
3872
+ patchElementWithRestrictions(elm, {
3873
+ isPortal,
3874
+ isLight,
3875
+ });
4023
3876
  }
4024
3877
  }
4025
3878
  function allocateChildren(vnode, vm) {
@@ -4054,15 +3907,6 @@ function createViewModelHook(elm, vnode, renderer) {
4054
3907
  return vm;
4055
3908
  }
4056
3909
  const { sel, mode, ctor, owner } = vnode;
4057
- setScopeTokenClassIfNecessary(elm, owner, renderer);
4058
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
4059
- const { stylesheetToken } = owner.context;
4060
- // when running in synthetic shadow mode, we need to set the shadowToken value
4061
- // into each element from the template, so they can be styled accordingly.
4062
- if (!isUndefined$1(stylesheetToken)) {
4063
- setElementShadowToken(elm, stylesheetToken);
4064
- }
4065
- }
4066
3910
  vm = createVM(elm, ctor, renderer, {
4067
3911
  mode,
4068
3912
  owner,
@@ -4167,25 +4011,25 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4167
4011
  newEndVnode = newCh[--newEndIdx];
4168
4012
  }
4169
4013
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4170
- patch(oldStartVnode, newStartVnode, renderer);
4014
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4171
4015
  oldStartVnode = oldCh[++oldStartIdx];
4172
4016
  newStartVnode = newCh[++newStartIdx];
4173
4017
  }
4174
4018
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4175
- patch(oldEndVnode, newEndVnode, renderer);
4019
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4176
4020
  oldEndVnode = oldCh[--oldEndIdx];
4177
4021
  newEndVnode = newCh[--newEndIdx];
4178
4022
  }
4179
4023
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4180
4024
  // Vnode moved right
4181
- patch(oldStartVnode, newEndVnode, renderer);
4025
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4182
4026
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4183
4027
  oldStartVnode = oldCh[++oldStartIdx];
4184
4028
  newEndVnode = newCh[--newEndIdx];
4185
4029
  }
4186
4030
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4187
4031
  // Vnode moved left
4188
- patch(oldEndVnode, newStartVnode, renderer);
4032
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4189
4033
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4190
4034
  oldEndVnode = oldCh[--oldEndIdx];
4191
4035
  newStartVnode = newCh[++newStartIdx];
@@ -4208,7 +4052,7 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
4208
4052
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4209
4053
  }
4210
4054
  else {
4211
- patch(elmToMove, newStartVnode, renderer);
4055
+ patch(elmToMove, newStartVnode, parent, renderer);
4212
4056
  // Delete the old child, but copy the array since it is read-only.
4213
4057
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4214
4058
  // so we only care about the `oldCh` object inside this function.
@@ -4268,7 +4112,7 @@ function updateStaticChildren(c1, c2, parent, renderer) {
4268
4112
  if (isVNode(n1)) {
4269
4113
  if (isVNode(n2)) {
4270
4114
  // both vnodes are equivalent, and we just need to patch them
4271
- patch(n1, n2, renderer);
4115
+ patch(n1, n2, parent, renderer);
4272
4116
  anchor = n2.elm;
4273
4117
  }
4274
4118
  else {
@@ -4602,13 +4446,6 @@ function fid(url) {
4602
4446
  }
4603
4447
  return url;
4604
4448
  }
4605
- /**
4606
- * Map to store an index value assigned to any dynamic component reference ingested
4607
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4608
- * component reference to avoid diffing algo mismatches.
4609
- */
4610
- const DynamicImportedComponentMap = new Map();
4611
- let dynamicImportedComponentCounter = 0;
4612
4449
  /**
4613
4450
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4614
4451
  */
@@ -4625,18 +4462,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
4625
4462
  if (!isComponentConstructor(Ctor)) {
4626
4463
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4627
4464
  }
4628
- let idx = DynamicImportedComponentMap.get(Ctor);
4629
- if (isUndefined$1(idx)) {
4630
- idx = dynamicImportedComponentCounter++;
4631
- DynamicImportedComponentMap.set(Ctor, idx);
4632
- }
4633
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4634
- // to identify different constructors as vnodes with different keys to avoid reusing the
4635
- // element used for previous constructors.
4636
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4637
- // hoisting optimization.
4638
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4639
- return c(sel, Ctor, newData, children);
4465
+ return c(sel, Ctor, data, children);
4640
4466
  }
4641
4467
  /**
4642
4468
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5073,13 +4899,7 @@ function getComponentRegisteredTemplate(Ctor) {
5073
4899
  return signedTemplateMap.get(Ctor);
5074
4900
  }
5075
4901
  function getTemplateReactiveObserver(vm) {
5076
- return new ReactiveObserver(() => {
5077
- const { isDirty } = vm;
5078
- if (isFalse(isDirty)) {
5079
- markComponentAsDirty(vm);
5080
- scheduleRehydration(vm);
5081
- }
5082
- });
4902
+ return createReactiveObserver();
5083
4903
  }
5084
4904
  function renderComponent$1(vm) {
5085
4905
  if (process.env.NODE_ENV !== 'production') {
@@ -5316,7 +5136,7 @@ function createVM(elm, ctor, renderer, options) {
5316
5136
  renderer
5317
5137
  };
5318
5138
  vm.shadowMode = computeShadowMode(vm, renderer);
5319
- vm.tro = getTemplateReactiveObserver(vm);
5139
+ vm.tro = getTemplateReactiveObserver();
5320
5140
 
5321
5141
  if (process.env.NODE_ENV !== 'production') {
5322
5142
  vm.toString = () => {
@@ -5478,89 +5298,7 @@ function patchShadowRoot(vm, newCh) {
5478
5298
 
5479
5299
  if (vm.state === 1
5480
5300
  /* VMState.connected */
5481
- ) {
5482
- // If the element is connected, that means connectedCallback was already issued, and
5483
- // any successive rendering should finish with the call to renderedCallback, otherwise
5484
- // the connectedCallback will take care of calling it in the right order at the end of
5485
- // the current rehydration process.
5486
- runRenderedCallback(vm);
5487
- }
5488
- }
5489
-
5490
- function runRenderedCallback(vm) {
5491
- const {
5492
- def: {
5493
- renderedCallback
5494
- },
5495
- renderer: {
5496
- ssr
5497
- }
5498
- } = vm;
5499
-
5500
- if (isTrue(ssr)) {
5501
- return;
5502
- }
5503
-
5504
- const {
5505
- rendered
5506
- } = Services;
5507
-
5508
- if (rendered) {
5509
- invokeServiceHook(vm, rendered);
5510
- }
5511
-
5512
- if (!isUndefined$1(renderedCallback)) {
5513
- logOperationStart(4
5514
- /* OperationId.RenderedCallback */
5515
- , vm);
5516
- invokeComponentCallback(vm, renderedCallback);
5517
- logOperationEnd(4
5518
- /* OperationId.RenderedCallback */
5519
- , vm);
5520
- }
5521
- }
5522
- let rehydrateQueue = [];
5523
-
5524
- function flushRehydrationQueue() {
5525
- logGlobalOperationStart(8
5526
- /* OperationId.GlobalRehydrate */
5527
- );
5528
-
5529
- if (process.env.NODE_ENV !== 'production') {
5530
- 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}.`);
5531
- }
5532
-
5533
- const vms = rehydrateQueue.sort((a, b) => a.idx - b.idx);
5534
- rehydrateQueue = []; // reset to a new queue
5535
-
5536
- for (let i = 0, len = vms.length; i < len; i += 1) {
5537
- const vm = vms[i];
5538
-
5539
- try {
5540
- rehydrate(vm);
5541
- } catch (error) {
5542
- if (i + 1 < len) {
5543
- // pieces of the queue are still pending to be rehydrated, those should have priority
5544
- if (rehydrateQueue.length === 0) {
5545
- addCallbackToNextTick(flushRehydrationQueue);
5546
- }
5547
-
5548
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, i + 1));
5549
- } // we need to end the measure before throwing.
5550
-
5551
-
5552
- logGlobalOperationEnd(8
5553
- /* OperationId.GlobalRehydrate */
5554
- ); // re-throwing the original error will break the current tick, but since the next tick is
5555
- // already scheduled, it should continue patching the rest.
5556
-
5557
- throw error; // eslint-disable-line no-unsafe-finally
5558
- }
5559
- }
5560
-
5561
- logGlobalOperationEnd(8
5562
- /* OperationId.GlobalRehydrate */
5563
- );
5301
+ ) ;
5564
5302
  }
5565
5303
 
5566
5304
  function runConnectedCallback(vm) {
@@ -5749,25 +5487,6 @@ function resetComponentRoot(vm) {
5749
5487
  runChildNodesDisconnectedCallback(vm);
5750
5488
  vm.velements = EmptyArray;
5751
5489
  }
5752
- function scheduleRehydration(vm) {
5753
- const {
5754
- renderer: {
5755
- ssr
5756
- }
5757
- } = vm;
5758
-
5759
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5760
- return;
5761
- }
5762
-
5763
- vm.isScheduled = true;
5764
-
5765
- if (rehydrateQueue.length === 0) {
5766
- addCallbackToNextTick(flushRehydrationQueue);
5767
- }
5768
-
5769
- ArrayPush$1.call(rehydrateQueue, vm);
5770
- }
5771
5490
 
5772
5491
  function getErrorBoundaryVM(vm) {
5773
5492
  let currentVm = vm;
@@ -5846,15 +5565,8 @@ class WireContextRegistrationEvent extends CustomEvent {
5846
5565
  }
5847
5566
 
5848
5567
  function createFieldDataCallback(vm, name) {
5849
- const {
5850
- cmpFields
5851
- } = vm;
5852
5568
  return value => {
5853
- if (value !== vm.cmpFields[name]) {
5854
- // storing the value in the underlying storage
5855
- cmpFields[name] = value;
5856
- componentValueMutated(vm, name);
5857
- }
5569
+ updateComponentValue(vm, name, value);
5858
5570
  };
5859
5571
  }
5860
5572
 
@@ -5869,21 +5581,8 @@ function createMethodDataCallback(vm, method) {
5869
5581
  }
5870
5582
 
5871
5583
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
5872
- let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
5873
-
5874
- const ro = new ReactiveObserver(() => {
5875
- if (hasPendingConfig === false) {
5876
- hasPendingConfig = true; // collect new config in the micro-task
5877
5584
 
5878
- Promise.resolve().then(() => {
5879
- hasPendingConfig = false; // resetting current reactive params
5880
-
5881
- ro.reset(); // dispatching a new config due to a change in the configuration
5882
-
5883
- computeConfigAndUpdate();
5884
- });
5885
- }
5886
- });
5585
+ const ro = createReactiveObserver();
5887
5586
 
5888
5587
  const computeConfigAndUpdate = () => {
5889
5588
  let config;
@@ -6167,7 +5866,7 @@ function readonly(obj) {
6167
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.');
6168
5867
  }
6169
5868
  }
6170
- return reactiveMembrane.getReadOnlyProxy(obj);
5869
+ return getReadOnlyProxy(obj);
6171
5870
  }
6172
5871
 
6173
5872
  /*
@@ -6281,7 +5980,7 @@ function freezeTemplate(tmpl) {
6281
5980
  });
6282
5981
  }
6283
5982
  }
6284
- /* version: 2.21.0 */
5983
+ /* version: 2.23.0 */
6285
5984
 
6286
5985
  /*
6287
5986
  * Copyright (c) 2020, salesforce.com, inc.
@@ -6364,10 +6063,6 @@ class HTMLElementImpl {
6364
6063
  return createElement(tagName);
6365
6064
  }
6366
6065
  }
6367
- const ssr = true;
6368
- function isHydrating() {
6369
- return false;
6370
- }
6371
6066
  const isNativeShadowDefined = false;
6372
6067
  const isSyntheticShadowDefined = false;
6373
6068
  function insert(node, parent, anchor) {
@@ -6606,11 +6301,9 @@ const HTMLElementExported = HTMLElementImpl;
6606
6301
  /* noop */
6607
6302
  const assertInstanceOfHTMLElement = noop;
6608
6303
  const renderer = {
6609
- ssr,
6610
6304
  isNativeShadowDefined,
6611
6305
  isSyntheticShadowDefined,
6612
6306
  HTMLElementExported,
6613
- isHydrating,
6614
6307
  insert,
6615
6308
  remove,
6616
6309
  cloneNode,
@@ -6757,7 +6450,7 @@ function renderComponent(tagName, Ctor, props = {}) {
6757
6450
  */
6758
6451
  freeze(LightningElement);
6759
6452
  seal(LightningElement.prototype);
6760
- /* version: 2.21.0 */
6453
+ /* version: 2.23.0 */
6761
6454
 
6762
6455
  exports.LightningElement = LightningElement;
6763
6456
  exports.api = api$1;