lwc 2.5.6 → 2.5.10

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 (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +605 -181
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +605 -181
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +406 -169
  5. package/dist/engine-dom/iife/es5/engine-dom.js +684 -242
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +466 -221
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +605 -181
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +406 -169
  11. package/dist/engine-dom/umd/es5/engine-dom.js +684 -242
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +466 -221
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +484 -133
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +485 -133
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +8 -8
@@ -72,7 +72,7 @@ var LWC = (function (exports) {
72
72
  find: ArrayFind,
73
73
  indexOf: ArrayIndexOf,
74
74
  join: ArrayJoin,
75
- map: ArrayMap$1,
75
+ map: ArrayMap,
76
76
  push: ArrayPush$1,
77
77
  reduce: ArrayReduce,
78
78
  reverse: ArrayReverse,
@@ -139,7 +139,7 @@ var LWC = (function (exports) {
139
139
  // Array.prototype.toString directly will cause an error Iterate through
140
140
  // all the items and handle individually.
141
141
  if (isArray$1(obj)) {
142
- return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
142
+ return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
143
143
  }
144
144
 
145
145
  return obj.toString();
@@ -302,7 +302,7 @@ var LWC = (function (exports) {
302
302
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
303
303
  return attributeName;
304
304
  }
305
- /** version: 2.5.6 */
305
+ /** version: 2.5.10 */
306
306
 
307
307
  /*
308
308
  * Copyright (c) 2018, salesforce.com, inc.
@@ -482,7 +482,7 @@ var LWC = (function (exports) {
482
482
  setFeatureFlag(name, value);
483
483
  }
484
484
  }
485
- /** version: 2.5.6 */
485
+ /** version: 2.5.10 */
486
486
 
487
487
  /* proxy-compat-disable */
488
488
 
@@ -534,6 +534,28 @@ var LWC = (function (exports) {
534
534
  }
535
535
 
536
536
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
537
+ } // Borrowed from Vue template compiler.
538
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
539
+
540
+
541
+ const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
542
+ const PROPERTY_DELIMITER = /:(.+)/;
543
+
544
+ function parseStyleText(cssText) {
545
+ const styleMap = {};
546
+ const declarations = cssText.split(DECLARATION_DELIMITER);
547
+
548
+ for (const declaration of declarations) {
549
+ if (declaration) {
550
+ const [prop, value] = declaration.split(PROPERTY_DELIMITER);
551
+
552
+ if (prop !== undefined && value !== undefined) {
553
+ styleMap[prop.trim()] = value.trim();
554
+ }
555
+ }
556
+ }
557
+
558
+ return styleMap;
537
559
  }
538
560
  /*
539
561
  * Copyright (c) 2019, salesforce.com, inc.
@@ -715,8 +737,8 @@ var LWC = (function (exports) {
715
737
  */
716
738
 
717
739
 
718
- function logError(message, vm) {
719
- let msg = `[LWC error]: ${message}`;
740
+ function log(method, message, vm) {
741
+ let msg = `[LWC ${method}]: ${message}`;
720
742
 
721
743
  if (!isUndefined$1(vm)) {
722
744
  msg = `${msg}\n${getComponentStack(vm)}`;
@@ -724,7 +746,7 @@ var LWC = (function (exports) {
724
746
 
725
747
  if (process.env.NODE_ENV === 'test') {
726
748
  /* eslint-disable-next-line no-console */
727
- console.error(msg);
749
+ console[method](msg);
728
750
  return;
729
751
  }
730
752
 
@@ -732,9 +754,17 @@ var LWC = (function (exports) {
732
754
  throw new Error(msg);
733
755
  } catch (e) {
734
756
  /* eslint-disable-next-line no-console */
735
- console.error(e);
757
+ console[method](e);
736
758
  }
737
759
  }
760
+
761
+ function logError(message, vm) {
762
+ log('error', message, vm);
763
+ }
764
+
765
+ function logWarn(message, vm) {
766
+ log('warn', message, vm);
767
+ }
738
768
  /*
739
769
  * Copyright (c) 2018, salesforce.com, inc.
740
770
  * All rights reserved.
@@ -1902,7 +1932,6 @@ var LWC = (function (exports) {
1902
1932
  getPrototypeOf,
1903
1933
  create: ObjectCreate,
1904
1934
  defineProperty: ObjectDefineProperty,
1905
- defineProperties: ObjectDefineProperties,
1906
1935
  isExtensible,
1907
1936
  getOwnPropertyDescriptor,
1908
1937
  getOwnPropertyNames,
@@ -1912,8 +1941,7 @@ var LWC = (function (exports) {
1912
1941
  } = Object;
1913
1942
  const {
1914
1943
  push: ArrayPush,
1915
- concat: ArrayConcat,
1916
- map: ArrayMap
1944
+ concat: ArrayConcat
1917
1945
  } = Array.prototype;
1918
1946
  const OtS = {}.toString;
1919
1947
 
@@ -1978,7 +2006,9 @@ var LWC = (function (exports) {
1978
2006
  // but it will always be compatible with the previous descriptor
1979
2007
  // to preserve the object invariants, which makes these lines safe.
1980
2008
 
1981
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
2009
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
2010
+
2011
+ /* istanbul ignore else */
1982
2012
 
1983
2013
  if (!isUndefined(originalDescriptor)) {
1984
2014
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -2006,11 +2036,17 @@ var LWC = (function (exports) {
2006
2036
 
2007
2037
  preventExtensions(shadowTarget);
2008
2038
  } // Shared Traps
2039
+ // TODO: apply() is never called
2040
+
2041
+ /* istanbul ignore next */
2009
2042
 
2010
2043
 
2011
2044
  apply(shadowTarget, thisArg, argArray) {
2012
2045
  /* No op */
2013
- }
2046
+ } // TODO: construct() is never called
2047
+
2048
+ /* istanbul ignore next */
2049
+
2014
2050
 
2015
2051
  construct(shadowTarget, argArray, newTarget) {
2016
2052
  /* No op */
@@ -2123,8 +2159,8 @@ var LWC = (function (exports) {
2123
2159
 
2124
2160
  }
2125
2161
 
2126
- const getterMap = new WeakMap();
2127
- const setterMap = new WeakMap();
2162
+ const getterMap$1 = new WeakMap();
2163
+ const setterMap$1 = new WeakMap();
2128
2164
  const reverseGetterMap = new WeakMap();
2129
2165
  const reverseSetterMap = new WeakMap();
2130
2166
 
@@ -2134,7 +2170,7 @@ var LWC = (function (exports) {
2134
2170
  }
2135
2171
 
2136
2172
  wrapGetter(originalGet) {
2137
- const wrappedGetter = getterMap.get(originalGet);
2173
+ const wrappedGetter = getterMap$1.get(originalGet);
2138
2174
 
2139
2175
  if (!isUndefined(wrappedGetter)) {
2140
2176
  return wrappedGetter;
@@ -2147,13 +2183,13 @@ var LWC = (function (exports) {
2147
2183
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2148
2184
  };
2149
2185
 
2150
- getterMap.set(originalGet, get);
2186
+ getterMap$1.set(originalGet, get);
2151
2187
  reverseGetterMap.set(get, originalGet);
2152
2188
  return get;
2153
2189
  }
2154
2190
 
2155
2191
  wrapSetter(originalSet) {
2156
- const wrappedSetter = setterMap.get(originalSet);
2192
+ const wrappedSetter = setterMap$1.get(originalSet);
2157
2193
 
2158
2194
  if (!isUndefined(wrappedSetter)) {
2159
2195
  return wrappedSetter;
@@ -2164,7 +2200,7 @@ var LWC = (function (exports) {
2164
2200
  originalSet.call(unwrap$1(this), unwrap$1(v));
2165
2201
  };
2166
2202
 
2167
- setterMap.set(originalSet, set);
2203
+ setterMap$1.set(originalSet, set);
2168
2204
  reverseSetterMap.set(set, originalSet);
2169
2205
  return set;
2170
2206
  }
@@ -2205,7 +2241,7 @@ var LWC = (function (exports) {
2205
2241
  return unwrap$1(redGet.call(handler.wrapValue(this)));
2206
2242
  };
2207
2243
 
2208
- getterMap.set(get, redGet);
2244
+ getterMap$1.set(get, redGet);
2209
2245
  reverseGetterMap.set(redGet, get);
2210
2246
  return get;
2211
2247
  }
@@ -2224,7 +2260,7 @@ var LWC = (function (exports) {
2224
2260
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
2225
2261
  };
2226
2262
 
2227
- setterMap.set(set, redSet);
2263
+ setterMap$1.set(set, redSet);
2228
2264
  reverseSetterMap.set(redSet, set);
2229
2265
  return set;
2230
2266
  }
@@ -2265,6 +2301,7 @@ var LWC = (function (exports) {
2265
2301
  }
2266
2302
 
2267
2303
  setPrototypeOf(shadowTarget, prototype) {
2304
+ /* istanbul ignore else */
2268
2305
  if (process.env.NODE_ENV !== 'production') {
2269
2306
  throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
2270
2307
  }
@@ -2278,6 +2315,11 @@ var LWC = (function (exports) {
2278
2315
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
2279
2316
  // the preventExtension call, in which case we should not attempt to lock down
2280
2317
  // the shadow target.
2318
+ // TODO: It should not actually be possible to reach this `if` statement.
2319
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
2320
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
2321
+
2322
+ /* istanbul ignore if */
2281
2323
 
2282
2324
  if (isExtensible(originalTarget)) {
2283
2325
  return false;
@@ -2319,8 +2361,8 @@ var LWC = (function (exports) {
2319
2361
 
2320
2362
  }
2321
2363
 
2322
- const getterMap$1 = new WeakMap();
2323
- const setterMap$1 = new WeakMap();
2364
+ const getterMap = new WeakMap();
2365
+ const setterMap = new WeakMap();
2324
2366
 
2325
2367
  class ReadOnlyHandler extends BaseProxyHandler {
2326
2368
  wrapValue(value) {
@@ -2328,7 +2370,7 @@ var LWC = (function (exports) {
2328
2370
  }
2329
2371
 
2330
2372
  wrapGetter(originalGet) {
2331
- const wrappedGetter = getterMap$1.get(originalGet);
2373
+ const wrappedGetter = getterMap.get(originalGet);
2332
2374
 
2333
2375
  if (!isUndefined(wrappedGetter)) {
2334
2376
  return wrappedGetter;
@@ -2341,12 +2383,12 @@ var LWC = (function (exports) {
2341
2383
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2342
2384
  };
2343
2385
 
2344
- getterMap$1.set(originalGet, get);
2386
+ getterMap.set(originalGet, get);
2345
2387
  return get;
2346
2388
  }
2347
2389
 
2348
2390
  wrapSetter(originalSet) {
2349
- const wrappedSetter = setterMap$1.get(originalSet);
2391
+ const wrappedSetter = setterMap.get(originalSet);
2350
2392
 
2351
2393
  if (!isUndefined(wrappedSetter)) {
2352
2394
  return wrappedSetter;
@@ -2355,6 +2397,7 @@ var LWC = (function (exports) {
2355
2397
  const handler = this;
2356
2398
 
2357
2399
  const set = function (v) {
2400
+ /* istanbul ignore else */
2358
2401
  if (process.env.NODE_ENV !== 'production') {
2359
2402
  const {
2360
2403
  originalTarget
@@ -2363,33 +2406,41 @@ var LWC = (function (exports) {
2363
2406
  }
2364
2407
  };
2365
2408
 
2366
- setterMap$1.set(originalSet, set);
2409
+ setterMap.set(originalSet, set);
2367
2410
  return set;
2368
2411
  }
2369
2412
 
2370
2413
  set(shadowTarget, key, value) {
2414
+ /* istanbul ignore else */
2371
2415
  if (process.env.NODE_ENV !== 'production') {
2372
2416
  const {
2373
2417
  originalTarget
2374
2418
  } = this;
2375
- throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2419
+ const msg = isArray(originalTarget) ? `Invalid mutation: Cannot mutate array at index ${key.toString()}. Array is read-only.` : `Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`;
2420
+ throw new Error(msg);
2376
2421
  }
2422
+ /* istanbul ignore next */
2423
+
2377
2424
 
2378
2425
  return false;
2379
2426
  }
2380
2427
 
2381
2428
  deleteProperty(shadowTarget, key) {
2429
+ /* istanbul ignore else */
2382
2430
  if (process.env.NODE_ENV !== 'production') {
2383
2431
  const {
2384
2432
  originalTarget
2385
2433
  } = this;
2386
2434
  throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2387
2435
  }
2436
+ /* istanbul ignore next */
2437
+
2388
2438
 
2389
2439
  return false;
2390
2440
  }
2391
2441
 
2392
2442
  setPrototypeOf(shadowTarget, prototype) {
2443
+ /* istanbul ignore else */
2393
2444
  if (process.env.NODE_ENV !== 'production') {
2394
2445
  const {
2395
2446
  originalTarget
@@ -2399,23 +2450,29 @@ var LWC = (function (exports) {
2399
2450
  }
2400
2451
 
2401
2452
  preventExtensions(shadowTarget) {
2453
+ /* istanbul ignore else */
2402
2454
  if (process.env.NODE_ENV !== 'production') {
2403
2455
  const {
2404
2456
  originalTarget
2405
2457
  } = this;
2406
2458
  throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
2407
2459
  }
2460
+ /* istanbul ignore next */
2461
+
2408
2462
 
2409
2463
  return false;
2410
2464
  }
2411
2465
 
2412
2466
  defineProperty(shadowTarget, key, descriptor) {
2467
+ /* istanbul ignore else */
2413
2468
  if (process.env.NODE_ENV !== 'production') {
2414
2469
  const {
2415
2470
  originalTarget
2416
2471
  } = this;
2417
2472
  throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2418
2473
  }
2474
+ /* istanbul ignore next */
2475
+
2419
2476
 
2420
2477
  return false;
2421
2478
  }
@@ -2473,6 +2530,8 @@ var LWC = (function (exports) {
2473
2530
  }; // Inspired from paulmillr/es6-shim
2474
2531
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2475
2532
 
2533
+ /* istanbul ignore next */
2534
+
2476
2535
  function getGlobal() {
2477
2536
  // the only reliable means to get the global object is `Function('return this')()`
2478
2537
  // However, this causes CSP violations in Chrome apps.
@@ -2497,6 +2556,7 @@ var LWC = (function (exports) {
2497
2556
  }
2498
2557
 
2499
2558
  function init() {
2559
+ /* istanbul ignore if */
2500
2560
  if (process.env.NODE_ENV === 'production') {
2501
2561
  // this method should never leak to prod
2502
2562
  throw new ReferenceError();
@@ -2511,6 +2571,8 @@ var LWC = (function (exports) {
2511
2571
  ArrayPush.call(devtoolsFormatters, formatter);
2512
2572
  global.devtoolsFormatters = devtoolsFormatters;
2513
2573
  }
2574
+ /* istanbul ignore else */
2575
+
2514
2576
 
2515
2577
  if (process.env.NODE_ENV !== 'production') {
2516
2578
  init();
@@ -2557,7 +2619,8 @@ var LWC = (function (exports) {
2557
2619
  this.valueMutated = defaultValueMutated;
2558
2620
  this.valueObserved = defaultValueObserved;
2559
2621
  this.valueIsObservable = defaultValueIsObservable;
2560
- this.objectGraph = new WeakMap();
2622
+ this.readOnlyObjectGraph = new WeakMap();
2623
+ this.reactiveObjectGraph = new WeakMap();
2561
2624
 
2562
2625
  if (!isUndefined(options)) {
2563
2626
  const {
@@ -2580,10 +2643,13 @@ var LWC = (function (exports) {
2580
2643
  const distorted = this.valueDistortion(unwrappedValue);
2581
2644
 
2582
2645
  if (this.valueIsObservable(distorted)) {
2583
- const o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2584
- // we return the readonly.
2646
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2647
+ // when trying to extract the writable version of a readonly
2648
+ // we return the readonly.
2649
+ return value;
2650
+ }
2585
2651
 
2586
- return o.readOnly === value ? value : o.reactive;
2652
+ return this.getReactiveHandler(unwrappedValue, distorted);
2587
2653
  }
2588
2654
 
2589
2655
  return distorted;
@@ -2594,7 +2660,7 @@ var LWC = (function (exports) {
2594
2660
  const distorted = this.valueDistortion(value);
2595
2661
 
2596
2662
  if (this.valueIsObservable(distorted)) {
2597
- return this.getReactiveState(value, distorted).readOnly;
2663
+ return this.getReadOnlyHandler(value, distorted);
2598
2664
  }
2599
2665
 
2600
2666
  return distorted;
@@ -2604,47 +2670,36 @@ var LWC = (function (exports) {
2604
2670
  return unwrap$1(p);
2605
2671
  }
2606
2672
 
2607
- getReactiveState(value, distortedValue) {
2608
- const {
2609
- objectGraph
2610
- } = this;
2611
- let reactiveState = objectGraph.get(distortedValue);
2673
+ getReactiveHandler(value, distortedValue) {
2674
+ let proxy = this.reactiveObjectGraph.get(distortedValue);
2612
2675
 
2613
- if (reactiveState) {
2614
- return reactiveState;
2676
+ if (isUndefined(proxy)) {
2677
+ // caching the proxy after the first time it is accessed
2678
+ const handler = new ReactiveProxyHandler(this, distortedValue);
2679
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2680
+ registerProxy(proxy, value);
2681
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2615
2682
  }
2616
2683
 
2617
- const membrane = this;
2618
- reactiveState = {
2619
- get reactive() {
2620
- const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2621
-
2622
- const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2623
- registerProxy(proxy, value);
2624
- ObjectDefineProperty(this, 'reactive', {
2625
- value: proxy
2626
- });
2627
- return proxy;
2628
- },
2684
+ return proxy;
2685
+ }
2629
2686
 
2630
- get readOnly() {
2631
- const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2687
+ getReadOnlyHandler(value, distortedValue) {
2688
+ let proxy = this.readOnlyObjectGraph.get(distortedValue);
2632
2689
 
2633
- const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2634
- registerProxy(proxy, value);
2635
- ObjectDefineProperty(this, 'readOnly', {
2636
- value: proxy
2637
- });
2638
- return proxy;
2639
- }
2690
+ if (isUndefined(proxy)) {
2691
+ // caching the proxy after the first time it is accessed
2692
+ const handler = new ReadOnlyHandler(this, distortedValue);
2693
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2694
+ registerProxy(proxy, value);
2695
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2696
+ }
2640
2697
 
2641
- };
2642
- objectGraph.set(distortedValue, reactiveState);
2643
- return reactiveState;
2698
+ return proxy;
2644
2699
  }
2645
2700
 
2646
2701
  }
2647
- /** version: 1.0.0 */
2702
+ /** version: 1.1.5 */
2648
2703
 
2649
2704
  /*
2650
2705
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3098,8 +3153,10 @@ var LWC = (function (exports) {
3098
3153
  }
3099
3154
 
3100
3155
  return renderer[rendererMethod](elm);
3101
- }
3156
+ },
3102
3157
 
3158
+ configurable: true,
3159
+ enumerable: true
3103
3160
  };
3104
3161
  }
3105
3162
 
@@ -3119,8 +3176,11 @@ var LWC = (function (exports) {
3119
3176
  }
3120
3177
 
3121
3178
  return renderer[queryMethod](elm, arg);
3122
- }
3179
+ },
3123
3180
 
3181
+ configurable: true,
3182
+ enumerable: true,
3183
+ writable: true
3124
3184
  };
3125
3185
  }
3126
3186
 
@@ -4278,7 +4338,7 @@ var LWC = (function (exports) {
4278
4338
  if (!isUndefined$1(ctorShadowSupportMode)) {
4279
4339
  assert.invariant(ctorShadowSupportMode === "any"
4280
4340
  /* Any */
4281
- || ctorShadowSupportMode === "default"
4341
+ || ctorShadowSupportMode === "reset"
4282
4342
  /* Default */
4283
4343
  , `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
4284
4344
  }
@@ -4440,7 +4500,7 @@ var LWC = (function (exports) {
4440
4500
  renderMode: 1
4441
4501
  /* Shadow */
4442
4502
  ,
4443
- shadowSupportMode: "default"
4503
+ shadowSupportMode: "reset"
4444
4504
  /* Default */
4445
4505
  ,
4446
4506
  wire: EmptyObject,
@@ -4589,6 +4649,17 @@ var LWC = (function (exports) {
4589
4649
  modComputedStyle.create(vnode);
4590
4650
  }
4591
4651
 
4652
+ function hydrateElmHook(vnode) {
4653
+ modEvents.create(vnode); // Attrs are already on the element.
4654
+ // modAttrs.create(vnode);
4655
+
4656
+ modProps.create(vnode); // Already set.
4657
+ // modStaticClassName.create(vnode);
4658
+ // modStaticStyle.create(vnode);
4659
+ // modComputedClassName.create(vnode);
4660
+ // modComputedStyle.create(vnode);
4661
+ }
4662
+
4592
4663
  function fallbackElmHook(elm, vnode) {
4593
4664
  const {
4594
4665
  owner
@@ -4760,6 +4831,179 @@ var LWC = (function (exports) {
4760
4831
  }
4761
4832
  }
4762
4833
 
4834
+ function isElementNode(node) {
4835
+ // eslint-disable-next-line lwc-internal/no-global-node
4836
+ return node.nodeType === Node.ELEMENT_NODE;
4837
+ }
4838
+
4839
+ function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4840
+ const {
4841
+ data: {
4842
+ attrs = {}
4843
+ },
4844
+ owner: {
4845
+ renderer
4846
+ }
4847
+ } = vnode;
4848
+ let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
4849
+ // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
4850
+
4851
+ for (const [attrName, attrValue] of Object.entries(attrs)) {
4852
+ const elmAttrValue = renderer.getAttribute(elm, attrName);
4853
+
4854
+ if (String(attrValue) !== elmAttrValue) {
4855
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
4856
+ nodesAreCompatible = false;
4857
+ }
4858
+ }
4859
+
4860
+ return nodesAreCompatible;
4861
+ }
4862
+
4863
+ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4864
+ const {
4865
+ data: {
4866
+ className,
4867
+ classMap
4868
+ },
4869
+ owner: {
4870
+ renderer
4871
+ }
4872
+ } = vnode;
4873
+ let nodesAreCompatible = true;
4874
+ let vnodeClassName;
4875
+
4876
+ if (!isUndefined$1(className) && String(className) !== elm.className) {
4877
+ // className is used when class is bound to an expr.
4878
+ nodesAreCompatible = false;
4879
+ vnodeClassName = className;
4880
+ } else if (!isUndefined$1(classMap)) {
4881
+ // classMap is used when class is set to static value.
4882
+ const classList = renderer.getClassList(elm);
4883
+ let computedClassName = ''; // all classes from the vnode should be in the element.classList
4884
+
4885
+ for (const name in classMap) {
4886
+ computedClassName += ' ' + name;
4887
+
4888
+ if (!classList.contains(name)) {
4889
+ nodesAreCompatible = false;
4890
+ }
4891
+ }
4892
+
4893
+ vnodeClassName = computedClassName.trim();
4894
+
4895
+ if (classList.length > keys(classMap).length) {
4896
+ nodesAreCompatible = false;
4897
+ }
4898
+ }
4899
+
4900
+ if (!nodesAreCompatible) {
4901
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
4902
+ }
4903
+
4904
+ return nodesAreCompatible;
4905
+ }
4906
+
4907
+ function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
4908
+ const {
4909
+ data: {
4910
+ style,
4911
+ styleDecls
4912
+ },
4913
+ owner: {
4914
+ renderer
4915
+ }
4916
+ } = vnode;
4917
+ const elmStyle = renderer.getAttribute(elm, 'style') || '';
4918
+ let vnodeStyle;
4919
+ let nodesAreCompatible = true;
4920
+
4921
+ if (!isUndefined$1(style) && style !== elmStyle) {
4922
+ nodesAreCompatible = false;
4923
+ vnodeStyle = style;
4924
+ } else if (!isUndefined$1(styleDecls)) {
4925
+ const parsedVnodeStyle = parseStyleText(elmStyle);
4926
+ const expectedStyle = []; // styleMap is used when style is set to static value.
4927
+
4928
+ for (let i = 0, n = styleDecls.length; i < n; i++) {
4929
+ const [prop, value, important] = styleDecls[i];
4930
+ expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
4931
+ const parsedPropValue = parsedVnodeStyle[prop];
4932
+
4933
+ if (isUndefined$1(parsedPropValue)) {
4934
+ nodesAreCompatible = false;
4935
+ } else if (!parsedPropValue.startsWith(value)) {
4936
+ nodesAreCompatible = false;
4937
+ } else if (important && !parsedPropValue.endsWith('!important')) {
4938
+ nodesAreCompatible = false;
4939
+ }
4940
+ }
4941
+
4942
+ if (keys(parsedVnodeStyle).length > styleDecls.length) {
4943
+ nodesAreCompatible = false;
4944
+ }
4945
+
4946
+ vnodeStyle = ArrayJoin.call(expectedStyle, ';');
4947
+ }
4948
+
4949
+ if (!nodesAreCompatible) {
4950
+ // style is used when class is bound to an expr.
4951
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
4952
+ }
4953
+
4954
+ return nodesAreCompatible;
4955
+ }
4956
+
4957
+ function throwHydrationError() {
4958
+ assert.fail('Server rendered elements do not match client side generated elements');
4959
+ }
4960
+
4961
+ function hydrateChildrenHook(elmChildren, children, vm) {
4962
+ var _a, _b;
4963
+
4964
+ if (process.env.NODE_ENV !== 'production') {
4965
+ const filteredVNodes = ArrayFilter.call(children, vnode => !!vnode);
4966
+
4967
+ if (elmChildren.length !== filteredVNodes.length) {
4968
+ logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
4969
+ throwHydrationError();
4970
+ }
4971
+ }
4972
+
4973
+ let elmCurrentChildIdx = 0;
4974
+
4975
+ for (let j = 0, n = children.length; j < n; j++) {
4976
+ const ch = children[j];
4977
+
4978
+ if (ch != null) {
4979
+ const childNode = elmChildren[elmCurrentChildIdx];
4980
+
4981
+ if (process.env.NODE_ENV !== 'production') {
4982
+ // VComments and VTexts validation is handled in their hooks
4983
+ if (isElementNode(childNode)) {
4984
+ if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
4985
+ logError(`Hydration mismatch: expecting element with tag "${(_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase()}" but found "${childNode.tagName.toLowerCase()}".`, vm);
4986
+ throwHydrationError();
4987
+ } // Note: props are not yet set
4988
+
4989
+
4990
+ const hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
4991
+ const hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
4992
+ const hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
4993
+ const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
4994
+
4995
+ if (!isVNodeAndElementCompatible) {
4996
+ throwHydrationError();
4997
+ }
4998
+ }
4999
+ }
5000
+
5001
+ ch.hook.hydrate(ch, childNode);
5002
+ elmCurrentChildIdx++;
5003
+ }
5004
+ }
5005
+ }
5006
+
4763
5007
  function updateCustomElmHook(oldVnode, vnode) {
4764
5008
  // Attrs need to be applied to element before props
4765
5009
  // IE11 will wipe out value on radio inputs if value
@@ -4843,38 +5087,6 @@ var LWC = (function (exports) {
4843
5087
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4844
5088
  */
4845
5089
 
4846
- /**
4847
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4848
- * libraries to sanitize HTML content. This hook process the content passed via the template to
4849
- * lwc:inner-html directive.
4850
- * It is meant to be overridden with setSanitizeHtmlContentHook
4851
- */
4852
-
4853
-
4854
- let sanitizeHtmlContentHook = () => {
4855
- // locker-service patches this function during runtime to sanitize HTML content.
4856
- throw new Error('sanitizeHtmlContent hook must be implemented.');
4857
- };
4858
- /**
4859
- * Sets the sanitizeHtmlContentHook.
4860
- *
4861
- * @param newHookImpl
4862
- * @returns oldHookImplementation.
4863
- */
4864
-
4865
-
4866
- function setSanitizeHtmlContentHook(newHookImpl) {
4867
- const currentHook = sanitizeHtmlContentHook;
4868
- sanitizeHtmlContentHook = newHookImpl;
4869
- return currentHook;
4870
- }
4871
- /*
4872
- * Copyright (c) 2018, salesforce.com, inc.
4873
- * All rights reserved.
4874
- * SPDX-License-Identifier: MIT
4875
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4876
- */
4877
-
4878
5090
 
4879
5091
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
4880
5092
  const SymbolIterator = Symbol.iterator;
@@ -4893,7 +5105,26 @@ var LWC = (function (exports) {
4893
5105
  update: updateNodeHook,
4894
5106
  insert: insertNodeHook,
4895
5107
  move: insertNodeHook,
4896
- remove: removeNodeHook
5108
+ remove: removeNodeHook,
5109
+ hydrate: (vNode, node) => {
5110
+ var _a;
5111
+
5112
+ if (process.env.NODE_ENV !== 'production') {
5113
+ // eslint-disable-next-line lwc-internal/no-global-node
5114
+ if (node.nodeType !== Node.TEXT_NODE) {
5115
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5116
+ assert.fail('Hydration mismatch: incorrect node type received.');
5117
+ }
5118
+
5119
+ if (node.nodeValue !== vNode.text) {
5120
+ logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
5121
+ }
5122
+ } // always set the text value to the one from the vnode.
5123
+
5124
+
5125
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5126
+ vNode.elm = node;
5127
+ }
4897
5128
  };
4898
5129
  const CommentHook = {
4899
5130
  create: vnode => {
@@ -4911,7 +5142,26 @@ var LWC = (function (exports) {
4911
5142
  update: updateNodeHook,
4912
5143
  insert: insertNodeHook,
4913
5144
  move: insertNodeHook,
4914
- remove: removeNodeHook
5145
+ remove: removeNodeHook,
5146
+ hydrate: (vNode, node) => {
5147
+ var _a;
5148
+
5149
+ if (process.env.NODE_ENV !== 'production') {
5150
+ // eslint-disable-next-line lwc-internal/no-global-node
5151
+ if (node.nodeType !== Node.COMMENT_NODE) {
5152
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5153
+ assert.fail('Hydration mismatch: incorrect node type received.');
5154
+ }
5155
+
5156
+ if (node.nodeValue !== vNode.text) {
5157
+ logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
5158
+ }
5159
+ } // always set the text value to the one from the vnode.
5160
+
5161
+
5162
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5163
+ vNode.elm = node;
5164
+ }
4915
5165
  }; // insert is called after update, which is used somewhere else (via a module)
4916
5166
  // to mark the vm as inserted, that means we cannot use update as the main channel
4917
5167
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -4951,6 +5201,38 @@ var LWC = (function (exports) {
4951
5201
  remove: (vnode, parentNode) => {
4952
5202
  removeNodeHook(vnode, parentNode);
4953
5203
  removeElmHook(vnode);
5204
+ },
5205
+ hydrate: (vnode, node) => {
5206
+ const elm = node;
5207
+ vnode.elm = elm;
5208
+ const {
5209
+ context
5210
+ } = vnode.data;
5211
+ const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
5212
+ /* manual */
5213
+ );
5214
+
5215
+ if (isDomManual) {
5216
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5217
+ // remove the innerHTML from props so it reuses the existing dom elements.
5218
+ const {
5219
+ props
5220
+ } = vnode.data;
5221
+
5222
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5223
+ if (elm.innerHTML === props.innerHTML) {
5224
+ delete props.innerHTML;
5225
+ } else {
5226
+ logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5227
+ }
5228
+ }
5229
+ }
5230
+
5231
+ hydrateElmHook(vnode);
5232
+
5233
+ if (!isDomManual) {
5234
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
5235
+ }
4954
5236
  }
4955
5237
  };
4956
5238
  const CustomElementHook = {
@@ -5042,6 +5324,44 @@ var LWC = (function (exports) {
5042
5324
  // will take care of disconnecting any child VM attached to its shadow as well.
5043
5325
  removeVM(vm);
5044
5326
  }
5327
+ },
5328
+ hydrate: (vnode, elm) => {
5329
+ // the element is created, but the vm is not
5330
+ const {
5331
+ sel,
5332
+ mode,
5333
+ ctor,
5334
+ owner
5335
+ } = vnode;
5336
+ const def = getComponentInternalDef(ctor);
5337
+ createVM(elm, def, {
5338
+ mode,
5339
+ owner,
5340
+ tagName: sel,
5341
+ renderer: owner.renderer
5342
+ });
5343
+ vnode.elm = elm;
5344
+ const vm = getAssociatedVM(elm);
5345
+ allocateChildrenHook(vnode, vm);
5346
+ hydrateElmHook(vnode); // Insert hook section:
5347
+
5348
+ if (process.env.NODE_ENV !== 'production') {
5349
+ assert.isTrue(vm.state === 0
5350
+ /* created */
5351
+ , `${vm} cannot be recycled.`);
5352
+ }
5353
+
5354
+ runConnectedCallback(vm);
5355
+
5356
+ if (vm.renderMode !== 0
5357
+ /* Light */
5358
+ ) {
5359
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5360
+ // Note: for Light DOM, this is handled while hydrating the VM
5361
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
5362
+ }
5363
+
5364
+ hydrateVM(vm);
5045
5365
  }
5046
5366
  };
5047
5367
 
@@ -5354,7 +5674,7 @@ var LWC = (function (exports) {
5354
5674
 
5355
5675
 
5356
5676
  function d(value) {
5357
- return value == null ? '' : value;
5677
+ return value == null ? '' : String(value);
5358
5678
  } // [b]ind function
5359
5679
 
5360
5680
 
@@ -5516,6 +5836,26 @@ var LWC = (function (exports) {
5516
5836
 
5517
5837
  markAsDynamicChildren(vnodes);
5518
5838
  return vnodes;
5839
+ }
5840
+ /**
5841
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
5842
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
5843
+ * lwc:inner-html directive.
5844
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
5845
+ */
5846
+
5847
+
5848
+ let sanitizeHtmlContentHook = () => {
5849
+ // locker-service patches this function during runtime to sanitize HTML content.
5850
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
5851
+ };
5852
+ /**
5853
+ * Sets the sanitizeHtmlContentHook.
5854
+ */
5855
+
5856
+
5857
+ function setSanitizeHtmlContentHook(newHookImpl) {
5858
+ sanitizeHtmlContentHook = newHookImpl;
5519
5859
  } // [s]anitize [h]tml [c]ontent
5520
5860
 
5521
5861
 
@@ -5710,7 +6050,10 @@ var LWC = (function (exports) {
5710
6050
  for (let i = 0; i < stylesheets.length; i++) {
5711
6051
  renderer.insertGlobalStylesheet(stylesheets[i]);
5712
6052
  }
5713
- } else if (renderer.ssr) {
6053
+ } else if (renderer.ssr || renderer.isHydrating()) {
6054
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
6055
+ // This works in the client, because the stylesheets are created, and cached in the VM
6056
+ // the first time the VM renders.
5714
6057
  // native shadow or light DOM, SSR
5715
6058
  const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
5716
6059
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -6335,6 +6678,12 @@ var LWC = (function (exports) {
6335
6678
  , vm);
6336
6679
  }
6337
6680
 
6681
+ function hydrateRootElement(elm) {
6682
+ const vm = getAssociatedVM(elm);
6683
+ runConnectedCallback(vm);
6684
+ hydrateVM(vm);
6685
+ }
6686
+
6338
6687
  function disconnectRootElement(elm) {
6339
6688
  const vm = getAssociatedVM(elm);
6340
6689
  resetComponentStateWhenRemoved(vm);
@@ -6342,6 +6691,10 @@ var LWC = (function (exports) {
6342
6691
 
6343
6692
  function appendVM(vm) {
6344
6693
  rehydrate(vm);
6694
+ }
6695
+
6696
+ function hydrateVM(vm) {
6697
+ hydrate(vm);
6345
6698
  } // just in case the component comes back, with this we guarantee re-rendering it
6346
6699
  // while preventing any attempt to rehydration until after reinsertion.
6347
6700
 
@@ -6575,6 +6928,22 @@ var LWC = (function (exports) {
6575
6928
  }
6576
6929
  }
6577
6930
 
6931
+ function hydrate(vm) {
6932
+ if (isTrue(vm.isDirty)) {
6933
+ // manually diffing/patching here.
6934
+ // This routine is:
6935
+ // patchShadowRoot(vm, children);
6936
+ // -> addVnodes.
6937
+ const children = renderComponent(vm);
6938
+ vm.children = children;
6939
+ const vmChildren = vm.renderMode === 0
6940
+ /* Light */
6941
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
6942
+ hydrateChildrenHook(vmChildren, children, vm);
6943
+ runRenderedCallback(vm);
6944
+ }
6945
+ }
6946
+
6578
6947
  function patchShadowRoot(vm, newCh) {
6579
6948
  const {
6580
6949
  children: oldCh
@@ -7401,28 +7770,12 @@ var LWC = (function (exports) {
7401
7770
 
7402
7771
  let hooksAreSet = false;
7403
7772
 
7404
- function overrideHooks(hooks) {
7405
- const oldHooks = {};
7406
-
7407
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
7408
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7409
- }
7410
-
7411
- return oldHooks;
7412
- }
7413
-
7414
7773
  function setHooks(hooks) {
7415
7774
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7416
- overrideHooks(hooks);
7417
7775
  hooksAreSet = true;
7776
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7418
7777
  }
7419
-
7420
- function setHooksForTest(hooks) {
7421
- if (process.env.NODE_ENV !== 'production') {
7422
- return overrideHooks(hooks);
7423
- }
7424
- }
7425
- /* version: 2.5.6 */
7778
+ /* version: 2.5.10 */
7426
7779
 
7427
7780
  /*
7428
7781
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7566,8 +7919,19 @@ var LWC = (function (exports) {
7566
7919
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7567
7920
  }
7568
7921
 
7922
+ let isHydrating = false;
7923
+
7924
+ function setIsHydrating(v) {
7925
+ isHydrating = v;
7926
+ }
7927
+
7569
7928
  const renderer = {
7570
7929
  ssr: false,
7930
+
7931
+ isHydrating() {
7932
+ return isHydrating;
7933
+ },
7934
+
7571
7935
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
7572
7936
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
7573
7937
 
@@ -7596,6 +7960,10 @@ var LWC = (function (exports) {
7596
7960
  },
7597
7961
 
7598
7962
  attachShadow(element, options) {
7963
+ if (isHydrating) {
7964
+ return element.shadowRoot;
7965
+ }
7966
+
7599
7967
  return element.attachShadow(options);
7600
7968
  },
7601
7969
 
@@ -7733,61 +8101,6 @@ var LWC = (function (exports) {
7733
8101
  getCustomElement,
7734
8102
  HTMLElement: HTMLElementConstructor
7735
8103
  };
7736
- /*
7737
- * Copyright (c) 2018, salesforce.com, inc.
7738
- * All rights reserved.
7739
- * SPDX-License-Identifier: MIT
7740
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7741
- */
7742
-
7743
- /**
7744
- * This function builds a Web Component class from a LWC constructor so it can be
7745
- * registered as a new element via customElements.define() at any given time.
7746
- *
7747
- * @deprecated since version 1.3.11
7748
- *
7749
- * @example
7750
- * ```
7751
- * import { buildCustomElementConstructor } from 'lwc';
7752
- * import Foo from 'ns/foo';
7753
- * const WC = buildCustomElementConstructor(Foo);
7754
- * customElements.define('x-foo', WC);
7755
- * const elm = document.createElement('x-foo');
7756
- * ```
7757
- */
7758
-
7759
- function deprecatedBuildCustomElementConstructor(Ctor) {
7760
- if (process.env.NODE_ENV !== 'production') {
7761
- /* eslint-disable-next-line no-console */
7762
- console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
7763
- }
7764
-
7765
- return Ctor.CustomElementConstructor;
7766
- }
7767
-
7768
- function buildCustomElementConstructor(Ctor) {
7769
- const def = getComponentInternalDef(Ctor);
7770
- return class extends def.bridge {
7771
- constructor() {
7772
- super();
7773
- createVM(this, def, {
7774
- mode: 'open',
7775
- owner: null,
7776
- tagName: this.tagName,
7777
- renderer
7778
- });
7779
- }
7780
-
7781
- connectedCallback() {
7782
- connectRootElement(this);
7783
- }
7784
-
7785
- disconnectedCallback() {
7786
- disconnectRootElement(this);
7787
- }
7788
-
7789
- };
7790
- }
7791
8104
  /*
7792
8105
  * Copyright (c) 2018, salesforce.com, inc.
7793
8106
  * All rights reserved.
@@ -7797,7 +8110,6 @@ var LWC = (function (exports) {
7797
8110
  // TODO [#2472]: Remove this workaround when appropriate.
7798
8111
  // eslint-disable-next-line lwc-internal/no-global-node
7799
8112
 
7800
-
7801
8113
  const _Node$1 = Node;
7802
8114
  const ConnectingSlot = new WeakMap();
7803
8115
  const DisconnectingSlot = new WeakMap();
@@ -7908,6 +8220,118 @@ var LWC = (function (exports) {
7908
8220
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7909
8221
  */
7910
8222
 
8223
+
8224
+ function hydrateComponent(element, Ctor, props = {}) {
8225
+ if (!isFunction$1(Ctor)) {
8226
+ throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
8227
+ }
8228
+
8229
+ if (!isObject(props) || isNull(props)) {
8230
+ throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
8231
+ }
8232
+
8233
+ const def = getComponentInternalDef(Ctor);
8234
+
8235
+ try {
8236
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8237
+ // and uses the same algo to create the stylesheets as in SSR.
8238
+ setIsHydrating(true);
8239
+ createVM(element, def, {
8240
+ mode: 'open',
8241
+ owner: null,
8242
+ renderer,
8243
+ tagName: element.tagName.toLowerCase()
8244
+ });
8245
+
8246
+ for (const [key, value] of Object.entries(props)) {
8247
+ element[key] = value;
8248
+ }
8249
+
8250
+ hydrateRootElement(element); // set it back since now we finished hydration.
8251
+
8252
+ setIsHydrating(false);
8253
+ } catch (e) {
8254
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
8255
+ // the client generated DOM.
8256
+
8257
+ /* eslint-disable-next-line no-console */
8258
+ console.error('Recovering from error while hydrating: ', e);
8259
+ setIsHydrating(false);
8260
+ const newElem = createElement(element.tagName, {
8261
+ is: Ctor,
8262
+ mode: 'open'
8263
+ });
8264
+
8265
+ for (const [key, value] of Object.entries(props)) {
8266
+ newElem[key] = value;
8267
+ }
8268
+
8269
+ element.parentNode.replaceChild(newElem, element);
8270
+ }
8271
+ }
8272
+ /*
8273
+ * Copyright (c) 2018, salesforce.com, inc.
8274
+ * All rights reserved.
8275
+ * SPDX-License-Identifier: MIT
8276
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8277
+ */
8278
+
8279
+ /**
8280
+ * This function builds a Web Component class from a LWC constructor so it can be
8281
+ * registered as a new element via customElements.define() at any given time.
8282
+ *
8283
+ * @deprecated since version 1.3.11
8284
+ *
8285
+ * @example
8286
+ * ```
8287
+ * import { buildCustomElementConstructor } from 'lwc';
8288
+ * import Foo from 'ns/foo';
8289
+ * const WC = buildCustomElementConstructor(Foo);
8290
+ * customElements.define('x-foo', WC);
8291
+ * const elm = document.createElement('x-foo');
8292
+ * ```
8293
+ */
8294
+
8295
+
8296
+ function deprecatedBuildCustomElementConstructor(Ctor) {
8297
+ if (process.env.NODE_ENV !== 'production') {
8298
+ /* eslint-disable-next-line no-console */
8299
+ console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
8300
+ }
8301
+
8302
+ return Ctor.CustomElementConstructor;
8303
+ }
8304
+
8305
+ function buildCustomElementConstructor(Ctor) {
8306
+ const def = getComponentInternalDef(Ctor);
8307
+ return class extends def.bridge {
8308
+ constructor() {
8309
+ super();
8310
+ createVM(this, def, {
8311
+ mode: 'open',
8312
+ owner: null,
8313
+ tagName: this.tagName,
8314
+ renderer
8315
+ });
8316
+ }
8317
+
8318
+ connectedCallback() {
8319
+ connectRootElement(this);
8320
+ }
8321
+
8322
+ disconnectedCallback() {
8323
+ disconnectRootElement(this);
8324
+ }
8325
+
8326
+ };
8327
+ }
8328
+ /*
8329
+ * Copyright (c) 2018, salesforce.com, inc.
8330
+ * All rights reserved.
8331
+ * SPDX-License-Identifier: MIT
8332
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8333
+ */
8334
+
7911
8335
  /**
7912
8336
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
7913
8337
  * This API is subject to change or being removed.
@@ -8007,7 +8431,7 @@ var LWC = (function (exports) {
8007
8431
  });
8008
8432
  freeze(LightningElement);
8009
8433
  seal(LightningElement.prototype);
8010
- /* version: 2.5.6 */
8434
+ /* version: 2.5.10 */
8011
8435
 
8012
8436
  exports.LightningElement = LightningElement;
8013
8437
  exports.__unstable__ProfilerControl = profilerControl;
@@ -8017,6 +8441,7 @@ var LWC = (function (exports) {
8017
8441
  exports.createElement = createElement;
8018
8442
  exports.getComponentConstructor = getComponentConstructor;
8019
8443
  exports.getComponentDef = getComponentDef;
8444
+ exports.hydrateComponent = hydrateComponent;
8020
8445
  exports.isComponentConstructor = isComponentConstructor;
8021
8446
  exports.isNodeFromTemplate = isNodeFromTemplate;
8022
8447
  exports.readonly = readonly;
@@ -8028,7 +8453,6 @@ var LWC = (function (exports) {
8028
8453
  exports.setFeatureFlag = setFeatureFlag;
8029
8454
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
8030
8455
  exports.setHooks = setHooks;
8031
- exports.setHooksForTest = setHooksForTest;
8032
8456
  exports.swapComponent = swapComponent;
8033
8457
  exports.swapStyle = swapStyle;
8034
8458
  exports.swapTemplate = swapTemplate;