lwc 2.5.5-canary1 → 2.5.9

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 (41) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +672 -214
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +673 -215
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +473 -202
  5. package/dist/engine-dom/iife/es5/engine-dom.js +741 -265
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +522 -243
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +674 -216
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +474 -203
  11. package/dist/engine-dom/umd/es5/engine-dom.js +742 -266
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +523 -244
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +551 -166
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +552 -166
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +9 -39
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +10 -40
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +10 -40
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +10 -40
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +10 -40
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +11 -41
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +11 -41
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +11 -41
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +11 -41
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +3 -3
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +3 -3
  33. package/dist/wire-service/iife/es5/wire-service.js +3 -3
  34. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  35. package/dist/wire-service/iife/es5/wire-service_debug.js +3 -3
  36. package/dist/wire-service/umd/es2017/wire-service.js +4 -4
  37. package/dist/wire-service/umd/es2017/wire-service_debug.js +4 -4
  38. package/dist/wire-service/umd/es5/wire-service.js +4 -4
  39. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  40. package/dist/wire-service/umd/es5/wire-service_debug.js +4 -4
  41. package/package.json +8 -8
@@ -73,7 +73,7 @@ const {
73
73
  find: ArrayFind,
74
74
  indexOf: ArrayIndexOf,
75
75
  join: ArrayJoin,
76
- map: ArrayMap$1,
76
+ map: ArrayMap,
77
77
  push: ArrayPush$1,
78
78
  reduce: ArrayReduce,
79
79
  reverse: ArrayReverse,
@@ -140,7 +140,7 @@ function toString$1(obj) {
140
140
  // Array.prototype.toString directly will cause an error Iterate through
141
141
  // all the items and handle individually.
142
142
  if (isArray$1(obj)) {
143
- return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
143
+ return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
144
144
  }
145
145
 
146
146
  return obj.toString();
@@ -339,7 +339,7 @@ function htmlPropertyToAttribute(propName) {
339
339
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
340
340
  return attributeName;
341
341
  }
342
- /** version: 2.5.5-canary1 */
342
+ /** version: 2.5.9 */
343
343
 
344
344
  /*
345
345
  * Copyright (c) 2020, salesforce.com, inc.
@@ -460,7 +460,7 @@ function setFeatureFlagForTest(name, value) {
460
460
  setFeatureFlag(name, value);
461
461
  }
462
462
  }
463
- /** version: 2.5.5-canary1 */
463
+ /** version: 2.5.9 */
464
464
 
465
465
  /* proxy-compat-disable */
466
466
 
@@ -512,6 +512,28 @@ function guid() {
512
512
  }
513
513
 
514
514
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
515
+ } // Borrowed from Vue template compiler.
516
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
517
+
518
+
519
+ const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
520
+ const PROPERTY_DELIMITER = /:(.+)/;
521
+
522
+ function parseStyleText(cssText) {
523
+ const styleMap = {};
524
+ const declarations = cssText.split(DECLARATION_DELIMITER);
525
+
526
+ for (const declaration of declarations) {
527
+ if (declaration) {
528
+ const [prop, value] = declaration.split(PROPERTY_DELIMITER);
529
+
530
+ if (prop !== undefined && value !== undefined) {
531
+ styleMap[prop.trim()] = value.trim();
532
+ }
533
+ }
534
+ }
535
+
536
+ return styleMap;
515
537
  }
516
538
  /*
517
539
  * Copyright (c) 2019, salesforce.com, inc.
@@ -693,8 +715,8 @@ function getErrorComponentStack(vm) {
693
715
  */
694
716
 
695
717
 
696
- function logError(message, vm) {
697
- let msg = `[LWC error]: ${message}`;
718
+ function log(method, message, vm) {
719
+ let msg = `[LWC ${method}]: ${message}`;
698
720
 
699
721
  if (!isUndefined$1(vm)) {
700
722
  msg = `${msg}\n${getComponentStack(vm)}`;
@@ -702,7 +724,7 @@ function logError(message, vm) {
702
724
 
703
725
  if (process.env.NODE_ENV === 'test') {
704
726
  /* eslint-disable-next-line no-console */
705
- console.error(msg);
727
+ console[method](msg);
706
728
  return;
707
729
  }
708
730
 
@@ -710,9 +732,17 @@ function logError(message, vm) {
710
732
  throw new Error(msg);
711
733
  } catch (e) {
712
734
  /* eslint-disable-next-line no-console */
713
- console.error(e);
735
+ console[method](e);
714
736
  }
715
737
  }
738
+
739
+ function logError(message, vm) {
740
+ log('error', message, vm);
741
+ }
742
+
743
+ function logWarn(message, vm) {
744
+ log('warn', message, vm);
745
+ }
716
746
  /*
717
747
  * Copyright (c) 2018, salesforce.com, inc.
718
748
  * All rights reserved.
@@ -1880,7 +1910,6 @@ const {
1880
1910
  getPrototypeOf,
1881
1911
  create: ObjectCreate,
1882
1912
  defineProperty: ObjectDefineProperty,
1883
- defineProperties: ObjectDefineProperties,
1884
1913
  isExtensible,
1885
1914
  getOwnPropertyDescriptor,
1886
1915
  getOwnPropertyNames,
@@ -1890,8 +1919,7 @@ const {
1890
1919
  } = Object;
1891
1920
  const {
1892
1921
  push: ArrayPush,
1893
- concat: ArrayConcat,
1894
- map: ArrayMap
1922
+ concat: ArrayConcat
1895
1923
  } = Array.prototype;
1896
1924
  const OtS = {}.toString;
1897
1925
 
@@ -1956,7 +1984,9 @@ class BaseProxyHandler {
1956
1984
  // but it will always be compatible with the previous descriptor
1957
1985
  // to preserve the object invariants, which makes these lines safe.
1958
1986
 
1959
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
1987
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1988
+
1989
+ /* istanbul ignore else */
1960
1990
 
1961
1991
  if (!isUndefined(originalDescriptor)) {
1962
1992
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1984,11 +2014,17 @@ class BaseProxyHandler {
1984
2014
 
1985
2015
  preventExtensions(shadowTarget);
1986
2016
  } // Shared Traps
2017
+ // TODO: apply() is never called
2018
+
2019
+ /* istanbul ignore next */
1987
2020
 
1988
2021
 
1989
2022
  apply(shadowTarget, thisArg, argArray) {
1990
2023
  /* No op */
1991
- }
2024
+ } // TODO: construct() is never called
2025
+
2026
+ /* istanbul ignore next */
2027
+
1992
2028
 
1993
2029
  construct(shadowTarget, argArray, newTarget) {
1994
2030
  /* No op */
@@ -2101,8 +2137,8 @@ class BaseProxyHandler {
2101
2137
 
2102
2138
  }
2103
2139
 
2104
- const getterMap = new WeakMap();
2105
- const setterMap = new WeakMap();
2140
+ const getterMap$1 = new WeakMap();
2141
+ const setterMap$1 = new WeakMap();
2106
2142
  const reverseGetterMap = new WeakMap();
2107
2143
  const reverseSetterMap = new WeakMap();
2108
2144
 
@@ -2112,7 +2148,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2112
2148
  }
2113
2149
 
2114
2150
  wrapGetter(originalGet) {
2115
- const wrappedGetter = getterMap.get(originalGet);
2151
+ const wrappedGetter = getterMap$1.get(originalGet);
2116
2152
 
2117
2153
  if (!isUndefined(wrappedGetter)) {
2118
2154
  return wrappedGetter;
@@ -2125,13 +2161,13 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2125
2161
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2126
2162
  };
2127
2163
 
2128
- getterMap.set(originalGet, get);
2164
+ getterMap$1.set(originalGet, get);
2129
2165
  reverseGetterMap.set(get, originalGet);
2130
2166
  return get;
2131
2167
  }
2132
2168
 
2133
2169
  wrapSetter(originalSet) {
2134
- const wrappedSetter = setterMap.get(originalSet);
2170
+ const wrappedSetter = setterMap$1.get(originalSet);
2135
2171
 
2136
2172
  if (!isUndefined(wrappedSetter)) {
2137
2173
  return wrappedSetter;
@@ -2142,7 +2178,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2142
2178
  originalSet.call(unwrap$1(this), unwrap$1(v));
2143
2179
  };
2144
2180
 
2145
- setterMap.set(originalSet, set);
2181
+ setterMap$1.set(originalSet, set);
2146
2182
  reverseSetterMap.set(set, originalSet);
2147
2183
  return set;
2148
2184
  }
@@ -2183,7 +2219,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2183
2219
  return unwrap$1(redGet.call(handler.wrapValue(this)));
2184
2220
  };
2185
2221
 
2186
- getterMap.set(get, redGet);
2222
+ getterMap$1.set(get, redGet);
2187
2223
  reverseGetterMap.set(redGet, get);
2188
2224
  return get;
2189
2225
  }
@@ -2202,7 +2238,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2202
2238
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
2203
2239
  };
2204
2240
 
2205
- setterMap.set(set, redSet);
2241
+ setterMap$1.set(set, redSet);
2206
2242
  reverseSetterMap.set(redSet, set);
2207
2243
  return set;
2208
2244
  }
@@ -2243,6 +2279,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2243
2279
  }
2244
2280
 
2245
2281
  setPrototypeOf(shadowTarget, prototype) {
2282
+ /* istanbul ignore else */
2246
2283
  if (process.env.NODE_ENV !== 'production') {
2247
2284
  throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
2248
2285
  }
@@ -2256,6 +2293,11 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2256
2293
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
2257
2294
  // the preventExtension call, in which case we should not attempt to lock down
2258
2295
  // the shadow target.
2296
+ // TODO: It should not actually be possible to reach this `if` statement.
2297
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
2298
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
2299
+
2300
+ /* istanbul ignore if */
2259
2301
 
2260
2302
  if (isExtensible(originalTarget)) {
2261
2303
  return false;
@@ -2297,8 +2339,8 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2297
2339
 
2298
2340
  }
2299
2341
 
2300
- const getterMap$1 = new WeakMap();
2301
- const setterMap$1 = new WeakMap();
2342
+ const getterMap = new WeakMap();
2343
+ const setterMap = new WeakMap();
2302
2344
 
2303
2345
  class ReadOnlyHandler extends BaseProxyHandler {
2304
2346
  wrapValue(value) {
@@ -2306,7 +2348,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
2306
2348
  }
2307
2349
 
2308
2350
  wrapGetter(originalGet) {
2309
- const wrappedGetter = getterMap$1.get(originalGet);
2351
+ const wrappedGetter = getterMap.get(originalGet);
2310
2352
 
2311
2353
  if (!isUndefined(wrappedGetter)) {
2312
2354
  return wrappedGetter;
@@ -2319,12 +2361,12 @@ class ReadOnlyHandler extends BaseProxyHandler {
2319
2361
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2320
2362
  };
2321
2363
 
2322
- getterMap$1.set(originalGet, get);
2364
+ getterMap.set(originalGet, get);
2323
2365
  return get;
2324
2366
  }
2325
2367
 
2326
2368
  wrapSetter(originalSet) {
2327
- const wrappedSetter = setterMap$1.get(originalSet);
2369
+ const wrappedSetter = setterMap.get(originalSet);
2328
2370
 
2329
2371
  if (!isUndefined(wrappedSetter)) {
2330
2372
  return wrappedSetter;
@@ -2333,6 +2375,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
2333
2375
  const handler = this;
2334
2376
 
2335
2377
  const set = function (v) {
2378
+ /* istanbul ignore else */
2336
2379
  if (process.env.NODE_ENV !== 'production') {
2337
2380
  const {
2338
2381
  originalTarget
@@ -2341,33 +2384,41 @@ class ReadOnlyHandler extends BaseProxyHandler {
2341
2384
  }
2342
2385
  };
2343
2386
 
2344
- setterMap$1.set(originalSet, set);
2387
+ setterMap.set(originalSet, set);
2345
2388
  return set;
2346
2389
  }
2347
2390
 
2348
2391
  set(shadowTarget, key, value) {
2392
+ /* istanbul ignore else */
2349
2393
  if (process.env.NODE_ENV !== 'production') {
2350
2394
  const {
2351
2395
  originalTarget
2352
2396
  } = this;
2353
- throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2397
+ 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.`;
2398
+ throw new Error(msg);
2354
2399
  }
2400
+ /* istanbul ignore next */
2401
+
2355
2402
 
2356
2403
  return false;
2357
2404
  }
2358
2405
 
2359
2406
  deleteProperty(shadowTarget, key) {
2407
+ /* istanbul ignore else */
2360
2408
  if (process.env.NODE_ENV !== 'production') {
2361
2409
  const {
2362
2410
  originalTarget
2363
2411
  } = this;
2364
2412
  throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2365
2413
  }
2414
+ /* istanbul ignore next */
2415
+
2366
2416
 
2367
2417
  return false;
2368
2418
  }
2369
2419
 
2370
2420
  setPrototypeOf(shadowTarget, prototype) {
2421
+ /* istanbul ignore else */
2371
2422
  if (process.env.NODE_ENV !== 'production') {
2372
2423
  const {
2373
2424
  originalTarget
@@ -2377,23 +2428,29 @@ class ReadOnlyHandler extends BaseProxyHandler {
2377
2428
  }
2378
2429
 
2379
2430
  preventExtensions(shadowTarget) {
2431
+ /* istanbul ignore else */
2380
2432
  if (process.env.NODE_ENV !== 'production') {
2381
2433
  const {
2382
2434
  originalTarget
2383
2435
  } = this;
2384
2436
  throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
2385
2437
  }
2438
+ /* istanbul ignore next */
2439
+
2386
2440
 
2387
2441
  return false;
2388
2442
  }
2389
2443
 
2390
2444
  defineProperty(shadowTarget, key, descriptor) {
2445
+ /* istanbul ignore else */
2391
2446
  if (process.env.NODE_ENV !== 'production') {
2392
2447
  const {
2393
2448
  originalTarget
2394
2449
  } = this;
2395
2450
  throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2396
2451
  }
2452
+ /* istanbul ignore next */
2453
+
2397
2454
 
2398
2455
  return false;
2399
2456
  }
@@ -2451,6 +2508,8 @@ const formatter = {
2451
2508
  }; // Inspired from paulmillr/es6-shim
2452
2509
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2453
2510
 
2511
+ /* istanbul ignore next */
2512
+
2454
2513
  function getGlobal() {
2455
2514
  // the only reliable means to get the global object is `Function('return this')()`
2456
2515
  // However, this causes CSP violations in Chrome apps.
@@ -2475,6 +2534,7 @@ function getGlobal() {
2475
2534
  }
2476
2535
 
2477
2536
  function init() {
2537
+ /* istanbul ignore if */
2478
2538
  if (process.env.NODE_ENV === 'production') {
2479
2539
  // this method should never leak to prod
2480
2540
  throw new ReferenceError();
@@ -2489,6 +2549,8 @@ function init() {
2489
2549
  ArrayPush.call(devtoolsFormatters, formatter);
2490
2550
  global.devtoolsFormatters = devtoolsFormatters;
2491
2551
  }
2552
+ /* istanbul ignore else */
2553
+
2492
2554
 
2493
2555
  if (process.env.NODE_ENV !== 'production') {
2494
2556
  init();
@@ -2535,7 +2597,8 @@ class ReactiveMembrane {
2535
2597
  this.valueMutated = defaultValueMutated;
2536
2598
  this.valueObserved = defaultValueObserved;
2537
2599
  this.valueIsObservable = defaultValueIsObservable;
2538
- this.objectGraph = new WeakMap();
2600
+ this.readOnlyObjectGraph = new WeakMap();
2601
+ this.reactiveObjectGraph = new WeakMap();
2539
2602
 
2540
2603
  if (!isUndefined(options)) {
2541
2604
  const {
@@ -2558,10 +2621,13 @@ class ReactiveMembrane {
2558
2621
  const distorted = this.valueDistortion(unwrappedValue);
2559
2622
 
2560
2623
  if (this.valueIsObservable(distorted)) {
2561
- const o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2562
- // we return the readonly.
2624
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2625
+ // when trying to extract the writable version of a readonly
2626
+ // we return the readonly.
2627
+ return value;
2628
+ }
2563
2629
 
2564
- return o.readOnly === value ? value : o.reactive;
2630
+ return this.getReactiveHandler(unwrappedValue, distorted);
2565
2631
  }
2566
2632
 
2567
2633
  return distorted;
@@ -2572,7 +2638,7 @@ class ReactiveMembrane {
2572
2638
  const distorted = this.valueDistortion(value);
2573
2639
 
2574
2640
  if (this.valueIsObservable(distorted)) {
2575
- return this.getReactiveState(value, distorted).readOnly;
2641
+ return this.getReadOnlyHandler(value, distorted);
2576
2642
  }
2577
2643
 
2578
2644
  return distorted;
@@ -2582,47 +2648,36 @@ class ReactiveMembrane {
2582
2648
  return unwrap$1(p);
2583
2649
  }
2584
2650
 
2585
- getReactiveState(value, distortedValue) {
2586
- const {
2587
- objectGraph
2588
- } = this;
2589
- let reactiveState = objectGraph.get(distortedValue);
2651
+ getReactiveHandler(value, distortedValue) {
2652
+ let proxy = this.reactiveObjectGraph.get(distortedValue);
2590
2653
 
2591
- if (reactiveState) {
2592
- return reactiveState;
2654
+ if (isUndefined(proxy)) {
2655
+ // caching the proxy after the first time it is accessed
2656
+ const handler = new ReactiveProxyHandler(this, distortedValue);
2657
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2658
+ registerProxy(proxy, value);
2659
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2593
2660
  }
2594
2661
 
2595
- const membrane = this;
2596
- reactiveState = {
2597
- get reactive() {
2598
- const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2599
-
2600
- const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2601
- registerProxy(proxy, value);
2602
- ObjectDefineProperty(this, 'reactive', {
2603
- value: proxy
2604
- });
2605
- return proxy;
2606
- },
2662
+ return proxy;
2663
+ }
2607
2664
 
2608
- get readOnly() {
2609
- const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2665
+ getReadOnlyHandler(value, distortedValue) {
2666
+ let proxy = this.readOnlyObjectGraph.get(distortedValue);
2610
2667
 
2611
- const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2612
- registerProxy(proxy, value);
2613
- ObjectDefineProperty(this, 'readOnly', {
2614
- value: proxy
2615
- });
2616
- return proxy;
2617
- }
2668
+ if (isUndefined(proxy)) {
2669
+ // caching the proxy after the first time it is accessed
2670
+ const handler = new ReadOnlyHandler(this, distortedValue);
2671
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2672
+ registerProxy(proxy, value);
2673
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2674
+ }
2618
2675
 
2619
- };
2620
- objectGraph.set(distortedValue, reactiveState);
2621
- return reactiveState;
2676
+ return proxy;
2622
2677
  }
2623
2678
 
2624
2679
  }
2625
- /** version: 1.0.0 */
2680
+ /** version: 1.1.5 */
2626
2681
 
2627
2682
  /*
2628
2683
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3076,8 +3131,10 @@ for (const [elementProp, rendererMethod] of childGetters) {
3076
3131
  }
3077
3132
 
3078
3133
  return renderer[rendererMethod](elm);
3079
- }
3134
+ },
3080
3135
 
3136
+ configurable: true,
3137
+ enumerable: true
3081
3138
  };
3082
3139
  }
3083
3140
 
@@ -3097,8 +3154,11 @@ for (const queryMethod of queryMethods) {
3097
3154
  }
3098
3155
 
3099
3156
  return renderer[queryMethod](elm, arg);
3100
- }
3157
+ },
3101
3158
 
3159
+ configurable: true,
3160
+ enumerable: true,
3161
+ writable: true
3102
3162
  };
3103
3163
  }
3104
3164
 
@@ -4136,7 +4196,7 @@ function createComponentDef(Ctor) {
4136
4196
  if (!isUndefined$1(ctorShadowSupportMode)) {
4137
4197
  assert.invariant(ctorShadowSupportMode === "any"
4138
4198
  /* Any */
4139
- || ctorShadowSupportMode === "default"
4199
+ || ctorShadowSupportMode === "reset"
4140
4200
  /* Default */
4141
4201
  , `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
4142
4202
  }
@@ -4298,7 +4358,7 @@ const lightingElementDef = {
4298
4358
  renderMode: 1
4299
4359
  /* Shadow */
4300
4360
  ,
4301
- shadowSupportMode: "default"
4361
+ shadowSupportMode: "reset"
4302
4362
  /* Default */
4303
4363
  ,
4304
4364
  wire: EmptyObject,
@@ -4447,6 +4507,17 @@ function createElmHook(vnode) {
4447
4507
  modComputedStyle.create(vnode);
4448
4508
  }
4449
4509
 
4510
+ function hydrateElmHook(vnode) {
4511
+ modEvents.create(vnode); // Attrs are already on the element.
4512
+ // modAttrs.create(vnode);
4513
+
4514
+ modProps.create(vnode); // Already set.
4515
+ // modStaticClassName.create(vnode);
4516
+ // modStaticStyle.create(vnode);
4517
+ // modComputedClassName.create(vnode);
4518
+ // modComputedStyle.create(vnode);
4519
+ }
4520
+
4450
4521
  function fallbackElmHook(elm, vnode) {
4451
4522
  const {
4452
4523
  owner
@@ -4618,6 +4689,179 @@ function createChildrenHook(vnode) {
4618
4689
  }
4619
4690
  }
4620
4691
 
4692
+ function isElementNode(node) {
4693
+ // eslint-disable-next-line lwc-internal/no-global-node
4694
+ return node.nodeType === Node.ELEMENT_NODE;
4695
+ }
4696
+
4697
+ function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4698
+ const {
4699
+ data: {
4700
+ attrs = {}
4701
+ },
4702
+ owner: {
4703
+ renderer
4704
+ }
4705
+ } = vnode;
4706
+ let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
4707
+ // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
4708
+
4709
+ for (const [attrName, attrValue] of Object.entries(attrs)) {
4710
+ const elmAttrValue = renderer.getAttribute(elm, attrName);
4711
+
4712
+ if (String(attrValue) !== elmAttrValue) {
4713
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
4714
+ nodesAreCompatible = false;
4715
+ }
4716
+ }
4717
+
4718
+ return nodesAreCompatible;
4719
+ }
4720
+
4721
+ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4722
+ const {
4723
+ data: {
4724
+ className,
4725
+ classMap
4726
+ },
4727
+ owner: {
4728
+ renderer
4729
+ }
4730
+ } = vnode;
4731
+ let nodesAreCompatible = true;
4732
+ let vnodeClassName;
4733
+
4734
+ if (!isUndefined$1(className) && String(className) !== elm.className) {
4735
+ // className is used when class is bound to an expr.
4736
+ nodesAreCompatible = false;
4737
+ vnodeClassName = className;
4738
+ } else if (!isUndefined$1(classMap)) {
4739
+ // classMap is used when class is set to static value.
4740
+ const classList = renderer.getClassList(elm);
4741
+ let computedClassName = ''; // all classes from the vnode should be in the element.classList
4742
+
4743
+ for (const name in classMap) {
4744
+ computedClassName += ' ' + name;
4745
+
4746
+ if (!classList.contains(name)) {
4747
+ nodesAreCompatible = false;
4748
+ }
4749
+ }
4750
+
4751
+ vnodeClassName = computedClassName.trim();
4752
+
4753
+ if (classList.length > keys(classMap).length) {
4754
+ nodesAreCompatible = false;
4755
+ }
4756
+ }
4757
+
4758
+ if (!nodesAreCompatible) {
4759
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
4760
+ }
4761
+
4762
+ return nodesAreCompatible;
4763
+ }
4764
+
4765
+ function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
4766
+ const {
4767
+ data: {
4768
+ style,
4769
+ styleDecls
4770
+ },
4771
+ owner: {
4772
+ renderer
4773
+ }
4774
+ } = vnode;
4775
+ const elmStyle = renderer.getAttribute(elm, 'style') || '';
4776
+ let vnodeStyle;
4777
+ let nodesAreCompatible = true;
4778
+
4779
+ if (!isUndefined$1(style) && style !== elmStyle) {
4780
+ nodesAreCompatible = false;
4781
+ vnodeStyle = style;
4782
+ } else if (!isUndefined$1(styleDecls)) {
4783
+ const parsedVnodeStyle = parseStyleText(elmStyle);
4784
+ const expectedStyle = []; // styleMap is used when style is set to static value.
4785
+
4786
+ for (let i = 0, n = styleDecls.length; i < n; i++) {
4787
+ const [prop, value, important] = styleDecls[i];
4788
+ expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
4789
+ const parsedPropValue = parsedVnodeStyle[prop];
4790
+
4791
+ if (isUndefined$1(parsedPropValue)) {
4792
+ nodesAreCompatible = false;
4793
+ } else if (!parsedPropValue.startsWith(value)) {
4794
+ nodesAreCompatible = false;
4795
+ } else if (important && !parsedPropValue.endsWith('!important')) {
4796
+ nodesAreCompatible = false;
4797
+ }
4798
+ }
4799
+
4800
+ if (keys(parsedVnodeStyle).length > styleDecls.length) {
4801
+ nodesAreCompatible = false;
4802
+ }
4803
+
4804
+ vnodeStyle = ArrayJoin.call(expectedStyle, ';');
4805
+ }
4806
+
4807
+ if (!nodesAreCompatible) {
4808
+ // style is used when class is bound to an expr.
4809
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
4810
+ }
4811
+
4812
+ return nodesAreCompatible;
4813
+ }
4814
+
4815
+ function throwHydrationError() {
4816
+ assert.fail('Server rendered elements do not match client side generated elements');
4817
+ }
4818
+
4819
+ function hydrateChildrenHook(elmChildren, children, vm) {
4820
+ var _a, _b;
4821
+
4822
+ if (process.env.NODE_ENV !== 'production') {
4823
+ const filteredVNodes = ArrayFilter.call(children, vnode => !!vnode);
4824
+
4825
+ if (elmChildren.length !== filteredVNodes.length) {
4826
+ logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
4827
+ throwHydrationError();
4828
+ }
4829
+ }
4830
+
4831
+ let elmCurrentChildIdx = 0;
4832
+
4833
+ for (let j = 0, n = children.length; j < n; j++) {
4834
+ const ch = children[j];
4835
+
4836
+ if (ch != null) {
4837
+ const childNode = elmChildren[elmCurrentChildIdx];
4838
+
4839
+ if (process.env.NODE_ENV !== 'production') {
4840
+ // VComments and VTexts validation is handled in their hooks
4841
+ if (isElementNode(childNode)) {
4842
+ if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
4843
+ logError(`Hydration mismatch: expecting element with tag "${(_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase()}" but found "${childNode.tagName.toLowerCase()}".`, vm);
4844
+ throwHydrationError();
4845
+ } // Note: props are not yet set
4846
+
4847
+
4848
+ const hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
4849
+ const hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
4850
+ const hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
4851
+ const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
4852
+
4853
+ if (!isVNodeAndElementCompatible) {
4854
+ throwHydrationError();
4855
+ }
4856
+ }
4857
+ }
4858
+
4859
+ ch.hook.hydrate(ch, childNode);
4860
+ elmCurrentChildIdx++;
4861
+ }
4862
+ }
4863
+ }
4864
+
4621
4865
  function updateCustomElmHook(oldVnode, vnode) {
4622
4866
  // Attrs need to be applied to element before props
4623
4867
  // IE11 will wipe out value on radio inputs if value
@@ -4701,38 +4945,6 @@ function getUpgradableConstructor(tagName, renderer) {
4701
4945
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4702
4946
  */
4703
4947
 
4704
- /**
4705
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4706
- * libraries to sanitize HTML content. This hook process the content passed via the template to
4707
- * lwc:inner-html directive.
4708
- * It is meant to be overridden with setSanitizeHtmlContentHook
4709
- */
4710
-
4711
-
4712
- let sanitizeHtmlContentHook = () => {
4713
- // locker-service patches this function during runtime to sanitize HTML content.
4714
- throw new Error('sanitizeHtmlContent hook must be implemented.');
4715
- };
4716
- /**
4717
- * Sets the sanitizeHtmlContentHook.
4718
- *
4719
- * @param newHookImpl
4720
- * @returns oldHookImplementation.
4721
- */
4722
-
4723
-
4724
- function setSanitizeHtmlContentHook(newHookImpl) {
4725
- const currentHook = sanitizeHtmlContentHook;
4726
- sanitizeHtmlContentHook = newHookImpl;
4727
- return currentHook;
4728
- }
4729
- /*
4730
- * Copyright (c) 2018, salesforce.com, inc.
4731
- * All rights reserved.
4732
- * SPDX-License-Identifier: MIT
4733
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4734
- */
4735
-
4736
4948
 
4737
4949
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
4738
4950
  const SymbolIterator = Symbol.iterator;
@@ -4751,7 +4963,26 @@ const TextHook = {
4751
4963
  update: updateNodeHook,
4752
4964
  insert: insertNodeHook,
4753
4965
  move: insertNodeHook,
4754
- remove: removeNodeHook
4966
+ remove: removeNodeHook,
4967
+ hydrate: (vNode, node) => {
4968
+ var _a;
4969
+
4970
+ if (process.env.NODE_ENV !== 'production') {
4971
+ // eslint-disable-next-line lwc-internal/no-global-node
4972
+ if (node.nodeType !== Node.TEXT_NODE) {
4973
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
4974
+ assert.fail('Hydration mismatch: incorrect node type received.');
4975
+ }
4976
+
4977
+ if (node.nodeValue !== vNode.text) {
4978
+ logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
4979
+ }
4980
+ } // always set the text value to the one from the vnode.
4981
+
4982
+
4983
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
4984
+ vNode.elm = node;
4985
+ }
4755
4986
  };
4756
4987
  const CommentHook = {
4757
4988
  create: vnode => {
@@ -4769,7 +5000,26 @@ const CommentHook = {
4769
5000
  update: updateNodeHook,
4770
5001
  insert: insertNodeHook,
4771
5002
  move: insertNodeHook,
4772
- remove: removeNodeHook
5003
+ remove: removeNodeHook,
5004
+ hydrate: (vNode, node) => {
5005
+ var _a;
5006
+
5007
+ if (process.env.NODE_ENV !== 'production') {
5008
+ // eslint-disable-next-line lwc-internal/no-global-node
5009
+ if (node.nodeType !== Node.COMMENT_NODE) {
5010
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5011
+ assert.fail('Hydration mismatch: incorrect node type received.');
5012
+ }
5013
+
5014
+ if (node.nodeValue !== vNode.text) {
5015
+ logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
5016
+ }
5017
+ } // always set the text value to the one from the vnode.
5018
+
5019
+
5020
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5021
+ vNode.elm = node;
5022
+ }
4773
5023
  }; // insert is called after update, which is used somewhere else (via a module)
4774
5024
  // to mark the vm as inserted, that means we cannot use update as the main channel
4775
5025
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -4809,6 +5059,38 @@ const ElementHook = {
4809
5059
  remove: (vnode, parentNode) => {
4810
5060
  removeNodeHook(vnode, parentNode);
4811
5061
  removeElmHook(vnode);
5062
+ },
5063
+ hydrate: (vnode, node) => {
5064
+ const elm = node;
5065
+ vnode.elm = elm;
5066
+ const {
5067
+ context
5068
+ } = vnode.data;
5069
+ const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
5070
+ /* manual */
5071
+ );
5072
+
5073
+ if (isDomManual) {
5074
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5075
+ // remove the innerHTML from props so it reuses the existing dom elements.
5076
+ const {
5077
+ props
5078
+ } = vnode.data;
5079
+
5080
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5081
+ if (elm.innerHTML === props.innerHTML) {
5082
+ delete props.innerHTML;
5083
+ } else {
5084
+ logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5085
+ }
5086
+ }
5087
+ }
5088
+
5089
+ hydrateElmHook(vnode);
5090
+
5091
+ if (!isDomManual) {
5092
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
5093
+ }
4812
5094
  }
4813
5095
  };
4814
5096
  const CustomElementHook = {
@@ -4900,6 +5182,44 @@ const CustomElementHook = {
4900
5182
  // will take care of disconnecting any child VM attached to its shadow as well.
4901
5183
  removeVM(vm);
4902
5184
  }
5185
+ },
5186
+ hydrate: (vnode, elm) => {
5187
+ // the element is created, but the vm is not
5188
+ const {
5189
+ sel,
5190
+ mode,
5191
+ ctor,
5192
+ owner
5193
+ } = vnode;
5194
+ const def = getComponentInternalDef(ctor);
5195
+ createVM(elm, def, {
5196
+ mode,
5197
+ owner,
5198
+ tagName: sel,
5199
+ renderer: owner.renderer
5200
+ });
5201
+ vnode.elm = elm;
5202
+ const vm = getAssociatedVM(elm);
5203
+ allocateChildrenHook(vnode, vm);
5204
+ hydrateElmHook(vnode); // Insert hook section:
5205
+
5206
+ if (process.env.NODE_ENV !== 'production') {
5207
+ assert.isTrue(vm.state === 0
5208
+ /* created */
5209
+ , `${vm} cannot be recycled.`);
5210
+ }
5211
+
5212
+ runConnectedCallback(vm);
5213
+
5214
+ if (vm.renderMode !== 0
5215
+ /* Light */
5216
+ ) {
5217
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5218
+ // Note: for Light DOM, this is handled while hydrating the VM
5219
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
5220
+ }
5221
+
5222
+ hydrateVM(vm);
4903
5223
  }
4904
5224
  };
4905
5225
 
@@ -5108,7 +5428,7 @@ function i(iterable, factory) {
5108
5428
  next = iterator.next();
5109
5429
  last = next.done; // template factory logic based on the previous collected value
5110
5430
 
5111
- const vnode = factory(value, j, j === 0, last);
5431
+ const vnode = factory(value, j, j === 0, last === true);
5112
5432
 
5113
5433
  if (isArray$1(vnode)) {
5114
5434
  ArrayPush$1.apply(list, vnode);
@@ -5212,7 +5532,7 @@ function co(text) {
5212
5532
 
5213
5533
 
5214
5534
  function d(value) {
5215
- return value == null ? '' : value;
5535
+ return value == null ? '' : String(value);
5216
5536
  } // [b]ind function
5217
5537
 
5218
5538
 
@@ -5374,6 +5694,26 @@ function sc(vnodes) {
5374
5694
 
5375
5695
  markAsDynamicChildren(vnodes);
5376
5696
  return vnodes;
5697
+ }
5698
+ /**
5699
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
5700
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
5701
+ * lwc:inner-html directive.
5702
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
5703
+ */
5704
+
5705
+
5706
+ let sanitizeHtmlContentHook = () => {
5707
+ // locker-service patches this function during runtime to sanitize HTML content.
5708
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
5709
+ };
5710
+ /**
5711
+ * Sets the sanitizeHtmlContentHook.
5712
+ */
5713
+
5714
+
5715
+ function setSanitizeHtmlContentHook(newHookImpl) {
5716
+ sanitizeHtmlContentHook = newHookImpl;
5377
5717
  } // [s]anitize [h]tml [c]ontent
5378
5718
 
5379
5719
 
@@ -5381,24 +5721,22 @@ function shc(content) {
5381
5721
  return sanitizeHtmlContentHook(content);
5382
5722
  }
5383
5723
 
5384
- var api = /*#__PURE__*/Object.freeze({
5385
- __proto__: null,
5386
- h: h,
5387
- ti: ti,
5388
- s: s,
5389
- c: c,
5390
- i: i,
5391
- f: f,
5392
- t: t,
5393
- co: co,
5394
- d: d,
5395
- b: b,
5396
- k: k,
5397
- gid: gid,
5398
- fid: fid,
5399
- dc: dc,
5400
- sc: sc,
5401
- shc: shc
5724
+ const api = freeze({
5725
+ s,
5726
+ h,
5727
+ c,
5728
+ i,
5729
+ f,
5730
+ t,
5731
+ d,
5732
+ b,
5733
+ k,
5734
+ co,
5735
+ dc,
5736
+ ti,
5737
+ gid,
5738
+ fid,
5739
+ shc
5402
5740
  });
5403
5741
  /*
5404
5742
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5412,12 +5750,12 @@ function makeHostToken(token) {
5412
5750
  }
5413
5751
 
5414
5752
  function createInlineStyleVNode(content) {
5415
- return h('style', {
5753
+ return api.h('style', {
5416
5754
  key: 'style',
5417
5755
  attrs: {
5418
5756
  type: 'text/css'
5419
5757
  }
5420
- }, [t(content)]);
5758
+ }, [api.t(content)]);
5421
5759
  }
5422
5760
 
5423
5761
  function updateStylesheetToken(vm, template) {
@@ -5485,6 +5823,7 @@ function updateStylesheetToken(vm, template) {
5485
5823
 
5486
5824
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5487
5825
  const content = [];
5826
+ let root;
5488
5827
 
5489
5828
  for (let i = 0; i < stylesheets.length; i++) {
5490
5829
  let stylesheet = stylesheets[i];
@@ -5497,23 +5836,46 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5497
5836
  // the component instance might be attempting to use an old version of
5498
5837
  // the stylesheet, while internally, we have a replacement for it.
5499
5838
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5500
- } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5501
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5839
+ }
5502
5840
 
5841
+ const isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5842
+
5843
+ const scopeToken = isScopedCss || vm.shadowMode === 1
5844
+ /* Synthetic */
5845
+ && vm.renderMode === 1
5846
+ /* Shadow */
5847
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5848
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5503
5849
 
5504
- const isScopedCss = stylesheet[KEY__SCOPED_CSS];
5505
5850
  const useActualHostSelector = vm.renderMode === 0
5506
5851
  /* Light */
5507
5852
  ? !isScopedCss : vm.shadowMode === 0
5508
5853
  /* Native */
5509
- ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5854
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5855
+ // we use an attribute selector on the host to simulate :dir().
5510
5856
 
5511
- const scopeToken = isScopedCss || vm.shadowMode === 1
5512
- /* Synthetic */
5513
- && vm.renderMode === 1
5857
+ let useNativeDirPseudoclass;
5858
+
5859
+ if (vm.renderMode === 1
5514
5860
  /* Shadow */
5515
- ? stylesheetToken : undefined;
5516
- ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
5861
+ ) {
5862
+ useNativeDirPseudoclass = vm.shadowMode === 0
5863
+ /* Native */
5864
+ ;
5865
+ } else {
5866
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
5867
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
5868
+ if (isUndefined$1(root)) {
5869
+ // Only calculate the root once as necessary
5870
+ root = getNearestShadowComponent(vm);
5871
+ }
5872
+
5873
+ useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
5874
+ /* Native */
5875
+ ;
5876
+ }
5877
+
5878
+ ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5517
5879
  }
5518
5880
  }
5519
5881
 
@@ -5537,14 +5899,12 @@ function getStylesheetsContent(vm, template) {
5537
5899
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5538
5900
 
5539
5901
 
5540
- function getNearestNativeShadowComponent(vm) {
5902
+ function getNearestShadowComponent(vm) {
5541
5903
  let owner = vm;
5542
5904
 
5543
5905
  while (!isNull(owner)) {
5544
5906
  if (owner.renderMode === 1
5545
5907
  /* Shadow */
5546
- && owner.shadowMode === 0
5547
- /* Native */
5548
5908
  ) {
5549
5909
  return owner;
5550
5910
  }
@@ -5555,6 +5915,20 @@ function getNearestNativeShadowComponent(vm) {
5555
5915
  return owner;
5556
5916
  }
5557
5917
 
5918
+ function getNearestNativeShadowComponent(vm) {
5919
+ const owner = getNearestShadowComponent(vm);
5920
+
5921
+ if (!isNull(owner) && owner.shadowMode === 1
5922
+ /* Synthetic */
5923
+ ) {
5924
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
5925
+ // synthetic, we know we won't find a native component if we go any further.
5926
+ return null;
5927
+ }
5928
+
5929
+ return owner;
5930
+ }
5931
+
5558
5932
  function createStylesheet(vm, stylesheets) {
5559
5933
  const {
5560
5934
  renderer,
@@ -5570,7 +5944,10 @@ function createStylesheet(vm, stylesheets) {
5570
5944
  for (let i = 0; i < stylesheets.length; i++) {
5571
5945
  renderer.insertGlobalStylesheet(stylesheets[i]);
5572
5946
  }
5573
- } else if (renderer.ssr) {
5947
+ } else if (renderer.ssr || renderer.isHydrating()) {
5948
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
5949
+ // This works in the client, because the stylesheets are created, and cached in the VM
5950
+ // the first time the VM renders.
5574
5951
  // native shadow or light DOM, SSR
5575
5952
  const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
5576
5953
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -6150,6 +6527,10 @@ function disconnectRootElement(elm) {
6150
6527
 
6151
6528
  function appendVM(vm) {
6152
6529
  rehydrate(vm);
6530
+ }
6531
+
6532
+ function hydrateVM(vm) {
6533
+ hydrate(vm);
6153
6534
  } // just in case the component comes back, with this we guarantee re-rendering it
6154
6535
  // while preventing any attempt to rehydration until after reinsertion.
6155
6536
 
@@ -6383,6 +6764,22 @@ function rehydrate(vm) {
6383
6764
  }
6384
6765
  }
6385
6766
 
6767
+ function hydrate(vm) {
6768
+ if (isTrue(vm.isDirty)) {
6769
+ // manually diffing/patching here.
6770
+ // This routine is:
6771
+ // patchShadowRoot(vm, children);
6772
+ // -> addVnodes.
6773
+ const children = renderComponent$1(vm);
6774
+ vm.children = children;
6775
+ const vmChildren = vm.renderMode === 0
6776
+ /* Light */
6777
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
6778
+ hydrateChildrenHook(vmChildren, children, vm);
6779
+ runRenderedCallback(vm);
6780
+ }
6781
+ }
6782
+
6386
6783
  function patchShadowRoot(vm, newCh) {
6387
6784
  const {
6388
6785
  children: oldCh
@@ -7191,28 +7588,12 @@ function readonly(obj) {
7191
7588
 
7192
7589
  let hooksAreSet = false;
7193
7590
 
7194
- function overrideHooks(hooks) {
7195
- const oldHooks = {};
7196
-
7197
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
7198
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7199
- }
7200
-
7201
- return oldHooks;
7202
- }
7203
-
7204
7591
  function setHooks(hooks) {
7205
7592
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7206
- overrideHooks(hooks);
7207
7593
  hooksAreSet = true;
7594
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7208
7595
  }
7209
-
7210
- function setHooksForTest(hooks) {
7211
- if (process.env.NODE_ENV !== 'production') {
7212
- return overrideHooks(hooks);
7213
- }
7214
- }
7215
- /* version: 2.5.5-canary1 */
7596
+ /* version: 2.5.9 */
7216
7597
 
7217
7598
  /*
7218
7599
  * Copyright (c) 2020, salesforce.com, inc.
@@ -7242,7 +7623,7 @@ var HostNodeType;
7242
7623
  const CLASSNAMES_SEPARATOR = /\s+/g;
7243
7624
 
7244
7625
  function classNameToTokenList(value) {
7245
- return new Set(value.trim().split(CLASSNAMES_SEPARATOR));
7626
+ return new Set(value.split(CLASSNAMES_SEPARATOR).filter(str => str.length));
7246
7627
  }
7247
7628
 
7248
7629
  function tokenListToClassName(values) {
@@ -7304,6 +7685,11 @@ class HTMLElement$1 {
7304
7685
 
7305
7686
  const renderer = {
7306
7687
  ssr: true,
7688
+
7689
+ isHydrating() {
7690
+ return false;
7691
+ },
7692
+
7307
7693
  isNativeShadowDefined: false,
7308
7694
  isSyntheticShadowDefined: false,
7309
7695
 
@@ -7511,18 +7897,18 @@ const renderer = {
7511
7897
  },
7512
7898
 
7513
7899
  setCSSStyleProperty(element, name, value, important) {
7514
- let styleAttribute = element.attributes.find(attr => attr.name === 'style' && isNull(attr.namespace));
7900
+ const styleAttribute = element.attributes.find(attr => attr.name === 'style' && isNull(attr.namespace));
7901
+ const serializedProperty = `${name}: ${value}${important ? ' !important' : ''}`;
7515
7902
 
7516
7903
  if (isUndefined$1(styleAttribute)) {
7517
- styleAttribute = {
7904
+ element.attributes.push({
7518
7905
  name: 'style',
7519
7906
  namespace: null,
7520
- value: ''
7521
- };
7522
- element.attributes.push(styleAttribute);
7907
+ value: serializedProperty
7908
+ });
7909
+ } else {
7910
+ styleAttribute.value += `; ${serializedProperty}`;
7523
7911
  }
7524
-
7525
- styleAttribute.value = `${styleAttribute.value}; ${name}: ${value}${important ? ' !important' : ''}`;
7526
7912
  },
7527
7913
 
7528
7914
  isConnected(node) {
@@ -7703,7 +8089,7 @@ function renderComponent(tagName, Ctor, props = {}) {
7703
8089
 
7704
8090
  freeze(LightningElement);
7705
8091
  seal(LightningElement.prototype);
7706
- /* version: 2.5.5-canary1 */
8092
+ /* version: 2.5.9 */
7707
8093
 
7708
8094
  exports.LightningElement = LightningElement;
7709
8095
  exports.api = api$1;
@@ -7720,7 +8106,6 @@ exports.sanitizeAttribute = sanitizeAttribute;
7720
8106
  exports.setFeatureFlag = setFeatureFlag;
7721
8107
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
7722
8108
  exports.setHooks = setHooks;
7723
- exports.setHooksForTest = setHooksForTest;
7724
8109
  exports.track = track;
7725
8110
  exports.unwrap = unwrap;
7726
8111
  exports.wire = wire;