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
@@ -302,9 +302,13 @@ var LWC = (function (exports) {
302
302
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
303
303
  */
304
304
  // Increment whenever the LWC template compiler changes
305
- const LWC_VERSION = "2.21.1";
305
+ const LWC_VERSION = "2.23.1";
306
306
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
307
- /** version: 2.21.1 */
307
+ /** version: 2.23.1 */
308
+
309
+ /**
310
+ * Copyright (C) 2018 salesforce.com, inc.
311
+ */
308
312
 
309
313
  /*
310
314
  * Copyright (c) 2018, salesforce.com, inc.
@@ -313,7 +317,7 @@ var LWC = (function (exports) {
313
317
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
314
318
  */
315
319
  function detect(propName) {
316
- return Object.getOwnPropertyDescriptor(Element.prototype, propName) === undefined;
320
+ return getOwnPropertyDescriptor$1(Element.prototype, propName) === undefined;
317
321
  }
318
322
 
319
323
  /*
@@ -382,6 +386,7 @@ var LWC = (function (exports) {
382
386
  patch$1(propName);
383
387
  }
384
388
  }
389
+ /** version: 2.23.1 */
385
390
 
386
391
  /**
387
392
  * Copyright (C) 2018 salesforce.com, inc.
@@ -409,7 +414,7 @@ var LWC = (function (exports) {
409
414
  if (!_globalThis.lwcRuntimeFlags) {
410
415
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
411
416
  }
412
- const runtimeFlags = _globalThis.lwcRuntimeFlags;
417
+ const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
413
418
  /**
414
419
  * Set the value at runtime of a given feature flag. This method only be invoked once per feature
415
420
  * flag. It is meant to be used during the app initialization.
@@ -436,17 +441,17 @@ var LWC = (function (exports) {
436
441
  }
437
442
  if (process.env.NODE_ENV !== 'production') {
438
443
  // Allow the same flag to be set more than once outside of production to enable testing
439
- runtimeFlags[name] = value;
444
+ lwcRuntimeFlags[name] = value;
440
445
  }
441
446
  else {
442
447
  // Disallow the same flag to be set more than once in production
443
- const runtimeValue = runtimeFlags[name];
448
+ const runtimeValue = lwcRuntimeFlags[name];
444
449
  if (!isUndefined$1(runtimeValue)) {
445
450
  // eslint-disable-next-line no-console
446
451
  console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
447
452
  return;
448
453
  }
449
- defineProperty(runtimeFlags, name, { value });
454
+ defineProperty(lwcRuntimeFlags, name, { value });
450
455
  }
451
456
  }
452
457
  /**
@@ -458,7 +463,7 @@ var LWC = (function (exports) {
458
463
  setFeatureFlag(name, value);
459
464
  }
460
465
  }
461
- /** version: 2.21.1 */
466
+ /** version: 2.23.1 */
462
467
 
463
468
  /*
464
469
  * Copyright (c) 2018, salesforce.com, inc.
@@ -472,7 +477,7 @@ var LWC = (function (exports) {
472
477
  window.addEventListener('test-dummy-flag', () => {
473
478
  let hasFlag = false;
474
479
 
475
- if (runtimeFlags.DUMMY_TEST_FLAG) {
480
+ if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
476
481
  hasFlag = true;
477
482
  }
478
483
 
@@ -499,7 +504,7 @@ var LWC = (function (exports) {
499
504
  window.addEventListener('test-dummy-flag', () => {
500
505
  let hasFlag = false;
501
506
 
502
- if (runtimeFlags.DUMMY_TEST_FLAG) {
507
+ if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
503
508
  hasFlag = true;
504
509
  }
505
510
 
@@ -690,18 +695,21 @@ var LWC = (function (exports) {
690
695
  ArrayPush$1.call(this.listeners, reactiveObservers);
691
696
  }
692
697
  }
693
-
694
- /*
695
- * Copyright (c) 2018, salesforce.com, inc.
696
- * All rights reserved.
697
- * SPDX-License-Identifier: MIT
698
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
699
- */
700
698
  function componentValueMutated(vm, key) {
701
- valueMutated(vm.component, key);
699
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
700
+ {
701
+ valueMutated(vm.component, key);
702
+ }
702
703
  }
703
704
  function componentValueObserved(vm, key) {
704
- valueObserved(vm.component, key);
705
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
706
+ {
707
+ valueObserved(vm.component, key);
708
+ }
709
+ }
710
+ function createReactiveObserver(callback) {
711
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
712
+ return new ReactiveObserver(callback) ;
705
713
  }
706
714
 
707
715
  /*
@@ -1260,6 +1268,14 @@ var LWC = (function (exports) {
1260
1268
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1261
1269
  }
1262
1270
 
1271
+ function updateComponentValue(vm, key, newValue) {
1272
+ const { cmpFields } = vm;
1273
+ if (newValue !== cmpFields[key]) {
1274
+ cmpFields[key] = newValue;
1275
+ componentValueMutated(vm, key);
1276
+ }
1277
+ }
1278
+
1263
1279
  /**
1264
1280
  * Copyright (C) 2017 salesforce.com, inc.
1265
1281
  */
@@ -1823,7 +1839,24 @@ var LWC = (function (exports) {
1823
1839
  * change or being removed.
1824
1840
  */
1825
1841
  function unwrap(value) {
1826
- return reactiveMembrane.unwrapProxy(value);
1842
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1843
+ return reactiveMembrane.unwrapProxy(value) ;
1844
+ }
1845
+ function getReadOnlyProxy(value) {
1846
+ // We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
1847
+ // them from their parents. This applies to both the client and server.
1848
+ return reactiveMembrane.getReadOnlyProxy(value);
1849
+ }
1850
+ function getReactiveProxy(value) {
1851
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1852
+ return reactiveMembrane.getProxy(value) ;
1853
+ }
1854
+ // Making the component instance a live value when using Locker to support expandos.
1855
+ function markLockerLiveObject(obj) {
1856
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1857
+ {
1858
+ obj[lockerLivePropertyKey] = undefined;
1859
+ }
1827
1860
  }
1828
1861
 
1829
1862
  /*
@@ -1875,10 +1908,7 @@ var LWC = (function (exports) {
1875
1908
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1876
1909
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1877
1910
  }
1878
- if (newValue !== vm.cmpProps[propName]) {
1879
- vm.cmpProps[propName] = newValue;
1880
- componentValueMutated(vm, propName);
1881
- }
1911
+ updateComponentValue(vm, propName, newValue);
1882
1912
  return set.call(vm.elm, newValue);
1883
1913
  },
1884
1914
  };
@@ -1913,8 +1943,7 @@ var LWC = (function (exports) {
1913
1943
  vm.setHook = setHook;
1914
1944
  vm.getHook = getHook;
1915
1945
  }
1916
- // Making the component instance a live value when using Locker to support expandos.
1917
- this[lockerLivePropertyKey] = undefined;
1946
+ markLockerLiveObject(this);
1918
1947
  // Linking elm, shadow root and component with the VM.
1919
1948
  associateVM(component, vm);
1920
1949
  associateVM(elm, vm);
@@ -2174,15 +2203,51 @@ var LWC = (function (exports) {
2174
2203
  },
2175
2204
  set(newValue) {
2176
2205
  const vm = getAssociatedVM(this);
2177
- if (newValue !== vm.cmpFields[key]) {
2178
- vm.cmpFields[key] = newValue;
2179
- componentValueMutated(vm, key);
2180
- }
2206
+ updateComponentValue(vm, key, newValue);
2181
2207
  },
2182
2208
  enumerable: true,
2183
2209
  configurable: true,
2184
2210
  };
2185
2211
  }
2212
+ class AccessorReactiveObserver extends ReactiveObserver {
2213
+ constructor(vm, set) {
2214
+ super(() => {
2215
+ if (isFalse(this.debouncing)) {
2216
+ this.debouncing = true;
2217
+ addCallbackToNextTick(() => {
2218
+ if (isTrue(this.debouncing)) {
2219
+ const { value } = this;
2220
+ const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
2221
+ set.call(component, value);
2222
+ // de-bouncing after the call to the original setter to prevent
2223
+ // infinity loop if the setter itself is mutating things that
2224
+ // were accessed during the previous invocation.
2225
+ this.debouncing = false;
2226
+ if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2227
+ // immediate rehydration due to a setter driven mutation, otherwise
2228
+ // the component will get rendered on the second tick, which it is not
2229
+ // desirable.
2230
+ rerenderVM(vm);
2231
+ }
2232
+ }
2233
+ });
2234
+ }
2235
+ });
2236
+ this.debouncing = false;
2237
+ }
2238
+ reset(value) {
2239
+ super.reset();
2240
+ this.debouncing = false;
2241
+ if (arguments.length > 0) {
2242
+ this.value = value;
2243
+ }
2244
+ }
2245
+ }
2246
+ function createAccessorReactiveObserver(vm, set) {
2247
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
2248
+ return new AccessorReactiveObserver(vm, set)
2249
+ ;
2250
+ }
2186
2251
 
2187
2252
  /*
2188
2253
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2231,50 +2296,6 @@ var LWC = (function (exports) {
2231
2296
  configurable: true
2232
2297
  };
2233
2298
  }
2234
- class AccessorReactiveObserver extends ReactiveObserver {
2235
- constructor(vm, set) {
2236
- super(() => {
2237
- if (isFalse(this.debouncing)) {
2238
- this.debouncing = true;
2239
- addCallbackToNextTick(() => {
2240
- if (isTrue(this.debouncing)) {
2241
- const {
2242
- value
2243
- } = this;
2244
- const {
2245
- isDirty: dirtyStateBeforeSetterCall,
2246
- component,
2247
- idx
2248
- } = vm;
2249
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
2250
- // infinity loop if the setter itself is mutating things that
2251
- // were accessed during the previous invocation.
2252
-
2253
- this.debouncing = false;
2254
-
2255
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2256
- // immediate rehydration due to a setter driven mutation, otherwise
2257
- // the component will get rendered on the second tick, which it is not
2258
- // desirable.
2259
- rerenderVM(vm);
2260
- }
2261
- }
2262
- });
2263
- }
2264
- });
2265
- this.debouncing = false;
2266
- }
2267
-
2268
- reset(value) {
2269
- super.reset();
2270
- this.debouncing = false;
2271
-
2272
- if (arguments.length > 0) {
2273
- this.value = value;
2274
- }
2275
- }
2276
-
2277
- }
2278
2299
  function createPublicAccessorDescriptor(key, descriptor) {
2279
2300
  const {
2280
2301
  get,
@@ -2311,11 +2332,11 @@ var LWC = (function (exports) {
2311
2332
  }
2312
2333
 
2313
2334
  if (set) {
2314
- if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
2335
+ if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
2315
2336
  let ro = vm.oar[key];
2316
2337
 
2317
2338
  if (isUndefined$1(ro)) {
2318
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
2339
+ ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
2319
2340
  } // every time we invoke this setter from outside (through this wrapper setter)
2320
2341
  // we should reset the value and then debounce just in case there is a pending
2321
2342
  // invocation the next tick that is not longer relevant since the value is changing
@@ -2347,7 +2368,7 @@ var LWC = (function (exports) {
2347
2368
  */
2348
2369
  function track(target) {
2349
2370
  if (arguments.length === 1) {
2350
- return reactiveMembrane.getProxy(target);
2371
+ return getReactiveProxy(target);
2351
2372
  }
2352
2373
  if (process.env.NODE_ENV !== 'production') {
2353
2374
  assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
@@ -2368,11 +2389,8 @@ var LWC = (function (exports) {
2368
2389
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2369
2390
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2370
2391
  }
2371
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
2372
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2373
- vm.cmpFields[key] = reactiveOrAnyValue;
2374
- componentValueMutated(vm, key);
2375
- }
2392
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
2393
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2376
2394
  },
2377
2395
  enumerable: true,
2378
2396
  configurable: true,
@@ -2411,10 +2429,7 @@ var LWC = (function (exports) {
2411
2429
  * letting the author to do the wrong thing, but it will keep our
2412
2430
  * system to be backward compatible.
2413
2431
  */
2414
- if (value !== vm.cmpFields[key]) {
2415
- vm.cmpFields[key] = value;
2416
- componentValueMutated(vm, key);
2417
- }
2432
+ updateComponentValue(vm, key, value);
2418
2433
  },
2419
2434
  enumerable: true,
2420
2435
  configurable: true,
@@ -2760,7 +2775,7 @@ var LWC = (function (exports) {
2760
2775
  fn = cachedSetterByKey[key] = function (newValue) {
2761
2776
  const vm = getAssociatedVM(this);
2762
2777
  const { setHook } = vm;
2763
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
2778
+ newValue = getReadOnlyProxy(newValue);
2764
2779
  setHook(vm.component, key, newValue);
2765
2780
  };
2766
2781
  }
@@ -2969,7 +2984,7 @@ var LWC = (function (exports) {
2969
2984
  throw new ReferenceError();
2970
2985
  }
2971
2986
 
2972
- if (runtimeFlags.ENABLE_HMR) {
2987
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2973
2988
  const visited = new Set();
2974
2989
 
2975
2990
  while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
@@ -2986,7 +3001,7 @@ var LWC = (function (exports) {
2986
3001
  throw new ReferenceError();
2987
3002
  }
2988
3003
 
2989
- if (runtimeFlags.ENABLE_HMR) {
3004
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2990
3005
  const visited = new Set();
2991
3006
 
2992
3007
  while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
@@ -3003,7 +3018,7 @@ var LWC = (function (exports) {
3003
3018
  throw new ReferenceError();
3004
3019
  }
3005
3020
 
3006
- if (runtimeFlags.ENABLE_HMR) {
3021
+ if (lwcRuntimeFlags.ENABLE_HMR) {
3007
3022
  const visited = new Set();
3008
3023
 
3009
3024
  while (swappedStyleMap.has(style) && !visited.has(style)) {
@@ -3020,7 +3035,7 @@ var LWC = (function (exports) {
3020
3035
  throw new ReferenceError();
3021
3036
  }
3022
3037
 
3023
- if (runtimeFlags.ENABLE_HMR) {
3038
+ if (lwcRuntimeFlags.ENABLE_HMR) {
3024
3039
  // tracking active component
3025
3040
  const Ctor = vm.def.ctor;
3026
3041
  let componentVMs = activeComponents.get(Ctor);
@@ -3077,7 +3092,7 @@ var LWC = (function (exports) {
3077
3092
  throw new ReferenceError();
3078
3093
  }
3079
3094
 
3080
- if (runtimeFlags.ENABLE_HMR) {
3095
+ if (lwcRuntimeFlags.ENABLE_HMR) {
3081
3096
  // tracking inactive component
3082
3097
  const Ctor = vm.def.ctor;
3083
3098
  let list = activeComponents.get(Ctor);
@@ -3124,7 +3139,7 @@ var LWC = (function (exports) {
3124
3139
  }
3125
3140
  }
3126
3141
 
3127
- if (!runtimeFlags.ENABLE_HMR) {
3142
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
3128
3143
  throw new Error('HMR is not enabled');
3129
3144
  }
3130
3145
 
@@ -3140,7 +3155,7 @@ var LWC = (function (exports) {
3140
3155
  }
3141
3156
  }
3142
3157
 
3143
- if (!runtimeFlags.ENABLE_HMR) {
3158
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
3144
3159
  throw new Error('HMR is not enabled');
3145
3160
  }
3146
3161
 
@@ -3154,7 +3169,7 @@ var LWC = (function (exports) {
3154
3169
  return rehydrateHotStyle(oldStyle);
3155
3170
  }
3156
3171
 
3157
- if (!runtimeFlags.ENABLE_HMR) {
3172
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
3158
3173
  throw new Error('HMR is not enabled');
3159
3174
  }
3160
3175
 
@@ -3503,13 +3518,13 @@ var LWC = (function (exports) {
3503
3518
  return owner;
3504
3519
  }
3505
3520
  function createStylesheet(vm, stylesheets) {
3506
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3521
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3507
3522
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3508
3523
  for (let i = 0; i < stylesheets.length; i++) {
3509
3524
  insertStylesheet(stylesheets[i]);
3510
3525
  }
3511
3526
  }
3512
- else if (ssr || vm.hydrated) {
3527
+ else if (vm.hydrated) {
3513
3528
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3514
3529
  // This works in the client, because the stylesheets are created, and cached in the VM
3515
3530
  // the first time the VM renders.
@@ -3810,7 +3825,7 @@ var LWC = (function (exports) {
3810
3825
  updateStaticChildren(c1, c2, parent, renderer);
3811
3826
  }
3812
3827
  }
3813
- function patch(n1, n2, renderer) {
3828
+ function patch(n1, n2, parent, renderer) {
3814
3829
  var _a, _b;
3815
3830
  if (n1 === n2) {
3816
3831
  return;
@@ -3839,7 +3854,7 @@ var LWC = (function (exports) {
3839
3854
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3840
3855
  break;
3841
3856
  case 3 /* VNodeType.CustomElement */:
3842
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3857
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3843
3858
  break;
3844
3859
  }
3845
3860
  }
@@ -3966,22 +3981,32 @@ var LWC = (function (exports) {
3966
3981
  appendVM(vm);
3967
3982
  }
3968
3983
  }
3969
- function patchCustomElement(n1, n2, renderer) {
3970
- const elm = (n2.elm = n1.elm);
3971
- const vm = (n2.vm = n1.vm);
3972
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3973
- if (!isUndefined$1(vm)) {
3974
- // in fallback mode, the allocation will always set children to
3975
- // empty and delegate the real allocation to the slot elements
3976
- allocateChildren(n2, vm);
3984
+ function patchCustomElement(n1, n2, parent, renderer) {
3985
+ if (n1.ctor !== n2.ctor) {
3986
+ // If the constructor, unmount the current component and mount a new one using the new
3987
+ // constructor.
3988
+ const anchor = renderer.nextSibling(n1.elm);
3989
+ unmount(n1, parent, renderer, true);
3990
+ mountCustomElement(n2, parent, anchor, renderer);
3977
3991
  }
3978
- // in fallback mode, the children will be always empty, so, nothing
3979
- // will happen, but in native, it does allocate the light dom
3980
- patchChildren(n1.children, n2.children, elm, renderer);
3981
- if (!isUndefined$1(vm)) {
3982
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3983
- // this is important to preserve the top to bottom synchronous rendering phase.
3984
- rerenderVM(vm);
3992
+ else {
3993
+ // Otherwise patch the existing component with new props/attrs/etc.
3994
+ const elm = (n2.elm = n1.elm);
3995
+ const vm = (n2.vm = n1.vm);
3996
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3997
+ if (!isUndefined$1(vm)) {
3998
+ // in fallback mode, the allocation will always set children to
3999
+ // empty and delegate the real allocation to the slot elements
4000
+ allocateChildren(n2, vm);
4001
+ }
4002
+ // in fallback mode, the children will be always empty, so, nothing
4003
+ // will happen, but in native, it does allocate the light dom
4004
+ patchChildren(n1.children, n2.children, elm, renderer);
4005
+ if (!isUndefined$1(vm)) {
4006
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4007
+ // this is important to preserve the top to bottom synchronous rendering phase.
4008
+ rerenderVM(vm);
4009
+ }
3985
4010
  }
3986
4011
  }
3987
4012
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -4251,25 +4276,25 @@ var LWC = (function (exports) {
4251
4276
  newEndVnode = newCh[--newEndIdx];
4252
4277
  }
4253
4278
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4254
- patch(oldStartVnode, newStartVnode, renderer);
4279
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4255
4280
  oldStartVnode = oldCh[++oldStartIdx];
4256
4281
  newStartVnode = newCh[++newStartIdx];
4257
4282
  }
4258
4283
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4259
- patch(oldEndVnode, newEndVnode, renderer);
4284
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4260
4285
  oldEndVnode = oldCh[--oldEndIdx];
4261
4286
  newEndVnode = newCh[--newEndIdx];
4262
4287
  }
4263
4288
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4264
4289
  // Vnode moved right
4265
- patch(oldStartVnode, newEndVnode, renderer);
4290
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4266
4291
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4267
4292
  oldStartVnode = oldCh[++oldStartIdx];
4268
4293
  newEndVnode = newCh[--newEndIdx];
4269
4294
  }
4270
4295
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4271
4296
  // Vnode moved left
4272
- patch(oldEndVnode, newStartVnode, renderer);
4297
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4273
4298
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4274
4299
  oldEndVnode = oldCh[--oldEndIdx];
4275
4300
  newStartVnode = newCh[++newStartIdx];
@@ -4292,7 +4317,7 @@ var LWC = (function (exports) {
4292
4317
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4293
4318
  }
4294
4319
  else {
4295
- patch(elmToMove, newStartVnode, renderer);
4320
+ patch(elmToMove, newStartVnode, parent, renderer);
4296
4321
  // Delete the old child, but copy the array since it is read-only.
4297
4322
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4298
4323
  // so we only care about the `oldCh` object inside this function.
@@ -4352,7 +4377,7 @@ var LWC = (function (exports) {
4352
4377
  if (isVNode(n1)) {
4353
4378
  if (isVNode(n2)) {
4354
4379
  // both vnodes are equivalent, and we just need to patch them
4355
- patch(n1, n2, renderer);
4380
+ patch(n1, n2, parent, renderer);
4356
4381
  anchor = n2.elm;
4357
4382
  }
4358
4383
  else {
@@ -4686,13 +4711,6 @@ var LWC = (function (exports) {
4686
4711
  }
4687
4712
  return url;
4688
4713
  }
4689
- /**
4690
- * Map to store an index value assigned to any dynamic component reference ingested
4691
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4692
- * component reference to avoid diffing algo mismatches.
4693
- */
4694
- const DynamicImportedComponentMap = new Map();
4695
- let dynamicImportedComponentCounter = 0;
4696
4714
  /**
4697
4715
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4698
4716
  */
@@ -4709,18 +4727,7 @@ var LWC = (function (exports) {
4709
4727
  if (!isComponentConstructor(Ctor)) {
4710
4728
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4711
4729
  }
4712
- let idx = DynamicImportedComponentMap.get(Ctor);
4713
- if (isUndefined$1(idx)) {
4714
- idx = dynamicImportedComponentCounter++;
4715
- DynamicImportedComponentMap.set(Ctor, idx);
4716
- }
4717
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4718
- // to identify different constructors as vnodes with different keys to avoid reusing the
4719
- // element used for previous constructors.
4720
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4721
- // hoisting optimization.
4722
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4723
- return c(sel, Ctor, newData, children);
4730
+ return c(sel, Ctor, data, children);
4724
4731
  }
4725
4732
  /**
4726
4733
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5196,7 +5203,7 @@ var LWC = (function (exports) {
5196
5203
  return signedTemplateMap.get(Ctor);
5197
5204
  }
5198
5205
  function getTemplateReactiveObserver(vm) {
5199
- return new ReactiveObserver(() => {
5206
+ return createReactiveObserver(() => {
5200
5207
  const { isDirty } = vm;
5201
5208
  if (isFalse(isDirty)) {
5202
5209
  markComponentAsDirty(vm);
@@ -5446,7 +5453,7 @@ var LWC = (function (exports) {
5446
5453
  return `[object:vm ${def.name} (${vm.idx})]`;
5447
5454
  };
5448
5455
 
5449
- if (runtimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5456
+ if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5450
5457
  vm.shadowMode = 0
5451
5458
  /* ShadowMode.Native */
5452
5459
  ;
@@ -5485,7 +5492,7 @@ var LWC = (function (exports) {
5485
5492
  } else if (isNativeShadowDefined) {
5486
5493
  // Not combined with above condition because @lwc/features only supports identifiers in
5487
5494
  // the if-condition.
5488
- if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5495
+ if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5489
5496
  if (def.shadowSupportMode === "any"
5490
5497
  /* ShadowSupportMode.Any */
5491
5498
  ) {
@@ -5614,16 +5621,9 @@ var LWC = (function (exports) {
5614
5621
  const {
5615
5622
  def: {
5616
5623
  renderedCallback
5617
- },
5618
- renderer: {
5619
- ssr
5620
5624
  }
5621
5625
  } = vm;
5622
5626
 
5623
- if (isTrue(ssr)) {
5624
- return;
5625
- }
5626
-
5627
5627
  const {
5628
5628
  rendered
5629
5629
  } = Services;
@@ -5873,13 +5873,7 @@ var LWC = (function (exports) {
5873
5873
  vm.velements = EmptyArray;
5874
5874
  }
5875
5875
  function scheduleRehydration(vm) {
5876
- const {
5877
- renderer: {
5878
- ssr
5879
- }
5880
- } = vm;
5881
-
5882
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5876
+ if (isTrue(vm.isScheduled)) {
5883
5877
  return;
5884
5878
  }
5885
5879
 
@@ -5986,15 +5980,8 @@ var LWC = (function (exports) {
5986
5980
  }
5987
5981
 
5988
5982
  function createFieldDataCallback(vm, name) {
5989
- const {
5990
- cmpFields
5991
- } = vm;
5992
5983
  return value => {
5993
- if (value !== vm.cmpFields[name]) {
5994
- // storing the value in the underlying storage
5995
- cmpFields[name] = value;
5996
- componentValueMutated(vm, name);
5997
- }
5984
+ updateComponentValue(vm, name, value);
5998
5985
  };
5999
5986
  }
6000
5987
 
@@ -6011,7 +5998,7 @@ var LWC = (function (exports) {
6011
5998
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
6012
5999
  let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
6013
6000
 
6014
- const ro = new ReactiveObserver(() => {
6001
+ const ro = createReactiveObserver(() => {
6015
6002
  if (hasPendingConfig === false) {
6016
6003
  hasPendingConfig = true; // collect new config in the micro-task
6017
6004
 
@@ -6212,7 +6199,7 @@ var LWC = (function (exports) {
6212
6199
  ArrayPush$1.call(wiredConnecting, () => {
6213
6200
  connector.connect();
6214
6201
 
6215
- if (!runtimeFlags.ENABLE_WIRE_SYNC_EMIT) {
6202
+ if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
6216
6203
  if (hasDynamicParams) {
6217
6204
  Promise.resolve().then(computeConfigAndUpdate);
6218
6205
  return;
@@ -6307,7 +6294,7 @@ var LWC = (function (exports) {
6307
6294
  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.');
6308
6295
  }
6309
6296
  }
6310
- return reactiveMembrane.getReadOnlyProxy(obj);
6297
+ return getReadOnlyProxy(obj);
6311
6298
  }
6312
6299
 
6313
6300
  /*
@@ -6818,7 +6805,7 @@ var LWC = (function (exports) {
6818
6805
  }
6819
6806
  return ctor;
6820
6807
  }
6821
- /* version: 2.21.1 */
6808
+ /* version: 2.23.1 */
6822
6809
 
6823
6810
  /*
6824
6811
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6962,6 +6949,69 @@ var LWC = (function (exports) {
6962
6949
  }
6963
6950
  }
6964
6951
 
6952
+ /*
6953
+ * Copyright (c) 2018, salesforce.com, inc.
6954
+ * All rights reserved.
6955
+ * SPDX-License-Identifier: MIT
6956
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6957
+ */
6958
+ const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
6959
+ let createFragment;
6960
+ if (SUPPORTS_TEMPLATE) {
6961
+ // Parse the fragment HTML string into DOM
6962
+ createFragment = function (html) {
6963
+ const template = document.createElement('template');
6964
+ template.innerHTML = html;
6965
+ return template.content.firstChild;
6966
+ };
6967
+ }
6968
+ else {
6969
+ // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
6970
+ // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
6971
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
6972
+ // With other elements added from:
6973
+ // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
6974
+ // Using the test:
6975
+ // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
6976
+ // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
6977
+ const topLevelWrappingMap = {
6978
+ caption: ['table'],
6979
+ col: ['colgroup', 'table'],
6980
+ colgroup: ['table'],
6981
+ option: ['select'],
6982
+ tbody: ['table'],
6983
+ td: ['tr', 'tbody', 'table'],
6984
+ th: ['tr', 'tbody', 'table'],
6985
+ thead: ['table'],
6986
+ tfoot: ['table'],
6987
+ tr: ['tbody', 'table'],
6988
+ };
6989
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
6990
+ const getTagName = function (text) {
6991
+ return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
6992
+ };
6993
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
6994
+ createFragment = function (html) {
6995
+ const wrapperTags = topLevelWrappingMap[getTagName(html)];
6996
+ if (!isUndefined$1(wrapperTags)) {
6997
+ for (const wrapperTag of wrapperTags) {
6998
+ html = `<${wrapperTag}>${html}</${wrapperTag}>`;
6999
+ }
7000
+ }
7001
+ // For IE11, the document title must not be undefined, but it can be an empty string
7002
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
7003
+ const doc = document.implementation.createHTMLDocument('');
7004
+ doc.body.innerHTML = html;
7005
+ let content = doc.body;
7006
+ if (!isUndefined$1(wrapperTags)) {
7007
+ for (let i = 0; i < wrapperTags.length; i++) {
7008
+ content = content.firstChild;
7009
+ }
7010
+ }
7011
+ return content.firstChild;
7012
+ };
7013
+ }
7014
+
6965
7015
  /*
6966
7016
  * Copyright (c) 2018, salesforce.com, inc.
6967
7017
  * All rights reserved.
@@ -7027,22 +7077,11 @@ var LWC = (function (exports) {
7027
7077
  };
7028
7078
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7029
7079
  }
7030
- let hydrating = false;
7031
- function setIsHydrating(value) {
7032
- hydrating = value;
7033
- }
7034
- const ssr = false;
7035
- function isHydrating() {
7036
- return hydrating;
7037
- }
7038
7080
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
7039
7081
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
7040
7082
  function cloneNode(node, deep) {
7041
7083
  return node.cloneNode(deep);
7042
7084
  }
7043
- function createFragment(html) {
7044
- return document.createRange().createContextualFragment(html).firstChild;
7045
- }
7046
7085
  function createElement$1(tagName, namespace) {
7047
7086
  return isUndefined$1(namespace)
7048
7087
  ? document.createElement(tagName)
@@ -7064,15 +7103,11 @@ var LWC = (function (exports) {
7064
7103
  return node.nextSibling;
7065
7104
  }
7066
7105
  function attachShadow(element, options) {
7067
- // `hydrating` will be true in two cases:
7106
+ // `shadowRoot` will be non-null in two cases:
7068
7107
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
7069
7108
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
7070
- // root component with customeElement.define('c-app', Ctor)
7071
- //
7072
- // The second case can be treated as a failed hydration with nominal impact
7073
- // to performance. However, because <c-app> won't have a <template shadowroot>
7074
- // declarative child, `element.shadowRoot` is `null`.
7075
- if (hydrating && element.shadowRoot) {
7109
+ // root component with customElement.define('c-app', Ctor)
7110
+ if (!isNull(element.shadowRoot)) {
7076
7111
  return element.shadowRoot;
7077
7112
  }
7078
7113
  return element.attachShadow(options);
@@ -7168,11 +7203,9 @@ var LWC = (function (exports) {
7168
7203
  }
7169
7204
  const HTMLElementExported = HTMLElementConstructor;
7170
7205
  const renderer = {
7171
- ssr,
7172
7206
  isNativeShadowDefined,
7173
7207
  isSyntheticShadowDefined,
7174
7208
  HTMLElementExported,
7175
- isHydrating,
7176
7209
  insert,
7177
7210
  remove,
7178
7211
  cloneNode,
@@ -7258,13 +7291,8 @@ var LWC = (function (exports) {
7258
7291
  return;
7259
7292
  }
7260
7293
  try {
7261
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
7262
- // and uses the same algo to create the stylesheets as in SSR.
7263
- setIsHydrating(true);
7264
7294
  const vm = createVMWithProps(element, Ctor, props);
7265
7295
  hydrateRoot(vm);
7266
- // set it back since now we finished hydration.
7267
- setIsHydrating(false);
7268
7296
  }
7269
7297
  catch (e) {
7270
7298
  // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
@@ -7275,13 +7303,8 @@ var LWC = (function (exports) {
7275
7303
  resetShadowRootAndLightDom(element, Ctor);
7276
7304
  // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
7277
7305
  createVMWithProps(element, Ctor, props);
7278
- setIsHydrating(false);
7279
7306
  connectRootElement(element);
7280
7307
  }
7281
- finally {
7282
- // in case there's an error during recovery
7283
- setIsHydrating(false);
7284
- }
7285
7308
  }
7286
7309
 
7287
7310
  /*
@@ -7506,7 +7529,7 @@ var LWC = (function (exports) {
7506
7529
  });
7507
7530
  freeze(LightningElement);
7508
7531
  seal(LightningElement.prototype);
7509
- /* version: 2.21.1 */
7532
+ /* version: 2.23.1 */
7510
7533
 
7511
7534
  exports.LightningElement = LightningElement;
7512
7535
  exports.__unstable__ProfilerControl = profilerControl;