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
@@ -305,9 +305,13 @@
305
305
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
306
306
  */
307
307
  // Increment whenever the LWC template compiler changes
308
- const LWC_VERSION = "2.21.1";
308
+ const LWC_VERSION = "2.23.1";
309
309
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
310
- /** version: 2.21.1 */
310
+ /** version: 2.23.1 */
311
+
312
+ /**
313
+ * Copyright (C) 2018 salesforce.com, inc.
314
+ */
311
315
 
312
316
  /*
313
317
  * Copyright (c) 2018, salesforce.com, inc.
@@ -316,7 +320,7 @@
316
320
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
317
321
  */
318
322
  function detect(propName) {
319
- return Object.getOwnPropertyDescriptor(Element.prototype, propName) === undefined;
323
+ return getOwnPropertyDescriptor$1(Element.prototype, propName) === undefined;
320
324
  }
321
325
 
322
326
  /*
@@ -385,6 +389,7 @@
385
389
  patch$1(propName);
386
390
  }
387
391
  }
392
+ /** version: 2.23.1 */
388
393
 
389
394
  /**
390
395
  * Copyright (C) 2018 salesforce.com, inc.
@@ -412,7 +417,7 @@
412
417
  if (!_globalThis.lwcRuntimeFlags) {
413
418
  Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
414
419
  }
415
- const runtimeFlags = _globalThis.lwcRuntimeFlags;
420
+ const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
416
421
  /**
417
422
  * Set the value at runtime of a given feature flag. This method only be invoked once per feature
418
423
  * flag. It is meant to be used during the app initialization.
@@ -439,17 +444,17 @@
439
444
  }
440
445
  if (process.env.NODE_ENV !== 'production') {
441
446
  // Allow the same flag to be set more than once outside of production to enable testing
442
- runtimeFlags[name] = value;
447
+ lwcRuntimeFlags[name] = value;
443
448
  }
444
449
  else {
445
450
  // Disallow the same flag to be set more than once in production
446
- const runtimeValue = runtimeFlags[name];
451
+ const runtimeValue = lwcRuntimeFlags[name];
447
452
  if (!isUndefined$1(runtimeValue)) {
448
453
  // eslint-disable-next-line no-console
449
454
  console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
450
455
  return;
451
456
  }
452
- defineProperty(runtimeFlags, name, { value });
457
+ defineProperty(lwcRuntimeFlags, name, { value });
453
458
  }
454
459
  }
455
460
  /**
@@ -461,7 +466,7 @@
461
466
  setFeatureFlag(name, value);
462
467
  }
463
468
  }
464
- /** version: 2.21.1 */
469
+ /** version: 2.23.1 */
465
470
 
466
471
  /*
467
472
  * Copyright (c) 2018, salesforce.com, inc.
@@ -475,7 +480,7 @@
475
480
  window.addEventListener('test-dummy-flag', () => {
476
481
  let hasFlag = false;
477
482
 
478
- if (runtimeFlags.DUMMY_TEST_FLAG) {
483
+ if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
479
484
  hasFlag = true;
480
485
  }
481
486
 
@@ -502,7 +507,7 @@
502
507
  window.addEventListener('test-dummy-flag', () => {
503
508
  let hasFlag = false;
504
509
 
505
- if (runtimeFlags.DUMMY_TEST_FLAG) {
510
+ if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
506
511
  hasFlag = true;
507
512
  }
508
513
 
@@ -693,18 +698,21 @@
693
698
  ArrayPush$1.call(this.listeners, reactiveObservers);
694
699
  }
695
700
  }
696
-
697
- /*
698
- * Copyright (c) 2018, salesforce.com, inc.
699
- * All rights reserved.
700
- * SPDX-License-Identifier: MIT
701
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
702
- */
703
701
  function componentValueMutated(vm, key) {
704
- valueMutated(vm.component, key);
702
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
703
+ {
704
+ valueMutated(vm.component, key);
705
+ }
705
706
  }
706
707
  function componentValueObserved(vm, key) {
707
- valueObserved(vm.component, key);
708
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
709
+ {
710
+ valueObserved(vm.component, key);
711
+ }
712
+ }
713
+ function createReactiveObserver(callback) {
714
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
715
+ return new ReactiveObserver(callback) ;
708
716
  }
709
717
 
710
718
  /*
@@ -1263,6 +1271,14 @@
1263
1271
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
1264
1272
  }
1265
1273
 
1274
+ function updateComponentValue(vm, key, newValue) {
1275
+ const { cmpFields } = vm;
1276
+ if (newValue !== cmpFields[key]) {
1277
+ cmpFields[key] = newValue;
1278
+ componentValueMutated(vm, key);
1279
+ }
1280
+ }
1281
+
1266
1282
  /**
1267
1283
  * Copyright (C) 2017 salesforce.com, inc.
1268
1284
  */
@@ -1826,7 +1842,24 @@
1826
1842
  * change or being removed.
1827
1843
  */
1828
1844
  function unwrap(value) {
1829
- return reactiveMembrane.unwrapProxy(value);
1845
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1846
+ return reactiveMembrane.unwrapProxy(value) ;
1847
+ }
1848
+ function getReadOnlyProxy(value) {
1849
+ // We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
1850
+ // them from their parents. This applies to both the client and server.
1851
+ return reactiveMembrane.getReadOnlyProxy(value);
1852
+ }
1853
+ function getReactiveProxy(value) {
1854
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1855
+ return reactiveMembrane.getProxy(value) ;
1856
+ }
1857
+ // Making the component instance a live value when using Locker to support expandos.
1858
+ function markLockerLiveObject(obj) {
1859
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1860
+ {
1861
+ obj[lockerLivePropertyKey] = undefined;
1862
+ }
1830
1863
  }
1831
1864
 
1832
1865
  /*
@@ -1878,10 +1911,7 @@
1878
1911
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1879
1912
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1880
1913
  }
1881
- if (newValue !== vm.cmpProps[propName]) {
1882
- vm.cmpProps[propName] = newValue;
1883
- componentValueMutated(vm, propName);
1884
- }
1914
+ updateComponentValue(vm, propName, newValue);
1885
1915
  return set.call(vm.elm, newValue);
1886
1916
  },
1887
1917
  };
@@ -1916,8 +1946,7 @@
1916
1946
  vm.setHook = setHook;
1917
1947
  vm.getHook = getHook;
1918
1948
  }
1919
- // Making the component instance a live value when using Locker to support expandos.
1920
- this[lockerLivePropertyKey] = undefined;
1949
+ markLockerLiveObject(this);
1921
1950
  // Linking elm, shadow root and component with the VM.
1922
1951
  associateVM(component, vm);
1923
1952
  associateVM(elm, vm);
@@ -2177,15 +2206,51 @@
2177
2206
  },
2178
2207
  set(newValue) {
2179
2208
  const vm = getAssociatedVM(this);
2180
- if (newValue !== vm.cmpFields[key]) {
2181
- vm.cmpFields[key] = newValue;
2182
- componentValueMutated(vm, key);
2183
- }
2209
+ updateComponentValue(vm, key, newValue);
2184
2210
  },
2185
2211
  enumerable: true,
2186
2212
  configurable: true,
2187
2213
  };
2188
2214
  }
2215
+ class AccessorReactiveObserver extends ReactiveObserver {
2216
+ constructor(vm, set) {
2217
+ super(() => {
2218
+ if (isFalse(this.debouncing)) {
2219
+ this.debouncing = true;
2220
+ addCallbackToNextTick(() => {
2221
+ if (isTrue(this.debouncing)) {
2222
+ const { value } = this;
2223
+ const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
2224
+ set.call(component, value);
2225
+ // de-bouncing after the call to the original setter to prevent
2226
+ // infinity loop if the setter itself is mutating things that
2227
+ // were accessed during the previous invocation.
2228
+ this.debouncing = false;
2229
+ if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2230
+ // immediate rehydration due to a setter driven mutation, otherwise
2231
+ // the component will get rendered on the second tick, which it is not
2232
+ // desirable.
2233
+ rerenderVM(vm);
2234
+ }
2235
+ }
2236
+ });
2237
+ }
2238
+ });
2239
+ this.debouncing = false;
2240
+ }
2241
+ reset(value) {
2242
+ super.reset();
2243
+ this.debouncing = false;
2244
+ if (arguments.length > 0) {
2245
+ this.value = value;
2246
+ }
2247
+ }
2248
+ }
2249
+ function createAccessorReactiveObserver(vm, set) {
2250
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
2251
+ return new AccessorReactiveObserver(vm, set)
2252
+ ;
2253
+ }
2189
2254
 
2190
2255
  /*
2191
2256
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2234,50 +2299,6 @@
2234
2299
  configurable: true
2235
2300
  };
2236
2301
  }
2237
- class AccessorReactiveObserver extends ReactiveObserver {
2238
- constructor(vm, set) {
2239
- super(() => {
2240
- if (isFalse(this.debouncing)) {
2241
- this.debouncing = true;
2242
- addCallbackToNextTick(() => {
2243
- if (isTrue(this.debouncing)) {
2244
- const {
2245
- value
2246
- } = this;
2247
- const {
2248
- isDirty: dirtyStateBeforeSetterCall,
2249
- component,
2250
- idx
2251
- } = vm;
2252
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
2253
- // infinity loop if the setter itself is mutating things that
2254
- // were accessed during the previous invocation.
2255
-
2256
- this.debouncing = false;
2257
-
2258
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2259
- // immediate rehydration due to a setter driven mutation, otherwise
2260
- // the component will get rendered on the second tick, which it is not
2261
- // desirable.
2262
- rerenderVM(vm);
2263
- }
2264
- }
2265
- });
2266
- }
2267
- });
2268
- this.debouncing = false;
2269
- }
2270
-
2271
- reset(value) {
2272
- super.reset();
2273
- this.debouncing = false;
2274
-
2275
- if (arguments.length > 0) {
2276
- this.value = value;
2277
- }
2278
- }
2279
-
2280
- }
2281
2302
  function createPublicAccessorDescriptor(key, descriptor) {
2282
2303
  const {
2283
2304
  get,
@@ -2314,11 +2335,11 @@
2314
2335
  }
2315
2336
 
2316
2337
  if (set) {
2317
- if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
2338
+ if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
2318
2339
  let ro = vm.oar[key];
2319
2340
 
2320
2341
  if (isUndefined$1(ro)) {
2321
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
2342
+ ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
2322
2343
  } // every time we invoke this setter from outside (through this wrapper setter)
2323
2344
  // we should reset the value and then debounce just in case there is a pending
2324
2345
  // invocation the next tick that is not longer relevant since the value is changing
@@ -2350,7 +2371,7 @@
2350
2371
  */
2351
2372
  function track(target) {
2352
2373
  if (arguments.length === 1) {
2353
- return reactiveMembrane.getProxy(target);
2374
+ return getReactiveProxy(target);
2354
2375
  }
2355
2376
  if (process.env.NODE_ENV !== 'production') {
2356
2377
  assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
@@ -2371,11 +2392,8 @@
2371
2392
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2372
2393
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2373
2394
  }
2374
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
2375
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2376
- vm.cmpFields[key] = reactiveOrAnyValue;
2377
- componentValueMutated(vm, key);
2378
- }
2395
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
2396
+ updateComponentValue(vm, key, reactiveOrAnyValue);
2379
2397
  },
2380
2398
  enumerable: true,
2381
2399
  configurable: true,
@@ -2414,10 +2432,7 @@
2414
2432
  * letting the author to do the wrong thing, but it will keep our
2415
2433
  * system to be backward compatible.
2416
2434
  */
2417
- if (value !== vm.cmpFields[key]) {
2418
- vm.cmpFields[key] = value;
2419
- componentValueMutated(vm, key);
2420
- }
2435
+ updateComponentValue(vm, key, value);
2421
2436
  },
2422
2437
  enumerable: true,
2423
2438
  configurable: true,
@@ -2763,7 +2778,7 @@
2763
2778
  fn = cachedSetterByKey[key] = function (newValue) {
2764
2779
  const vm = getAssociatedVM(this);
2765
2780
  const { setHook } = vm;
2766
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
2781
+ newValue = getReadOnlyProxy(newValue);
2767
2782
  setHook(vm.component, key, newValue);
2768
2783
  };
2769
2784
  }
@@ -2972,7 +2987,7 @@
2972
2987
  throw new ReferenceError();
2973
2988
  }
2974
2989
 
2975
- if (runtimeFlags.ENABLE_HMR) {
2990
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2976
2991
  const visited = new Set();
2977
2992
 
2978
2993
  while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
@@ -2989,7 +3004,7 @@
2989
3004
  throw new ReferenceError();
2990
3005
  }
2991
3006
 
2992
- if (runtimeFlags.ENABLE_HMR) {
3007
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2993
3008
  const visited = new Set();
2994
3009
 
2995
3010
  while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
@@ -3006,7 +3021,7 @@
3006
3021
  throw new ReferenceError();
3007
3022
  }
3008
3023
 
3009
- if (runtimeFlags.ENABLE_HMR) {
3024
+ if (lwcRuntimeFlags.ENABLE_HMR) {
3010
3025
  const visited = new Set();
3011
3026
 
3012
3027
  while (swappedStyleMap.has(style) && !visited.has(style)) {
@@ -3023,7 +3038,7 @@
3023
3038
  throw new ReferenceError();
3024
3039
  }
3025
3040
 
3026
- if (runtimeFlags.ENABLE_HMR) {
3041
+ if (lwcRuntimeFlags.ENABLE_HMR) {
3027
3042
  // tracking active component
3028
3043
  const Ctor = vm.def.ctor;
3029
3044
  let componentVMs = activeComponents.get(Ctor);
@@ -3080,7 +3095,7 @@
3080
3095
  throw new ReferenceError();
3081
3096
  }
3082
3097
 
3083
- if (runtimeFlags.ENABLE_HMR) {
3098
+ if (lwcRuntimeFlags.ENABLE_HMR) {
3084
3099
  // tracking inactive component
3085
3100
  const Ctor = vm.def.ctor;
3086
3101
  let list = activeComponents.get(Ctor);
@@ -3127,7 +3142,7 @@
3127
3142
  }
3128
3143
  }
3129
3144
 
3130
- if (!runtimeFlags.ENABLE_HMR) {
3145
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
3131
3146
  throw new Error('HMR is not enabled');
3132
3147
  }
3133
3148
 
@@ -3143,7 +3158,7 @@
3143
3158
  }
3144
3159
  }
3145
3160
 
3146
- if (!runtimeFlags.ENABLE_HMR) {
3161
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
3147
3162
  throw new Error('HMR is not enabled');
3148
3163
  }
3149
3164
 
@@ -3157,7 +3172,7 @@
3157
3172
  return rehydrateHotStyle(oldStyle);
3158
3173
  }
3159
3174
 
3160
- if (!runtimeFlags.ENABLE_HMR) {
3175
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
3161
3176
  throw new Error('HMR is not enabled');
3162
3177
  }
3163
3178
 
@@ -3506,13 +3521,13 @@
3506
3521
  return owner;
3507
3522
  }
3508
3523
  function createStylesheet(vm, stylesheets) {
3509
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3524
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3510
3525
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3511
3526
  for (let i = 0; i < stylesheets.length; i++) {
3512
3527
  insertStylesheet(stylesheets[i]);
3513
3528
  }
3514
3529
  }
3515
- else if (ssr || vm.hydrated) {
3530
+ else if (vm.hydrated) {
3516
3531
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3517
3532
  // This works in the client, because the stylesheets are created, and cached in the VM
3518
3533
  // the first time the VM renders.
@@ -3813,7 +3828,7 @@
3813
3828
  updateStaticChildren(c1, c2, parent, renderer);
3814
3829
  }
3815
3830
  }
3816
- function patch(n1, n2, renderer) {
3831
+ function patch(n1, n2, parent, renderer) {
3817
3832
  var _a, _b;
3818
3833
  if (n1 === n2) {
3819
3834
  return;
@@ -3842,7 +3857,7 @@
3842
3857
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3843
3858
  break;
3844
3859
  case 3 /* VNodeType.CustomElement */:
3845
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3860
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3846
3861
  break;
3847
3862
  }
3848
3863
  }
@@ -3969,22 +3984,32 @@
3969
3984
  appendVM(vm);
3970
3985
  }
3971
3986
  }
3972
- function patchCustomElement(n1, n2, renderer) {
3973
- const elm = (n2.elm = n1.elm);
3974
- const vm = (n2.vm = n1.vm);
3975
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3976
- if (!isUndefined$1(vm)) {
3977
- // in fallback mode, the allocation will always set children to
3978
- // empty and delegate the real allocation to the slot elements
3979
- allocateChildren(n2, vm);
3987
+ function patchCustomElement(n1, n2, parent, renderer) {
3988
+ if (n1.ctor !== n2.ctor) {
3989
+ // If the constructor, unmount the current component and mount a new one using the new
3990
+ // constructor.
3991
+ const anchor = renderer.nextSibling(n1.elm);
3992
+ unmount(n1, parent, renderer, true);
3993
+ mountCustomElement(n2, parent, anchor, renderer);
3980
3994
  }
3981
- // in fallback mode, the children will be always empty, so, nothing
3982
- // will happen, but in native, it does allocate the light dom
3983
- patchChildren(n1.children, n2.children, elm, renderer);
3984
- if (!isUndefined$1(vm)) {
3985
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3986
- // this is important to preserve the top to bottom synchronous rendering phase.
3987
- rerenderVM(vm);
3995
+ else {
3996
+ // Otherwise patch the existing component with new props/attrs/etc.
3997
+ const elm = (n2.elm = n1.elm);
3998
+ const vm = (n2.vm = n1.vm);
3999
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
4000
+ if (!isUndefined$1(vm)) {
4001
+ // in fallback mode, the allocation will always set children to
4002
+ // empty and delegate the real allocation to the slot elements
4003
+ allocateChildren(n2, vm);
4004
+ }
4005
+ // in fallback mode, the children will be always empty, so, nothing
4006
+ // will happen, but in native, it does allocate the light dom
4007
+ patchChildren(n1.children, n2.children, elm, renderer);
4008
+ if (!isUndefined$1(vm)) {
4009
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
4010
+ // this is important to preserve the top to bottom synchronous rendering phase.
4011
+ rerenderVM(vm);
4012
+ }
3988
4013
  }
3989
4014
  }
3990
4015
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -4254,25 +4279,25 @@
4254
4279
  newEndVnode = newCh[--newEndIdx];
4255
4280
  }
4256
4281
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
4257
- patch(oldStartVnode, newStartVnode, renderer);
4282
+ patch(oldStartVnode, newStartVnode, parent, renderer);
4258
4283
  oldStartVnode = oldCh[++oldStartIdx];
4259
4284
  newStartVnode = newCh[++newStartIdx];
4260
4285
  }
4261
4286
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
4262
- patch(oldEndVnode, newEndVnode, renderer);
4287
+ patch(oldEndVnode, newEndVnode, parent, renderer);
4263
4288
  oldEndVnode = oldCh[--oldEndIdx];
4264
4289
  newEndVnode = newCh[--newEndIdx];
4265
4290
  }
4266
4291
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
4267
4292
  // Vnode moved right
4268
- patch(oldStartVnode, newEndVnode, renderer);
4293
+ patch(oldStartVnode, newEndVnode, parent, renderer);
4269
4294
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
4270
4295
  oldStartVnode = oldCh[++oldStartIdx];
4271
4296
  newEndVnode = newCh[--newEndIdx];
4272
4297
  }
4273
4298
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
4274
4299
  // Vnode moved left
4275
- patch(oldEndVnode, newStartVnode, renderer);
4300
+ patch(oldEndVnode, newStartVnode, parent, renderer);
4276
4301
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
4277
4302
  oldEndVnode = oldCh[--oldEndIdx];
4278
4303
  newStartVnode = newCh[++newStartIdx];
@@ -4295,7 +4320,7 @@
4295
4320
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
4296
4321
  }
4297
4322
  else {
4298
- patch(elmToMove, newStartVnode, renderer);
4323
+ patch(elmToMove, newStartVnode, parent, renderer);
4299
4324
  // Delete the old child, but copy the array since it is read-only.
4300
4325
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
4301
4326
  // so we only care about the `oldCh` object inside this function.
@@ -4355,7 +4380,7 @@
4355
4380
  if (isVNode(n1)) {
4356
4381
  if (isVNode(n2)) {
4357
4382
  // both vnodes are equivalent, and we just need to patch them
4358
- patch(n1, n2, renderer);
4383
+ patch(n1, n2, parent, renderer);
4359
4384
  anchor = n2.elm;
4360
4385
  }
4361
4386
  else {
@@ -4689,13 +4714,6 @@
4689
4714
  }
4690
4715
  return url;
4691
4716
  }
4692
- /**
4693
- * Map to store an index value assigned to any dynamic component reference ingested
4694
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4695
- * component reference to avoid diffing algo mismatches.
4696
- */
4697
- const DynamicImportedComponentMap = new Map();
4698
- let dynamicImportedComponentCounter = 0;
4699
4717
  /**
4700
4718
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4701
4719
  */
@@ -4712,18 +4730,7 @@
4712
4730
  if (!isComponentConstructor(Ctor)) {
4713
4731
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4714
4732
  }
4715
- let idx = DynamicImportedComponentMap.get(Ctor);
4716
- if (isUndefined$1(idx)) {
4717
- idx = dynamicImportedComponentCounter++;
4718
- DynamicImportedComponentMap.set(Ctor, idx);
4719
- }
4720
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4721
- // to identify different constructors as vnodes with different keys to avoid reusing the
4722
- // element used for previous constructors.
4723
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4724
- // hoisting optimization.
4725
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4726
- return c(sel, Ctor, newData, children);
4733
+ return c(sel, Ctor, data, children);
4727
4734
  }
4728
4735
  /**
4729
4736
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -5199,7 +5206,7 @@
5199
5206
  return signedTemplateMap.get(Ctor);
5200
5207
  }
5201
5208
  function getTemplateReactiveObserver(vm) {
5202
- return new ReactiveObserver(() => {
5209
+ return createReactiveObserver(() => {
5203
5210
  const { isDirty } = vm;
5204
5211
  if (isFalse(isDirty)) {
5205
5212
  markComponentAsDirty(vm);
@@ -5449,7 +5456,7 @@
5449
5456
  return `[object:vm ${def.name} (${vm.idx})]`;
5450
5457
  };
5451
5458
 
5452
- if (runtimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5459
+ if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5453
5460
  vm.shadowMode = 0
5454
5461
  /* ShadowMode.Native */
5455
5462
  ;
@@ -5488,7 +5495,7 @@
5488
5495
  } else if (isNativeShadowDefined) {
5489
5496
  // Not combined with above condition because @lwc/features only supports identifiers in
5490
5497
  // the if-condition.
5491
- if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5498
+ if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5492
5499
  if (def.shadowSupportMode === "any"
5493
5500
  /* ShadowSupportMode.Any */
5494
5501
  ) {
@@ -5617,16 +5624,9 @@
5617
5624
  const {
5618
5625
  def: {
5619
5626
  renderedCallback
5620
- },
5621
- renderer: {
5622
- ssr
5623
5627
  }
5624
5628
  } = vm;
5625
5629
 
5626
- if (isTrue(ssr)) {
5627
- return;
5628
- }
5629
-
5630
5630
  const {
5631
5631
  rendered
5632
5632
  } = Services;
@@ -5876,13 +5876,7 @@
5876
5876
  vm.velements = EmptyArray;
5877
5877
  }
5878
5878
  function scheduleRehydration(vm) {
5879
- const {
5880
- renderer: {
5881
- ssr
5882
- }
5883
- } = vm;
5884
-
5885
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5879
+ if (isTrue(vm.isScheduled)) {
5886
5880
  return;
5887
5881
  }
5888
5882
 
@@ -5989,15 +5983,8 @@
5989
5983
  }
5990
5984
 
5991
5985
  function createFieldDataCallback(vm, name) {
5992
- const {
5993
- cmpFields
5994
- } = vm;
5995
5986
  return value => {
5996
- if (value !== vm.cmpFields[name]) {
5997
- // storing the value in the underlying storage
5998
- cmpFields[name] = value;
5999
- componentValueMutated(vm, name);
6000
- }
5987
+ updateComponentValue(vm, name, value);
6001
5988
  };
6002
5989
  }
6003
5990
 
@@ -6014,7 +6001,7 @@
6014
6001
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
6015
6002
  let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
6016
6003
 
6017
- const ro = new ReactiveObserver(() => {
6004
+ const ro = createReactiveObserver(() => {
6018
6005
  if (hasPendingConfig === false) {
6019
6006
  hasPendingConfig = true; // collect new config in the micro-task
6020
6007
 
@@ -6215,7 +6202,7 @@
6215
6202
  ArrayPush$1.call(wiredConnecting, () => {
6216
6203
  connector.connect();
6217
6204
 
6218
- if (!runtimeFlags.ENABLE_WIRE_SYNC_EMIT) {
6205
+ if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
6219
6206
  if (hasDynamicParams) {
6220
6207
  Promise.resolve().then(computeConfigAndUpdate);
6221
6208
  return;
@@ -6310,7 +6297,7 @@
6310
6297
  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.');
6311
6298
  }
6312
6299
  }
6313
- return reactiveMembrane.getReadOnlyProxy(obj);
6300
+ return getReadOnlyProxy(obj);
6314
6301
  }
6315
6302
 
6316
6303
  /*
@@ -6821,7 +6808,7 @@
6821
6808
  }
6822
6809
  return ctor;
6823
6810
  }
6824
- /* version: 2.21.1 */
6811
+ /* version: 2.23.1 */
6825
6812
 
6826
6813
  /*
6827
6814
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6965,6 +6952,69 @@
6965
6952
  }
6966
6953
  }
6967
6954
 
6955
+ /*
6956
+ * Copyright (c) 2018, salesforce.com, inc.
6957
+ * All rights reserved.
6958
+ * SPDX-License-Identifier: MIT
6959
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6960
+ */
6961
+ const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
6962
+ let createFragment;
6963
+ if (SUPPORTS_TEMPLATE) {
6964
+ // Parse the fragment HTML string into DOM
6965
+ createFragment = function (html) {
6966
+ const template = document.createElement('template');
6967
+ template.innerHTML = html;
6968
+ return template.content.firstChild;
6969
+ };
6970
+ }
6971
+ else {
6972
+ // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
6973
+ // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
6974
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
6975
+ // With other elements added from:
6976
+ // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
6977
+ // Using the test:
6978
+ // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
6979
+ // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
6980
+ const topLevelWrappingMap = {
6981
+ caption: ['table'],
6982
+ col: ['colgroup', 'table'],
6983
+ colgroup: ['table'],
6984
+ option: ['select'],
6985
+ tbody: ['table'],
6986
+ td: ['tr', 'tbody', 'table'],
6987
+ th: ['tr', 'tbody', 'table'],
6988
+ thead: ['table'],
6989
+ tfoot: ['table'],
6990
+ tr: ['tbody', 'table'],
6991
+ };
6992
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
6993
+ const getTagName = function (text) {
6994
+ return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
6995
+ };
6996
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
6997
+ createFragment = function (html) {
6998
+ const wrapperTags = topLevelWrappingMap[getTagName(html)];
6999
+ if (!isUndefined$1(wrapperTags)) {
7000
+ for (const wrapperTag of wrapperTags) {
7001
+ html = `<${wrapperTag}>${html}</${wrapperTag}>`;
7002
+ }
7003
+ }
7004
+ // For IE11, the document title must not be undefined, but it can be an empty string
7005
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
7006
+ const doc = document.implementation.createHTMLDocument('');
7007
+ doc.body.innerHTML = html;
7008
+ let content = doc.body;
7009
+ if (!isUndefined$1(wrapperTags)) {
7010
+ for (let i = 0; i < wrapperTags.length; i++) {
7011
+ content = content.firstChild;
7012
+ }
7013
+ }
7014
+ return content.firstChild;
7015
+ };
7016
+ }
7017
+
6968
7018
  /*
6969
7019
  * Copyright (c) 2018, salesforce.com, inc.
6970
7020
  * All rights reserved.
@@ -7030,22 +7080,11 @@
7030
7080
  };
7031
7081
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7032
7082
  }
7033
- let hydrating = false;
7034
- function setIsHydrating(value) {
7035
- hydrating = value;
7036
- }
7037
- const ssr = false;
7038
- function isHydrating() {
7039
- return hydrating;
7040
- }
7041
7083
  const isNativeShadowDefined = _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED];
7042
7084
  const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN);
7043
7085
  function cloneNode(node, deep) {
7044
7086
  return node.cloneNode(deep);
7045
7087
  }
7046
- function createFragment(html) {
7047
- return document.createRange().createContextualFragment(html).firstChild;
7048
- }
7049
7088
  function createElement$1(tagName, namespace) {
7050
7089
  return isUndefined$1(namespace)
7051
7090
  ? document.createElement(tagName)
@@ -7067,15 +7106,11 @@
7067
7106
  return node.nextSibling;
7068
7107
  }
7069
7108
  function attachShadow(element, options) {
7070
- // `hydrating` will be true in two cases:
7109
+ // `shadowRoot` will be non-null in two cases:
7071
7110
  // 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
7072
7111
  // 2. when a webapp author places <c-app> in their static HTML and mounts their
7073
- // root component with customeElement.define('c-app', Ctor)
7074
- //
7075
- // The second case can be treated as a failed hydration with nominal impact
7076
- // to performance. However, because <c-app> won't have a <template shadowroot>
7077
- // declarative child, `element.shadowRoot` is `null`.
7078
- if (hydrating && element.shadowRoot) {
7112
+ // root component with customElement.define('c-app', Ctor)
7113
+ if (!isNull(element.shadowRoot)) {
7079
7114
  return element.shadowRoot;
7080
7115
  }
7081
7116
  return element.attachShadow(options);
@@ -7171,11 +7206,9 @@
7171
7206
  }
7172
7207
  const HTMLElementExported = HTMLElementConstructor;
7173
7208
  const renderer = {
7174
- ssr,
7175
7209
  isNativeShadowDefined,
7176
7210
  isSyntheticShadowDefined,
7177
7211
  HTMLElementExported,
7178
- isHydrating,
7179
7212
  insert,
7180
7213
  remove,
7181
7214
  cloneNode,
@@ -7261,13 +7294,8 @@
7261
7294
  return;
7262
7295
  }
7263
7296
  try {
7264
- // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
7265
- // and uses the same algo to create the stylesheets as in SSR.
7266
- setIsHydrating(true);
7267
7297
  const vm = createVMWithProps(element, Ctor, props);
7268
7298
  hydrateRoot(vm);
7269
- // set it back since now we finished hydration.
7270
- setIsHydrating(false);
7271
7299
  }
7272
7300
  catch (e) {
7273
7301
  // Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
@@ -7278,13 +7306,8 @@
7278
7306
  resetShadowRootAndLightDom(element, Ctor);
7279
7307
  // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
7280
7308
  createVMWithProps(element, Ctor, props);
7281
- setIsHydrating(false);
7282
7309
  connectRootElement(element);
7283
7310
  }
7284
- finally {
7285
- // in case there's an error during recovery
7286
- setIsHydrating(false);
7287
- }
7288
7311
  }
7289
7312
 
7290
7313
  /*
@@ -7509,7 +7532,7 @@
7509
7532
  });
7510
7533
  freeze(LightningElement);
7511
7534
  seal(LightningElement.prototype);
7512
- /* version: 2.21.1 */
7535
+ /* version: 2.23.1 */
7513
7536
 
7514
7537
  exports.LightningElement = LightningElement;
7515
7538
  exports.__unstable__ProfilerControl = profilerControl;