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
@@ -75,7 +75,7 @@
75
75
  find: ArrayFind,
76
76
  indexOf: ArrayIndexOf,
77
77
  join: ArrayJoin,
78
- map: ArrayMap$1,
78
+ map: ArrayMap,
79
79
  push: ArrayPush$1,
80
80
  reduce: ArrayReduce,
81
81
  reverse: ArrayReverse,
@@ -142,7 +142,7 @@
142
142
  // Array.prototype.toString directly will cause an error Iterate through
143
143
  // all the items and handle individually.
144
144
  if (isArray$1(obj)) {
145
- return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
145
+ return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
146
146
  }
147
147
 
148
148
  return obj.toString();
@@ -305,7 +305,7 @@
305
305
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
306
306
  return attributeName;
307
307
  }
308
- /** version: 2.5.6 */
308
+ /** version: 2.5.10 */
309
309
 
310
310
  /*
311
311
  * Copyright (c) 2018, salesforce.com, inc.
@@ -485,7 +485,7 @@
485
485
  setFeatureFlag(name, value);
486
486
  }
487
487
  }
488
- /** version: 2.5.6 */
488
+ /** version: 2.5.10 */
489
489
 
490
490
  /* proxy-compat-disable */
491
491
 
@@ -537,6 +537,28 @@
537
537
  }
538
538
 
539
539
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
540
+ } // Borrowed from Vue template compiler.
541
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
542
+
543
+
544
+ const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
545
+ const PROPERTY_DELIMITER = /:(.+)/;
546
+
547
+ function parseStyleText(cssText) {
548
+ const styleMap = {};
549
+ const declarations = cssText.split(DECLARATION_DELIMITER);
550
+
551
+ for (const declaration of declarations) {
552
+ if (declaration) {
553
+ const [prop, value] = declaration.split(PROPERTY_DELIMITER);
554
+
555
+ if (prop !== undefined && value !== undefined) {
556
+ styleMap[prop.trim()] = value.trim();
557
+ }
558
+ }
559
+ }
560
+
561
+ return styleMap;
540
562
  }
541
563
  /*
542
564
  * Copyright (c) 2019, salesforce.com, inc.
@@ -718,8 +740,8 @@
718
740
  */
719
741
 
720
742
 
721
- function logError(message, vm) {
722
- let msg = `[LWC error]: ${message}`;
743
+ function log(method, message, vm) {
744
+ let msg = `[LWC ${method}]: ${message}`;
723
745
 
724
746
  if (!isUndefined$1(vm)) {
725
747
  msg = `${msg}\n${getComponentStack(vm)}`;
@@ -727,7 +749,7 @@
727
749
 
728
750
  if (process.env.NODE_ENV === 'test') {
729
751
  /* eslint-disable-next-line no-console */
730
- console.error(msg);
752
+ console[method](msg);
731
753
  return;
732
754
  }
733
755
 
@@ -735,9 +757,17 @@
735
757
  throw new Error(msg);
736
758
  } catch (e) {
737
759
  /* eslint-disable-next-line no-console */
738
- console.error(e);
760
+ console[method](e);
739
761
  }
740
762
  }
763
+
764
+ function logError(message, vm) {
765
+ log('error', message, vm);
766
+ }
767
+
768
+ function logWarn(message, vm) {
769
+ log('warn', message, vm);
770
+ }
741
771
  /*
742
772
  * Copyright (c) 2018, salesforce.com, inc.
743
773
  * All rights reserved.
@@ -1905,7 +1935,6 @@
1905
1935
  getPrototypeOf,
1906
1936
  create: ObjectCreate,
1907
1937
  defineProperty: ObjectDefineProperty,
1908
- defineProperties: ObjectDefineProperties,
1909
1938
  isExtensible,
1910
1939
  getOwnPropertyDescriptor,
1911
1940
  getOwnPropertyNames,
@@ -1915,8 +1944,7 @@
1915
1944
  } = Object;
1916
1945
  const {
1917
1946
  push: ArrayPush,
1918
- concat: ArrayConcat,
1919
- map: ArrayMap
1947
+ concat: ArrayConcat
1920
1948
  } = Array.prototype;
1921
1949
  const OtS = {}.toString;
1922
1950
 
@@ -1981,7 +2009,9 @@
1981
2009
  // but it will always be compatible with the previous descriptor
1982
2010
  // to preserve the object invariants, which makes these lines safe.
1983
2011
 
1984
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
2012
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
2013
+
2014
+ /* istanbul ignore else */
1985
2015
 
1986
2016
  if (!isUndefined(originalDescriptor)) {
1987
2017
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -2009,11 +2039,17 @@
2009
2039
 
2010
2040
  preventExtensions(shadowTarget);
2011
2041
  } // Shared Traps
2042
+ // TODO: apply() is never called
2043
+
2044
+ /* istanbul ignore next */
2012
2045
 
2013
2046
 
2014
2047
  apply(shadowTarget, thisArg, argArray) {
2015
2048
  /* No op */
2016
- }
2049
+ } // TODO: construct() is never called
2050
+
2051
+ /* istanbul ignore next */
2052
+
2017
2053
 
2018
2054
  construct(shadowTarget, argArray, newTarget) {
2019
2055
  /* No op */
@@ -2126,8 +2162,8 @@
2126
2162
 
2127
2163
  }
2128
2164
 
2129
- const getterMap = new WeakMap();
2130
- const setterMap = new WeakMap();
2165
+ const getterMap$1 = new WeakMap();
2166
+ const setterMap$1 = new WeakMap();
2131
2167
  const reverseGetterMap = new WeakMap();
2132
2168
  const reverseSetterMap = new WeakMap();
2133
2169
 
@@ -2137,7 +2173,7 @@
2137
2173
  }
2138
2174
 
2139
2175
  wrapGetter(originalGet) {
2140
- const wrappedGetter = getterMap.get(originalGet);
2176
+ const wrappedGetter = getterMap$1.get(originalGet);
2141
2177
 
2142
2178
  if (!isUndefined(wrappedGetter)) {
2143
2179
  return wrappedGetter;
@@ -2150,13 +2186,13 @@
2150
2186
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2151
2187
  };
2152
2188
 
2153
- getterMap.set(originalGet, get);
2189
+ getterMap$1.set(originalGet, get);
2154
2190
  reverseGetterMap.set(get, originalGet);
2155
2191
  return get;
2156
2192
  }
2157
2193
 
2158
2194
  wrapSetter(originalSet) {
2159
- const wrappedSetter = setterMap.get(originalSet);
2195
+ const wrappedSetter = setterMap$1.get(originalSet);
2160
2196
 
2161
2197
  if (!isUndefined(wrappedSetter)) {
2162
2198
  return wrappedSetter;
@@ -2167,7 +2203,7 @@
2167
2203
  originalSet.call(unwrap$1(this), unwrap$1(v));
2168
2204
  };
2169
2205
 
2170
- setterMap.set(originalSet, set);
2206
+ setterMap$1.set(originalSet, set);
2171
2207
  reverseSetterMap.set(set, originalSet);
2172
2208
  return set;
2173
2209
  }
@@ -2208,7 +2244,7 @@
2208
2244
  return unwrap$1(redGet.call(handler.wrapValue(this)));
2209
2245
  };
2210
2246
 
2211
- getterMap.set(get, redGet);
2247
+ getterMap$1.set(get, redGet);
2212
2248
  reverseGetterMap.set(redGet, get);
2213
2249
  return get;
2214
2250
  }
@@ -2227,7 +2263,7 @@
2227
2263
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
2228
2264
  };
2229
2265
 
2230
- setterMap.set(set, redSet);
2266
+ setterMap$1.set(set, redSet);
2231
2267
  reverseSetterMap.set(redSet, set);
2232
2268
  return set;
2233
2269
  }
@@ -2268,6 +2304,7 @@
2268
2304
  }
2269
2305
 
2270
2306
  setPrototypeOf(shadowTarget, prototype) {
2307
+ /* istanbul ignore else */
2271
2308
  if (process.env.NODE_ENV !== 'production') {
2272
2309
  throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
2273
2310
  }
@@ -2281,6 +2318,11 @@
2281
2318
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
2282
2319
  // the preventExtension call, in which case we should not attempt to lock down
2283
2320
  // the shadow target.
2321
+ // TODO: It should not actually be possible to reach this `if` statement.
2322
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
2323
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
2324
+
2325
+ /* istanbul ignore if */
2284
2326
 
2285
2327
  if (isExtensible(originalTarget)) {
2286
2328
  return false;
@@ -2322,8 +2364,8 @@
2322
2364
 
2323
2365
  }
2324
2366
 
2325
- const getterMap$1 = new WeakMap();
2326
- const setterMap$1 = new WeakMap();
2367
+ const getterMap = new WeakMap();
2368
+ const setterMap = new WeakMap();
2327
2369
 
2328
2370
  class ReadOnlyHandler extends BaseProxyHandler {
2329
2371
  wrapValue(value) {
@@ -2331,7 +2373,7 @@
2331
2373
  }
2332
2374
 
2333
2375
  wrapGetter(originalGet) {
2334
- const wrappedGetter = getterMap$1.get(originalGet);
2376
+ const wrappedGetter = getterMap.get(originalGet);
2335
2377
 
2336
2378
  if (!isUndefined(wrappedGetter)) {
2337
2379
  return wrappedGetter;
@@ -2344,12 +2386,12 @@
2344
2386
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2345
2387
  };
2346
2388
 
2347
- getterMap$1.set(originalGet, get);
2389
+ getterMap.set(originalGet, get);
2348
2390
  return get;
2349
2391
  }
2350
2392
 
2351
2393
  wrapSetter(originalSet) {
2352
- const wrappedSetter = setterMap$1.get(originalSet);
2394
+ const wrappedSetter = setterMap.get(originalSet);
2353
2395
 
2354
2396
  if (!isUndefined(wrappedSetter)) {
2355
2397
  return wrappedSetter;
@@ -2358,6 +2400,7 @@
2358
2400
  const handler = this;
2359
2401
 
2360
2402
  const set = function (v) {
2403
+ /* istanbul ignore else */
2361
2404
  if (process.env.NODE_ENV !== 'production') {
2362
2405
  const {
2363
2406
  originalTarget
@@ -2366,33 +2409,41 @@
2366
2409
  }
2367
2410
  };
2368
2411
 
2369
- setterMap$1.set(originalSet, set);
2412
+ setterMap.set(originalSet, set);
2370
2413
  return set;
2371
2414
  }
2372
2415
 
2373
2416
  set(shadowTarget, key, value) {
2417
+ /* istanbul ignore else */
2374
2418
  if (process.env.NODE_ENV !== 'production') {
2375
2419
  const {
2376
2420
  originalTarget
2377
2421
  } = this;
2378
- throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2422
+ 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.`;
2423
+ throw new Error(msg);
2379
2424
  }
2425
+ /* istanbul ignore next */
2426
+
2380
2427
 
2381
2428
  return false;
2382
2429
  }
2383
2430
 
2384
2431
  deleteProperty(shadowTarget, key) {
2432
+ /* istanbul ignore else */
2385
2433
  if (process.env.NODE_ENV !== 'production') {
2386
2434
  const {
2387
2435
  originalTarget
2388
2436
  } = this;
2389
2437
  throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2390
2438
  }
2439
+ /* istanbul ignore next */
2440
+
2391
2441
 
2392
2442
  return false;
2393
2443
  }
2394
2444
 
2395
2445
  setPrototypeOf(shadowTarget, prototype) {
2446
+ /* istanbul ignore else */
2396
2447
  if (process.env.NODE_ENV !== 'production') {
2397
2448
  const {
2398
2449
  originalTarget
@@ -2402,23 +2453,29 @@
2402
2453
  }
2403
2454
 
2404
2455
  preventExtensions(shadowTarget) {
2456
+ /* istanbul ignore else */
2405
2457
  if (process.env.NODE_ENV !== 'production') {
2406
2458
  const {
2407
2459
  originalTarget
2408
2460
  } = this;
2409
2461
  throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
2410
2462
  }
2463
+ /* istanbul ignore next */
2464
+
2411
2465
 
2412
2466
  return false;
2413
2467
  }
2414
2468
 
2415
2469
  defineProperty(shadowTarget, key, descriptor) {
2470
+ /* istanbul ignore else */
2416
2471
  if (process.env.NODE_ENV !== 'production') {
2417
2472
  const {
2418
2473
  originalTarget
2419
2474
  } = this;
2420
2475
  throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2421
2476
  }
2477
+ /* istanbul ignore next */
2478
+
2422
2479
 
2423
2480
  return false;
2424
2481
  }
@@ -2476,6 +2533,8 @@
2476
2533
  }; // Inspired from paulmillr/es6-shim
2477
2534
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2478
2535
 
2536
+ /* istanbul ignore next */
2537
+
2479
2538
  function getGlobal() {
2480
2539
  // the only reliable means to get the global object is `Function('return this')()`
2481
2540
  // However, this causes CSP violations in Chrome apps.
@@ -2500,6 +2559,7 @@
2500
2559
  }
2501
2560
 
2502
2561
  function init() {
2562
+ /* istanbul ignore if */
2503
2563
  if (process.env.NODE_ENV === 'production') {
2504
2564
  // this method should never leak to prod
2505
2565
  throw new ReferenceError();
@@ -2514,6 +2574,8 @@
2514
2574
  ArrayPush.call(devtoolsFormatters, formatter);
2515
2575
  global.devtoolsFormatters = devtoolsFormatters;
2516
2576
  }
2577
+ /* istanbul ignore else */
2578
+
2517
2579
 
2518
2580
  if (process.env.NODE_ENV !== 'production') {
2519
2581
  init();
@@ -2560,7 +2622,8 @@
2560
2622
  this.valueMutated = defaultValueMutated;
2561
2623
  this.valueObserved = defaultValueObserved;
2562
2624
  this.valueIsObservable = defaultValueIsObservable;
2563
- this.objectGraph = new WeakMap();
2625
+ this.readOnlyObjectGraph = new WeakMap();
2626
+ this.reactiveObjectGraph = new WeakMap();
2564
2627
 
2565
2628
  if (!isUndefined(options)) {
2566
2629
  const {
@@ -2583,10 +2646,13 @@
2583
2646
  const distorted = this.valueDistortion(unwrappedValue);
2584
2647
 
2585
2648
  if (this.valueIsObservable(distorted)) {
2586
- const o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2587
- // we return the readonly.
2649
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2650
+ // when trying to extract the writable version of a readonly
2651
+ // we return the readonly.
2652
+ return value;
2653
+ }
2588
2654
 
2589
- return o.readOnly === value ? value : o.reactive;
2655
+ return this.getReactiveHandler(unwrappedValue, distorted);
2590
2656
  }
2591
2657
 
2592
2658
  return distorted;
@@ -2597,7 +2663,7 @@
2597
2663
  const distorted = this.valueDistortion(value);
2598
2664
 
2599
2665
  if (this.valueIsObservable(distorted)) {
2600
- return this.getReactiveState(value, distorted).readOnly;
2666
+ return this.getReadOnlyHandler(value, distorted);
2601
2667
  }
2602
2668
 
2603
2669
  return distorted;
@@ -2607,47 +2673,36 @@
2607
2673
  return unwrap$1(p);
2608
2674
  }
2609
2675
 
2610
- getReactiveState(value, distortedValue) {
2611
- const {
2612
- objectGraph
2613
- } = this;
2614
- let reactiveState = objectGraph.get(distortedValue);
2676
+ getReactiveHandler(value, distortedValue) {
2677
+ let proxy = this.reactiveObjectGraph.get(distortedValue);
2615
2678
 
2616
- if (reactiveState) {
2617
- return reactiveState;
2679
+ if (isUndefined(proxy)) {
2680
+ // caching the proxy after the first time it is accessed
2681
+ const handler = new ReactiveProxyHandler(this, distortedValue);
2682
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2683
+ registerProxy(proxy, value);
2684
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2618
2685
  }
2619
2686
 
2620
- const membrane = this;
2621
- reactiveState = {
2622
- get reactive() {
2623
- const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2624
-
2625
- const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2626
- registerProxy(proxy, value);
2627
- ObjectDefineProperty(this, 'reactive', {
2628
- value: proxy
2629
- });
2630
- return proxy;
2631
- },
2687
+ return proxy;
2688
+ }
2632
2689
 
2633
- get readOnly() {
2634
- const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2690
+ getReadOnlyHandler(value, distortedValue) {
2691
+ let proxy = this.readOnlyObjectGraph.get(distortedValue);
2635
2692
 
2636
- const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2637
- registerProxy(proxy, value);
2638
- ObjectDefineProperty(this, 'readOnly', {
2639
- value: proxy
2640
- });
2641
- return proxy;
2642
- }
2693
+ if (isUndefined(proxy)) {
2694
+ // caching the proxy after the first time it is accessed
2695
+ const handler = new ReadOnlyHandler(this, distortedValue);
2696
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2697
+ registerProxy(proxy, value);
2698
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2699
+ }
2643
2700
 
2644
- };
2645
- objectGraph.set(distortedValue, reactiveState);
2646
- return reactiveState;
2701
+ return proxy;
2647
2702
  }
2648
2703
 
2649
2704
  }
2650
- /** version: 1.0.0 */
2705
+ /** version: 1.1.5 */
2651
2706
 
2652
2707
  /*
2653
2708
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3101,8 +3156,10 @@
3101
3156
  }
3102
3157
 
3103
3158
  return renderer[rendererMethod](elm);
3104
- }
3159
+ },
3105
3160
 
3161
+ configurable: true,
3162
+ enumerable: true
3106
3163
  };
3107
3164
  }
3108
3165
 
@@ -3122,8 +3179,11 @@
3122
3179
  }
3123
3180
 
3124
3181
  return renderer[queryMethod](elm, arg);
3125
- }
3182
+ },
3126
3183
 
3184
+ configurable: true,
3185
+ enumerable: true,
3186
+ writable: true
3127
3187
  };
3128
3188
  }
3129
3189
 
@@ -4281,7 +4341,7 @@
4281
4341
  if (!isUndefined$1(ctorShadowSupportMode)) {
4282
4342
  assert.invariant(ctorShadowSupportMode === "any"
4283
4343
  /* Any */
4284
- || ctorShadowSupportMode === "default"
4344
+ || ctorShadowSupportMode === "reset"
4285
4345
  /* Default */
4286
4346
  , `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
4287
4347
  }
@@ -4443,7 +4503,7 @@
4443
4503
  renderMode: 1
4444
4504
  /* Shadow */
4445
4505
  ,
4446
- shadowSupportMode: "default"
4506
+ shadowSupportMode: "reset"
4447
4507
  /* Default */
4448
4508
  ,
4449
4509
  wire: EmptyObject,
@@ -4592,6 +4652,17 @@
4592
4652
  modComputedStyle.create(vnode);
4593
4653
  }
4594
4654
 
4655
+ function hydrateElmHook(vnode) {
4656
+ modEvents.create(vnode); // Attrs are already on the element.
4657
+ // modAttrs.create(vnode);
4658
+
4659
+ modProps.create(vnode); // Already set.
4660
+ // modStaticClassName.create(vnode);
4661
+ // modStaticStyle.create(vnode);
4662
+ // modComputedClassName.create(vnode);
4663
+ // modComputedStyle.create(vnode);
4664
+ }
4665
+
4595
4666
  function fallbackElmHook(elm, vnode) {
4596
4667
  const {
4597
4668
  owner
@@ -4763,6 +4834,179 @@
4763
4834
  }
4764
4835
  }
4765
4836
 
4837
+ function isElementNode(node) {
4838
+ // eslint-disable-next-line lwc-internal/no-global-node
4839
+ return node.nodeType === Node.ELEMENT_NODE;
4840
+ }
4841
+
4842
+ function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4843
+ const {
4844
+ data: {
4845
+ attrs = {}
4846
+ },
4847
+ owner: {
4848
+ renderer
4849
+ }
4850
+ } = vnode;
4851
+ let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
4852
+ // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
4853
+
4854
+ for (const [attrName, attrValue] of Object.entries(attrs)) {
4855
+ const elmAttrValue = renderer.getAttribute(elm, attrName);
4856
+
4857
+ if (String(attrValue) !== elmAttrValue) {
4858
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
4859
+ nodesAreCompatible = false;
4860
+ }
4861
+ }
4862
+
4863
+ return nodesAreCompatible;
4864
+ }
4865
+
4866
+ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4867
+ const {
4868
+ data: {
4869
+ className,
4870
+ classMap
4871
+ },
4872
+ owner: {
4873
+ renderer
4874
+ }
4875
+ } = vnode;
4876
+ let nodesAreCompatible = true;
4877
+ let vnodeClassName;
4878
+
4879
+ if (!isUndefined$1(className) && String(className) !== elm.className) {
4880
+ // className is used when class is bound to an expr.
4881
+ nodesAreCompatible = false;
4882
+ vnodeClassName = className;
4883
+ } else if (!isUndefined$1(classMap)) {
4884
+ // classMap is used when class is set to static value.
4885
+ const classList = renderer.getClassList(elm);
4886
+ let computedClassName = ''; // all classes from the vnode should be in the element.classList
4887
+
4888
+ for (const name in classMap) {
4889
+ computedClassName += ' ' + name;
4890
+
4891
+ if (!classList.contains(name)) {
4892
+ nodesAreCompatible = false;
4893
+ }
4894
+ }
4895
+
4896
+ vnodeClassName = computedClassName.trim();
4897
+
4898
+ if (classList.length > keys(classMap).length) {
4899
+ nodesAreCompatible = false;
4900
+ }
4901
+ }
4902
+
4903
+ if (!nodesAreCompatible) {
4904
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
4905
+ }
4906
+
4907
+ return nodesAreCompatible;
4908
+ }
4909
+
4910
+ function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
4911
+ const {
4912
+ data: {
4913
+ style,
4914
+ styleDecls
4915
+ },
4916
+ owner: {
4917
+ renderer
4918
+ }
4919
+ } = vnode;
4920
+ const elmStyle = renderer.getAttribute(elm, 'style') || '';
4921
+ let vnodeStyle;
4922
+ let nodesAreCompatible = true;
4923
+
4924
+ if (!isUndefined$1(style) && style !== elmStyle) {
4925
+ nodesAreCompatible = false;
4926
+ vnodeStyle = style;
4927
+ } else if (!isUndefined$1(styleDecls)) {
4928
+ const parsedVnodeStyle = parseStyleText(elmStyle);
4929
+ const expectedStyle = []; // styleMap is used when style is set to static value.
4930
+
4931
+ for (let i = 0, n = styleDecls.length; i < n; i++) {
4932
+ const [prop, value, important] = styleDecls[i];
4933
+ expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
4934
+ const parsedPropValue = parsedVnodeStyle[prop];
4935
+
4936
+ if (isUndefined$1(parsedPropValue)) {
4937
+ nodesAreCompatible = false;
4938
+ } else if (!parsedPropValue.startsWith(value)) {
4939
+ nodesAreCompatible = false;
4940
+ } else if (important && !parsedPropValue.endsWith('!important')) {
4941
+ nodesAreCompatible = false;
4942
+ }
4943
+ }
4944
+
4945
+ if (keys(parsedVnodeStyle).length > styleDecls.length) {
4946
+ nodesAreCompatible = false;
4947
+ }
4948
+
4949
+ vnodeStyle = ArrayJoin.call(expectedStyle, ';');
4950
+ }
4951
+
4952
+ if (!nodesAreCompatible) {
4953
+ // style is used when class is bound to an expr.
4954
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
4955
+ }
4956
+
4957
+ return nodesAreCompatible;
4958
+ }
4959
+
4960
+ function throwHydrationError() {
4961
+ assert.fail('Server rendered elements do not match client side generated elements');
4962
+ }
4963
+
4964
+ function hydrateChildrenHook(elmChildren, children, vm) {
4965
+ var _a, _b;
4966
+
4967
+ if (process.env.NODE_ENV !== 'production') {
4968
+ const filteredVNodes = ArrayFilter.call(children, vnode => !!vnode);
4969
+
4970
+ if (elmChildren.length !== filteredVNodes.length) {
4971
+ logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
4972
+ throwHydrationError();
4973
+ }
4974
+ }
4975
+
4976
+ let elmCurrentChildIdx = 0;
4977
+
4978
+ for (let j = 0, n = children.length; j < n; j++) {
4979
+ const ch = children[j];
4980
+
4981
+ if (ch != null) {
4982
+ const childNode = elmChildren[elmCurrentChildIdx];
4983
+
4984
+ if (process.env.NODE_ENV !== 'production') {
4985
+ // VComments and VTexts validation is handled in their hooks
4986
+ if (isElementNode(childNode)) {
4987
+ if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
4988
+ logError(`Hydration mismatch: expecting element with tag "${(_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase()}" but found "${childNode.tagName.toLowerCase()}".`, vm);
4989
+ throwHydrationError();
4990
+ } // Note: props are not yet set
4991
+
4992
+
4993
+ const hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
4994
+ const hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
4995
+ const hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
4996
+ const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
4997
+
4998
+ if (!isVNodeAndElementCompatible) {
4999
+ throwHydrationError();
5000
+ }
5001
+ }
5002
+ }
5003
+
5004
+ ch.hook.hydrate(ch, childNode);
5005
+ elmCurrentChildIdx++;
5006
+ }
5007
+ }
5008
+ }
5009
+
4766
5010
  function updateCustomElmHook(oldVnode, vnode) {
4767
5011
  // Attrs need to be applied to element before props
4768
5012
  // IE11 will wipe out value on radio inputs if value
@@ -4846,38 +5090,6 @@
4846
5090
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4847
5091
  */
4848
5092
 
4849
- /**
4850
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4851
- * libraries to sanitize HTML content. This hook process the content passed via the template to
4852
- * lwc:inner-html directive.
4853
- * It is meant to be overridden with setSanitizeHtmlContentHook
4854
- */
4855
-
4856
-
4857
- let sanitizeHtmlContentHook = () => {
4858
- // locker-service patches this function during runtime to sanitize HTML content.
4859
- throw new Error('sanitizeHtmlContent hook must be implemented.');
4860
- };
4861
- /**
4862
- * Sets the sanitizeHtmlContentHook.
4863
- *
4864
- * @param newHookImpl
4865
- * @returns oldHookImplementation.
4866
- */
4867
-
4868
-
4869
- function setSanitizeHtmlContentHook(newHookImpl) {
4870
- const currentHook = sanitizeHtmlContentHook;
4871
- sanitizeHtmlContentHook = newHookImpl;
4872
- return currentHook;
4873
- }
4874
- /*
4875
- * Copyright (c) 2018, salesforce.com, inc.
4876
- * All rights reserved.
4877
- * SPDX-License-Identifier: MIT
4878
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4879
- */
4880
-
4881
5093
 
4882
5094
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
4883
5095
  const SymbolIterator = Symbol.iterator;
@@ -4896,7 +5108,26 @@
4896
5108
  update: updateNodeHook,
4897
5109
  insert: insertNodeHook,
4898
5110
  move: insertNodeHook,
4899
- remove: removeNodeHook
5111
+ remove: removeNodeHook,
5112
+ hydrate: (vNode, node) => {
5113
+ var _a;
5114
+
5115
+ if (process.env.NODE_ENV !== 'production') {
5116
+ // eslint-disable-next-line lwc-internal/no-global-node
5117
+ if (node.nodeType !== Node.TEXT_NODE) {
5118
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5119
+ assert.fail('Hydration mismatch: incorrect node type received.');
5120
+ }
5121
+
5122
+ if (node.nodeValue !== vNode.text) {
5123
+ logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
5124
+ }
5125
+ } // always set the text value to the one from the vnode.
5126
+
5127
+
5128
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5129
+ vNode.elm = node;
5130
+ }
4900
5131
  };
4901
5132
  const CommentHook = {
4902
5133
  create: vnode => {
@@ -4914,7 +5145,26 @@
4914
5145
  update: updateNodeHook,
4915
5146
  insert: insertNodeHook,
4916
5147
  move: insertNodeHook,
4917
- remove: removeNodeHook
5148
+ remove: removeNodeHook,
5149
+ hydrate: (vNode, node) => {
5150
+ var _a;
5151
+
5152
+ if (process.env.NODE_ENV !== 'production') {
5153
+ // eslint-disable-next-line lwc-internal/no-global-node
5154
+ if (node.nodeType !== Node.COMMENT_NODE) {
5155
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5156
+ assert.fail('Hydration mismatch: incorrect node type received.');
5157
+ }
5158
+
5159
+ if (node.nodeValue !== vNode.text) {
5160
+ logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
5161
+ }
5162
+ } // always set the text value to the one from the vnode.
5163
+
5164
+
5165
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5166
+ vNode.elm = node;
5167
+ }
4918
5168
  }; // insert is called after update, which is used somewhere else (via a module)
4919
5169
  // to mark the vm as inserted, that means we cannot use update as the main channel
4920
5170
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -4954,6 +5204,38 @@
4954
5204
  remove: (vnode, parentNode) => {
4955
5205
  removeNodeHook(vnode, parentNode);
4956
5206
  removeElmHook(vnode);
5207
+ },
5208
+ hydrate: (vnode, node) => {
5209
+ const elm = node;
5210
+ vnode.elm = elm;
5211
+ const {
5212
+ context
5213
+ } = vnode.data;
5214
+ const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
5215
+ /* manual */
5216
+ );
5217
+
5218
+ if (isDomManual) {
5219
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5220
+ // remove the innerHTML from props so it reuses the existing dom elements.
5221
+ const {
5222
+ props
5223
+ } = vnode.data;
5224
+
5225
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5226
+ if (elm.innerHTML === props.innerHTML) {
5227
+ delete props.innerHTML;
5228
+ } else {
5229
+ logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5230
+ }
5231
+ }
5232
+ }
5233
+
5234
+ hydrateElmHook(vnode);
5235
+
5236
+ if (!isDomManual) {
5237
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
5238
+ }
4957
5239
  }
4958
5240
  };
4959
5241
  const CustomElementHook = {
@@ -5045,6 +5327,44 @@
5045
5327
  // will take care of disconnecting any child VM attached to its shadow as well.
5046
5328
  removeVM(vm);
5047
5329
  }
5330
+ },
5331
+ hydrate: (vnode, elm) => {
5332
+ // the element is created, but the vm is not
5333
+ const {
5334
+ sel,
5335
+ mode,
5336
+ ctor,
5337
+ owner
5338
+ } = vnode;
5339
+ const def = getComponentInternalDef(ctor);
5340
+ createVM(elm, def, {
5341
+ mode,
5342
+ owner,
5343
+ tagName: sel,
5344
+ renderer: owner.renderer
5345
+ });
5346
+ vnode.elm = elm;
5347
+ const vm = getAssociatedVM(elm);
5348
+ allocateChildrenHook(vnode, vm);
5349
+ hydrateElmHook(vnode); // Insert hook section:
5350
+
5351
+ if (process.env.NODE_ENV !== 'production') {
5352
+ assert.isTrue(vm.state === 0
5353
+ /* created */
5354
+ , `${vm} cannot be recycled.`);
5355
+ }
5356
+
5357
+ runConnectedCallback(vm);
5358
+
5359
+ if (vm.renderMode !== 0
5360
+ /* Light */
5361
+ ) {
5362
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5363
+ // Note: for Light DOM, this is handled while hydrating the VM
5364
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
5365
+ }
5366
+
5367
+ hydrateVM(vm);
5048
5368
  }
5049
5369
  };
5050
5370
 
@@ -5357,7 +5677,7 @@
5357
5677
 
5358
5678
 
5359
5679
  function d(value) {
5360
- return value == null ? '' : value;
5680
+ return value == null ? '' : String(value);
5361
5681
  } // [b]ind function
5362
5682
 
5363
5683
 
@@ -5519,6 +5839,26 @@
5519
5839
 
5520
5840
  markAsDynamicChildren(vnodes);
5521
5841
  return vnodes;
5842
+ }
5843
+ /**
5844
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
5845
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
5846
+ * lwc:inner-html directive.
5847
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
5848
+ */
5849
+
5850
+
5851
+ let sanitizeHtmlContentHook = () => {
5852
+ // locker-service patches this function during runtime to sanitize HTML content.
5853
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
5854
+ };
5855
+ /**
5856
+ * Sets the sanitizeHtmlContentHook.
5857
+ */
5858
+
5859
+
5860
+ function setSanitizeHtmlContentHook(newHookImpl) {
5861
+ sanitizeHtmlContentHook = newHookImpl;
5522
5862
  } // [s]anitize [h]tml [c]ontent
5523
5863
 
5524
5864
 
@@ -5713,7 +6053,10 @@
5713
6053
  for (let i = 0; i < stylesheets.length; i++) {
5714
6054
  renderer.insertGlobalStylesheet(stylesheets[i]);
5715
6055
  }
5716
- } else if (renderer.ssr) {
6056
+ } else if (renderer.ssr || renderer.isHydrating()) {
6057
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
6058
+ // This works in the client, because the stylesheets are created, and cached in the VM
6059
+ // the first time the VM renders.
5717
6060
  // native shadow or light DOM, SSR
5718
6061
  const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
5719
6062
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -6338,6 +6681,12 @@
6338
6681
  , vm);
6339
6682
  }
6340
6683
 
6684
+ function hydrateRootElement(elm) {
6685
+ const vm = getAssociatedVM(elm);
6686
+ runConnectedCallback(vm);
6687
+ hydrateVM(vm);
6688
+ }
6689
+
6341
6690
  function disconnectRootElement(elm) {
6342
6691
  const vm = getAssociatedVM(elm);
6343
6692
  resetComponentStateWhenRemoved(vm);
@@ -6345,6 +6694,10 @@
6345
6694
 
6346
6695
  function appendVM(vm) {
6347
6696
  rehydrate(vm);
6697
+ }
6698
+
6699
+ function hydrateVM(vm) {
6700
+ hydrate(vm);
6348
6701
  } // just in case the component comes back, with this we guarantee re-rendering it
6349
6702
  // while preventing any attempt to rehydration until after reinsertion.
6350
6703
 
@@ -6578,6 +6931,22 @@
6578
6931
  }
6579
6932
  }
6580
6933
 
6934
+ function hydrate(vm) {
6935
+ if (isTrue(vm.isDirty)) {
6936
+ // manually diffing/patching here.
6937
+ // This routine is:
6938
+ // patchShadowRoot(vm, children);
6939
+ // -> addVnodes.
6940
+ const children = renderComponent(vm);
6941
+ vm.children = children;
6942
+ const vmChildren = vm.renderMode === 0
6943
+ /* Light */
6944
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
6945
+ hydrateChildrenHook(vmChildren, children, vm);
6946
+ runRenderedCallback(vm);
6947
+ }
6948
+ }
6949
+
6581
6950
  function patchShadowRoot(vm, newCh) {
6582
6951
  const {
6583
6952
  children: oldCh
@@ -7404,28 +7773,12 @@
7404
7773
 
7405
7774
  let hooksAreSet = false;
7406
7775
 
7407
- function overrideHooks(hooks) {
7408
- const oldHooks = {};
7409
-
7410
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
7411
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7412
- }
7413
-
7414
- return oldHooks;
7415
- }
7416
-
7417
7776
  function setHooks(hooks) {
7418
7777
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7419
- overrideHooks(hooks);
7420
7778
  hooksAreSet = true;
7779
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7421
7780
  }
7422
-
7423
- function setHooksForTest(hooks) {
7424
- if (process.env.NODE_ENV !== 'production') {
7425
- return overrideHooks(hooks);
7426
- }
7427
- }
7428
- /* version: 2.5.6 */
7781
+ /* version: 2.5.10 */
7429
7782
 
7430
7783
  /*
7431
7784
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7569,8 +7922,19 @@
7569
7922
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7570
7923
  }
7571
7924
 
7925
+ let isHydrating = false;
7926
+
7927
+ function setIsHydrating(v) {
7928
+ isHydrating = v;
7929
+ }
7930
+
7572
7931
  const renderer = {
7573
7932
  ssr: false,
7933
+
7934
+ isHydrating() {
7935
+ return isHydrating;
7936
+ },
7937
+
7574
7938
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
7575
7939
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
7576
7940
 
@@ -7599,6 +7963,10 @@
7599
7963
  },
7600
7964
 
7601
7965
  attachShadow(element, options) {
7966
+ if (isHydrating) {
7967
+ return element.shadowRoot;
7968
+ }
7969
+
7602
7970
  return element.attachShadow(options);
7603
7971
  },
7604
7972
 
@@ -7736,61 +8104,6 @@
7736
8104
  getCustomElement,
7737
8105
  HTMLElement: HTMLElementConstructor
7738
8106
  };
7739
- /*
7740
- * Copyright (c) 2018, salesforce.com, inc.
7741
- * All rights reserved.
7742
- * SPDX-License-Identifier: MIT
7743
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7744
- */
7745
-
7746
- /**
7747
- * This function builds a Web Component class from a LWC constructor so it can be
7748
- * registered as a new element via customElements.define() at any given time.
7749
- *
7750
- * @deprecated since version 1.3.11
7751
- *
7752
- * @example
7753
- * ```
7754
- * import { buildCustomElementConstructor } from 'lwc';
7755
- * import Foo from 'ns/foo';
7756
- * const WC = buildCustomElementConstructor(Foo);
7757
- * customElements.define('x-foo', WC);
7758
- * const elm = document.createElement('x-foo');
7759
- * ```
7760
- */
7761
-
7762
- function deprecatedBuildCustomElementConstructor(Ctor) {
7763
- if (process.env.NODE_ENV !== 'production') {
7764
- /* eslint-disable-next-line no-console */
7765
- 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.`);
7766
- }
7767
-
7768
- return Ctor.CustomElementConstructor;
7769
- }
7770
-
7771
- function buildCustomElementConstructor(Ctor) {
7772
- const def = getComponentInternalDef(Ctor);
7773
- return class extends def.bridge {
7774
- constructor() {
7775
- super();
7776
- createVM(this, def, {
7777
- mode: 'open',
7778
- owner: null,
7779
- tagName: this.tagName,
7780
- renderer
7781
- });
7782
- }
7783
-
7784
- connectedCallback() {
7785
- connectRootElement(this);
7786
- }
7787
-
7788
- disconnectedCallback() {
7789
- disconnectRootElement(this);
7790
- }
7791
-
7792
- };
7793
- }
7794
8107
  /*
7795
8108
  * Copyright (c) 2018, salesforce.com, inc.
7796
8109
  * All rights reserved.
@@ -7800,7 +8113,6 @@
7800
8113
  // TODO [#2472]: Remove this workaround when appropriate.
7801
8114
  // eslint-disable-next-line lwc-internal/no-global-node
7802
8115
 
7803
-
7804
8116
  const _Node$1 = Node;
7805
8117
  const ConnectingSlot = new WeakMap();
7806
8118
  const DisconnectingSlot = new WeakMap();
@@ -7911,6 +8223,118 @@
7911
8223
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7912
8224
  */
7913
8225
 
8226
+
8227
+ function hydrateComponent(element, Ctor, props = {}) {
8228
+ if (!isFunction$1(Ctor)) {
8229
+ throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
8230
+ }
8231
+
8232
+ if (!isObject(props) || isNull(props)) {
8233
+ throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
8234
+ }
8235
+
8236
+ const def = getComponentInternalDef(Ctor);
8237
+
8238
+ try {
8239
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8240
+ // and uses the same algo to create the stylesheets as in SSR.
8241
+ setIsHydrating(true);
8242
+ createVM(element, def, {
8243
+ mode: 'open',
8244
+ owner: null,
8245
+ renderer,
8246
+ tagName: element.tagName.toLowerCase()
8247
+ });
8248
+
8249
+ for (const [key, value] of Object.entries(props)) {
8250
+ element[key] = value;
8251
+ }
8252
+
8253
+ hydrateRootElement(element); // set it back since now we finished hydration.
8254
+
8255
+ setIsHydrating(false);
8256
+ } catch (e) {
8257
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
8258
+ // the client generated DOM.
8259
+
8260
+ /* eslint-disable-next-line no-console */
8261
+ console.error('Recovering from error while hydrating: ', e);
8262
+ setIsHydrating(false);
8263
+ const newElem = createElement(element.tagName, {
8264
+ is: Ctor,
8265
+ mode: 'open'
8266
+ });
8267
+
8268
+ for (const [key, value] of Object.entries(props)) {
8269
+ newElem[key] = value;
8270
+ }
8271
+
8272
+ element.parentNode.replaceChild(newElem, element);
8273
+ }
8274
+ }
8275
+ /*
8276
+ * Copyright (c) 2018, salesforce.com, inc.
8277
+ * All rights reserved.
8278
+ * SPDX-License-Identifier: MIT
8279
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8280
+ */
8281
+
8282
+ /**
8283
+ * This function builds a Web Component class from a LWC constructor so it can be
8284
+ * registered as a new element via customElements.define() at any given time.
8285
+ *
8286
+ * @deprecated since version 1.3.11
8287
+ *
8288
+ * @example
8289
+ * ```
8290
+ * import { buildCustomElementConstructor } from 'lwc';
8291
+ * import Foo from 'ns/foo';
8292
+ * const WC = buildCustomElementConstructor(Foo);
8293
+ * customElements.define('x-foo', WC);
8294
+ * const elm = document.createElement('x-foo');
8295
+ * ```
8296
+ */
8297
+
8298
+
8299
+ function deprecatedBuildCustomElementConstructor(Ctor) {
8300
+ if (process.env.NODE_ENV !== 'production') {
8301
+ /* eslint-disable-next-line no-console */
8302
+ 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.`);
8303
+ }
8304
+
8305
+ return Ctor.CustomElementConstructor;
8306
+ }
8307
+
8308
+ function buildCustomElementConstructor(Ctor) {
8309
+ const def = getComponentInternalDef(Ctor);
8310
+ return class extends def.bridge {
8311
+ constructor() {
8312
+ super();
8313
+ createVM(this, def, {
8314
+ mode: 'open',
8315
+ owner: null,
8316
+ tagName: this.tagName,
8317
+ renderer
8318
+ });
8319
+ }
8320
+
8321
+ connectedCallback() {
8322
+ connectRootElement(this);
8323
+ }
8324
+
8325
+ disconnectedCallback() {
8326
+ disconnectRootElement(this);
8327
+ }
8328
+
8329
+ };
8330
+ }
8331
+ /*
8332
+ * Copyright (c) 2018, salesforce.com, inc.
8333
+ * All rights reserved.
8334
+ * SPDX-License-Identifier: MIT
8335
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8336
+ */
8337
+
7914
8338
  /**
7915
8339
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
7916
8340
  * This API is subject to change or being removed.
@@ -8010,7 +8434,7 @@
8010
8434
  });
8011
8435
  freeze(LightningElement);
8012
8436
  seal(LightningElement.prototype);
8013
- /* version: 2.5.6 */
8437
+ /* version: 2.5.10 */
8014
8438
 
8015
8439
  exports.LightningElement = LightningElement;
8016
8440
  exports.__unstable__ProfilerControl = profilerControl;
@@ -8020,6 +8444,7 @@
8020
8444
  exports.createElement = createElement;
8021
8445
  exports.getComponentConstructor = getComponentConstructor;
8022
8446
  exports.getComponentDef = getComponentDef;
8447
+ exports.hydrateComponent = hydrateComponent;
8023
8448
  exports.isComponentConstructor = isComponentConstructor;
8024
8449
  exports.isNodeFromTemplate = isNodeFromTemplate;
8025
8450
  exports.readonly = readonly;
@@ -8031,7 +8456,6 @@
8031
8456
  exports.setFeatureFlag = setFeatureFlag;
8032
8457
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
8033
8458
  exports.setHooks = setHooks;
8034
- exports.setHooksForTest = setHooksForTest;
8035
8459
  exports.swapComponent = swapComponent;
8036
8460
  exports.swapStyle = swapStyle;
8037
8461
  exports.swapTemplate = swapTemplate;