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
@@ -69,7 +69,7 @@ const {
69
69
  find: ArrayFind,
70
70
  indexOf: ArrayIndexOf,
71
71
  join: ArrayJoin,
72
- map: ArrayMap$1,
72
+ map: ArrayMap,
73
73
  push: ArrayPush$1,
74
74
  reduce: ArrayReduce,
75
75
  reverse: ArrayReverse,
@@ -136,7 +136,7 @@ function toString$1(obj) {
136
136
  // Array.prototype.toString directly will cause an error Iterate through
137
137
  // all the items and handle individually.
138
138
  if (isArray$1(obj)) {
139
- return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
139
+ return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
140
140
  }
141
141
 
142
142
  return obj.toString();
@@ -335,7 +335,7 @@ function htmlPropertyToAttribute(propName) {
335
335
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
336
336
  return attributeName;
337
337
  }
338
- /** version: 2.5.5-canary1 */
338
+ /** version: 2.5.9 */
339
339
 
340
340
  /*
341
341
  * Copyright (c) 2020, salesforce.com, inc.
@@ -456,7 +456,7 @@ function setFeatureFlagForTest(name, value) {
456
456
  setFeatureFlag(name, value);
457
457
  }
458
458
  }
459
- /** version: 2.5.5-canary1 */
459
+ /** version: 2.5.9 */
460
460
 
461
461
  /* proxy-compat-disable */
462
462
 
@@ -508,6 +508,28 @@ function guid() {
508
508
  }
509
509
 
510
510
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
511
+ } // Borrowed from Vue template compiler.
512
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
513
+
514
+
515
+ const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
516
+ const PROPERTY_DELIMITER = /:(.+)/;
517
+
518
+ function parseStyleText(cssText) {
519
+ const styleMap = {};
520
+ const declarations = cssText.split(DECLARATION_DELIMITER);
521
+
522
+ for (const declaration of declarations) {
523
+ if (declaration) {
524
+ const [prop, value] = declaration.split(PROPERTY_DELIMITER);
525
+
526
+ if (prop !== undefined && value !== undefined) {
527
+ styleMap[prop.trim()] = value.trim();
528
+ }
529
+ }
530
+ }
531
+
532
+ return styleMap;
511
533
  }
512
534
  /*
513
535
  * Copyright (c) 2019, salesforce.com, inc.
@@ -689,8 +711,8 @@ function getErrorComponentStack(vm) {
689
711
  */
690
712
 
691
713
 
692
- function logError(message, vm) {
693
- let msg = `[LWC error]: ${message}`;
714
+ function log(method, message, vm) {
715
+ let msg = `[LWC ${method}]: ${message}`;
694
716
 
695
717
  if (!isUndefined$1(vm)) {
696
718
  msg = `${msg}\n${getComponentStack(vm)}`;
@@ -698,7 +720,7 @@ function logError(message, vm) {
698
720
 
699
721
  if (process.env.NODE_ENV === 'test') {
700
722
  /* eslint-disable-next-line no-console */
701
- console.error(msg);
723
+ console[method](msg);
702
724
  return;
703
725
  }
704
726
 
@@ -706,9 +728,17 @@ function logError(message, vm) {
706
728
  throw new Error(msg);
707
729
  } catch (e) {
708
730
  /* eslint-disable-next-line no-console */
709
- console.error(e);
731
+ console[method](e);
710
732
  }
711
733
  }
734
+
735
+ function logError(message, vm) {
736
+ log('error', message, vm);
737
+ }
738
+
739
+ function logWarn(message, vm) {
740
+ log('warn', message, vm);
741
+ }
712
742
  /*
713
743
  * Copyright (c) 2018, salesforce.com, inc.
714
744
  * All rights reserved.
@@ -1876,7 +1906,6 @@ const {
1876
1906
  getPrototypeOf,
1877
1907
  create: ObjectCreate,
1878
1908
  defineProperty: ObjectDefineProperty,
1879
- defineProperties: ObjectDefineProperties,
1880
1909
  isExtensible,
1881
1910
  getOwnPropertyDescriptor,
1882
1911
  getOwnPropertyNames,
@@ -1886,8 +1915,7 @@ const {
1886
1915
  } = Object;
1887
1916
  const {
1888
1917
  push: ArrayPush,
1889
- concat: ArrayConcat,
1890
- map: ArrayMap
1918
+ concat: ArrayConcat
1891
1919
  } = Array.prototype;
1892
1920
  const OtS = {}.toString;
1893
1921
 
@@ -1952,7 +1980,9 @@ class BaseProxyHandler {
1952
1980
  // but it will always be compatible with the previous descriptor
1953
1981
  // to preserve the object invariants, which makes these lines safe.
1954
1982
 
1955
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
1983
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1984
+
1985
+ /* istanbul ignore else */
1956
1986
 
1957
1987
  if (!isUndefined(originalDescriptor)) {
1958
1988
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1980,11 +2010,17 @@ class BaseProxyHandler {
1980
2010
 
1981
2011
  preventExtensions(shadowTarget);
1982
2012
  } // Shared Traps
2013
+ // TODO: apply() is never called
2014
+
2015
+ /* istanbul ignore next */
1983
2016
 
1984
2017
 
1985
2018
  apply(shadowTarget, thisArg, argArray) {
1986
2019
  /* No op */
1987
- }
2020
+ } // TODO: construct() is never called
2021
+
2022
+ /* istanbul ignore next */
2023
+
1988
2024
 
1989
2025
  construct(shadowTarget, argArray, newTarget) {
1990
2026
  /* No op */
@@ -2097,8 +2133,8 @@ class BaseProxyHandler {
2097
2133
 
2098
2134
  }
2099
2135
 
2100
- const getterMap = new WeakMap();
2101
- const setterMap = new WeakMap();
2136
+ const getterMap$1 = new WeakMap();
2137
+ const setterMap$1 = new WeakMap();
2102
2138
  const reverseGetterMap = new WeakMap();
2103
2139
  const reverseSetterMap = new WeakMap();
2104
2140
 
@@ -2108,7 +2144,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2108
2144
  }
2109
2145
 
2110
2146
  wrapGetter(originalGet) {
2111
- const wrappedGetter = getterMap.get(originalGet);
2147
+ const wrappedGetter = getterMap$1.get(originalGet);
2112
2148
 
2113
2149
  if (!isUndefined(wrappedGetter)) {
2114
2150
  return wrappedGetter;
@@ -2121,13 +2157,13 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2121
2157
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2122
2158
  };
2123
2159
 
2124
- getterMap.set(originalGet, get);
2160
+ getterMap$1.set(originalGet, get);
2125
2161
  reverseGetterMap.set(get, originalGet);
2126
2162
  return get;
2127
2163
  }
2128
2164
 
2129
2165
  wrapSetter(originalSet) {
2130
- const wrappedSetter = setterMap.get(originalSet);
2166
+ const wrappedSetter = setterMap$1.get(originalSet);
2131
2167
 
2132
2168
  if (!isUndefined(wrappedSetter)) {
2133
2169
  return wrappedSetter;
@@ -2138,7 +2174,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2138
2174
  originalSet.call(unwrap$1(this), unwrap$1(v));
2139
2175
  };
2140
2176
 
2141
- setterMap.set(originalSet, set);
2177
+ setterMap$1.set(originalSet, set);
2142
2178
  reverseSetterMap.set(set, originalSet);
2143
2179
  return set;
2144
2180
  }
@@ -2179,7 +2215,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2179
2215
  return unwrap$1(redGet.call(handler.wrapValue(this)));
2180
2216
  };
2181
2217
 
2182
- getterMap.set(get, redGet);
2218
+ getterMap$1.set(get, redGet);
2183
2219
  reverseGetterMap.set(redGet, get);
2184
2220
  return get;
2185
2221
  }
@@ -2198,7 +2234,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2198
2234
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
2199
2235
  };
2200
2236
 
2201
- setterMap.set(set, redSet);
2237
+ setterMap$1.set(set, redSet);
2202
2238
  reverseSetterMap.set(redSet, set);
2203
2239
  return set;
2204
2240
  }
@@ -2239,6 +2275,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2239
2275
  }
2240
2276
 
2241
2277
  setPrototypeOf(shadowTarget, prototype) {
2278
+ /* istanbul ignore else */
2242
2279
  if (process.env.NODE_ENV !== 'production') {
2243
2280
  throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
2244
2281
  }
@@ -2252,6 +2289,11 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2252
2289
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
2253
2290
  // the preventExtension call, in which case we should not attempt to lock down
2254
2291
  // the shadow target.
2292
+ // TODO: It should not actually be possible to reach this `if` statement.
2293
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
2294
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
2295
+
2296
+ /* istanbul ignore if */
2255
2297
 
2256
2298
  if (isExtensible(originalTarget)) {
2257
2299
  return false;
@@ -2293,8 +2335,8 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2293
2335
 
2294
2336
  }
2295
2337
 
2296
- const getterMap$1 = new WeakMap();
2297
- const setterMap$1 = new WeakMap();
2338
+ const getterMap = new WeakMap();
2339
+ const setterMap = new WeakMap();
2298
2340
 
2299
2341
  class ReadOnlyHandler extends BaseProxyHandler {
2300
2342
  wrapValue(value) {
@@ -2302,7 +2344,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
2302
2344
  }
2303
2345
 
2304
2346
  wrapGetter(originalGet) {
2305
- const wrappedGetter = getterMap$1.get(originalGet);
2347
+ const wrappedGetter = getterMap.get(originalGet);
2306
2348
 
2307
2349
  if (!isUndefined(wrappedGetter)) {
2308
2350
  return wrappedGetter;
@@ -2315,12 +2357,12 @@ class ReadOnlyHandler extends BaseProxyHandler {
2315
2357
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2316
2358
  };
2317
2359
 
2318
- getterMap$1.set(originalGet, get);
2360
+ getterMap.set(originalGet, get);
2319
2361
  return get;
2320
2362
  }
2321
2363
 
2322
2364
  wrapSetter(originalSet) {
2323
- const wrappedSetter = setterMap$1.get(originalSet);
2365
+ const wrappedSetter = setterMap.get(originalSet);
2324
2366
 
2325
2367
  if (!isUndefined(wrappedSetter)) {
2326
2368
  return wrappedSetter;
@@ -2329,6 +2371,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
2329
2371
  const handler = this;
2330
2372
 
2331
2373
  const set = function (v) {
2374
+ /* istanbul ignore else */
2332
2375
  if (process.env.NODE_ENV !== 'production') {
2333
2376
  const {
2334
2377
  originalTarget
@@ -2337,33 +2380,41 @@ class ReadOnlyHandler extends BaseProxyHandler {
2337
2380
  }
2338
2381
  };
2339
2382
 
2340
- setterMap$1.set(originalSet, set);
2383
+ setterMap.set(originalSet, set);
2341
2384
  return set;
2342
2385
  }
2343
2386
 
2344
2387
  set(shadowTarget, key, value) {
2388
+ /* istanbul ignore else */
2345
2389
  if (process.env.NODE_ENV !== 'production') {
2346
2390
  const {
2347
2391
  originalTarget
2348
2392
  } = this;
2349
- throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2393
+ 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.`;
2394
+ throw new Error(msg);
2350
2395
  }
2396
+ /* istanbul ignore next */
2397
+
2351
2398
 
2352
2399
  return false;
2353
2400
  }
2354
2401
 
2355
2402
  deleteProperty(shadowTarget, key) {
2403
+ /* istanbul ignore else */
2356
2404
  if (process.env.NODE_ENV !== 'production') {
2357
2405
  const {
2358
2406
  originalTarget
2359
2407
  } = this;
2360
2408
  throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2361
2409
  }
2410
+ /* istanbul ignore next */
2411
+
2362
2412
 
2363
2413
  return false;
2364
2414
  }
2365
2415
 
2366
2416
  setPrototypeOf(shadowTarget, prototype) {
2417
+ /* istanbul ignore else */
2367
2418
  if (process.env.NODE_ENV !== 'production') {
2368
2419
  const {
2369
2420
  originalTarget
@@ -2373,23 +2424,29 @@ class ReadOnlyHandler extends BaseProxyHandler {
2373
2424
  }
2374
2425
 
2375
2426
  preventExtensions(shadowTarget) {
2427
+ /* istanbul ignore else */
2376
2428
  if (process.env.NODE_ENV !== 'production') {
2377
2429
  const {
2378
2430
  originalTarget
2379
2431
  } = this;
2380
2432
  throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
2381
2433
  }
2434
+ /* istanbul ignore next */
2435
+
2382
2436
 
2383
2437
  return false;
2384
2438
  }
2385
2439
 
2386
2440
  defineProperty(shadowTarget, key, descriptor) {
2441
+ /* istanbul ignore else */
2387
2442
  if (process.env.NODE_ENV !== 'production') {
2388
2443
  const {
2389
2444
  originalTarget
2390
2445
  } = this;
2391
2446
  throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2392
2447
  }
2448
+ /* istanbul ignore next */
2449
+
2393
2450
 
2394
2451
  return false;
2395
2452
  }
@@ -2447,6 +2504,8 @@ const formatter = {
2447
2504
  }; // Inspired from paulmillr/es6-shim
2448
2505
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2449
2506
 
2507
+ /* istanbul ignore next */
2508
+
2450
2509
  function getGlobal() {
2451
2510
  // the only reliable means to get the global object is `Function('return this')()`
2452
2511
  // However, this causes CSP violations in Chrome apps.
@@ -2471,6 +2530,7 @@ function getGlobal() {
2471
2530
  }
2472
2531
 
2473
2532
  function init() {
2533
+ /* istanbul ignore if */
2474
2534
  if (process.env.NODE_ENV === 'production') {
2475
2535
  // this method should never leak to prod
2476
2536
  throw new ReferenceError();
@@ -2485,6 +2545,8 @@ function init() {
2485
2545
  ArrayPush.call(devtoolsFormatters, formatter);
2486
2546
  global.devtoolsFormatters = devtoolsFormatters;
2487
2547
  }
2548
+ /* istanbul ignore else */
2549
+
2488
2550
 
2489
2551
  if (process.env.NODE_ENV !== 'production') {
2490
2552
  init();
@@ -2531,7 +2593,8 @@ class ReactiveMembrane {
2531
2593
  this.valueMutated = defaultValueMutated;
2532
2594
  this.valueObserved = defaultValueObserved;
2533
2595
  this.valueIsObservable = defaultValueIsObservable;
2534
- this.objectGraph = new WeakMap();
2596
+ this.readOnlyObjectGraph = new WeakMap();
2597
+ this.reactiveObjectGraph = new WeakMap();
2535
2598
 
2536
2599
  if (!isUndefined(options)) {
2537
2600
  const {
@@ -2554,10 +2617,13 @@ class ReactiveMembrane {
2554
2617
  const distorted = this.valueDistortion(unwrappedValue);
2555
2618
 
2556
2619
  if (this.valueIsObservable(distorted)) {
2557
- const o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2558
- // we return the readonly.
2620
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2621
+ // when trying to extract the writable version of a readonly
2622
+ // we return the readonly.
2623
+ return value;
2624
+ }
2559
2625
 
2560
- return o.readOnly === value ? value : o.reactive;
2626
+ return this.getReactiveHandler(unwrappedValue, distorted);
2561
2627
  }
2562
2628
 
2563
2629
  return distorted;
@@ -2568,7 +2634,7 @@ class ReactiveMembrane {
2568
2634
  const distorted = this.valueDistortion(value);
2569
2635
 
2570
2636
  if (this.valueIsObservable(distorted)) {
2571
- return this.getReactiveState(value, distorted).readOnly;
2637
+ return this.getReadOnlyHandler(value, distorted);
2572
2638
  }
2573
2639
 
2574
2640
  return distorted;
@@ -2578,47 +2644,36 @@ class ReactiveMembrane {
2578
2644
  return unwrap$1(p);
2579
2645
  }
2580
2646
 
2581
- getReactiveState(value, distortedValue) {
2582
- const {
2583
- objectGraph
2584
- } = this;
2585
- let reactiveState = objectGraph.get(distortedValue);
2647
+ getReactiveHandler(value, distortedValue) {
2648
+ let proxy = this.reactiveObjectGraph.get(distortedValue);
2586
2649
 
2587
- if (reactiveState) {
2588
- return reactiveState;
2650
+ if (isUndefined(proxy)) {
2651
+ // caching the proxy after the first time it is accessed
2652
+ const handler = new ReactiveProxyHandler(this, distortedValue);
2653
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2654
+ registerProxy(proxy, value);
2655
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2589
2656
  }
2590
2657
 
2591
- const membrane = this;
2592
- reactiveState = {
2593
- get reactive() {
2594
- const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2595
-
2596
- const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2597
- registerProxy(proxy, value);
2598
- ObjectDefineProperty(this, 'reactive', {
2599
- value: proxy
2600
- });
2601
- return proxy;
2602
- },
2658
+ return proxy;
2659
+ }
2603
2660
 
2604
- get readOnly() {
2605
- const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2661
+ getReadOnlyHandler(value, distortedValue) {
2662
+ let proxy = this.readOnlyObjectGraph.get(distortedValue);
2606
2663
 
2607
- const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2608
- registerProxy(proxy, value);
2609
- ObjectDefineProperty(this, 'readOnly', {
2610
- value: proxy
2611
- });
2612
- return proxy;
2613
- }
2664
+ if (isUndefined(proxy)) {
2665
+ // caching the proxy after the first time it is accessed
2666
+ const handler = new ReadOnlyHandler(this, distortedValue);
2667
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2668
+ registerProxy(proxy, value);
2669
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2670
+ }
2614
2671
 
2615
- };
2616
- objectGraph.set(distortedValue, reactiveState);
2617
- return reactiveState;
2672
+ return proxy;
2618
2673
  }
2619
2674
 
2620
2675
  }
2621
- /** version: 1.0.0 */
2676
+ /** version: 1.1.5 */
2622
2677
 
2623
2678
  /*
2624
2679
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3072,8 +3127,10 @@ for (const [elementProp, rendererMethod] of childGetters) {
3072
3127
  }
3073
3128
 
3074
3129
  return renderer[rendererMethod](elm);
3075
- }
3130
+ },
3076
3131
 
3132
+ configurable: true,
3133
+ enumerable: true
3077
3134
  };
3078
3135
  }
3079
3136
 
@@ -3093,8 +3150,11 @@ for (const queryMethod of queryMethods) {
3093
3150
  }
3094
3151
 
3095
3152
  return renderer[queryMethod](elm, arg);
3096
- }
3153
+ },
3097
3154
 
3155
+ configurable: true,
3156
+ enumerable: true,
3157
+ writable: true
3098
3158
  };
3099
3159
  }
3100
3160
 
@@ -4132,7 +4192,7 @@ function createComponentDef(Ctor) {
4132
4192
  if (!isUndefined$1(ctorShadowSupportMode)) {
4133
4193
  assert.invariant(ctorShadowSupportMode === "any"
4134
4194
  /* Any */
4135
- || ctorShadowSupportMode === "default"
4195
+ || ctorShadowSupportMode === "reset"
4136
4196
  /* Default */
4137
4197
  , `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
4138
4198
  }
@@ -4294,7 +4354,7 @@ const lightingElementDef = {
4294
4354
  renderMode: 1
4295
4355
  /* Shadow */
4296
4356
  ,
4297
- shadowSupportMode: "default"
4357
+ shadowSupportMode: "reset"
4298
4358
  /* Default */
4299
4359
  ,
4300
4360
  wire: EmptyObject,
@@ -4443,6 +4503,17 @@ function createElmHook(vnode) {
4443
4503
  modComputedStyle.create(vnode);
4444
4504
  }
4445
4505
 
4506
+ function hydrateElmHook(vnode) {
4507
+ modEvents.create(vnode); // Attrs are already on the element.
4508
+ // modAttrs.create(vnode);
4509
+
4510
+ modProps.create(vnode); // Already set.
4511
+ // modStaticClassName.create(vnode);
4512
+ // modStaticStyle.create(vnode);
4513
+ // modComputedClassName.create(vnode);
4514
+ // modComputedStyle.create(vnode);
4515
+ }
4516
+
4446
4517
  function fallbackElmHook(elm, vnode) {
4447
4518
  const {
4448
4519
  owner
@@ -4614,6 +4685,179 @@ function createChildrenHook(vnode) {
4614
4685
  }
4615
4686
  }
4616
4687
 
4688
+ function isElementNode(node) {
4689
+ // eslint-disable-next-line lwc-internal/no-global-node
4690
+ return node.nodeType === Node.ELEMENT_NODE;
4691
+ }
4692
+
4693
+ function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4694
+ const {
4695
+ data: {
4696
+ attrs = {}
4697
+ },
4698
+ owner: {
4699
+ renderer
4700
+ }
4701
+ } = vnode;
4702
+ let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
4703
+ // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
4704
+
4705
+ for (const [attrName, attrValue] of Object.entries(attrs)) {
4706
+ const elmAttrValue = renderer.getAttribute(elm, attrName);
4707
+
4708
+ if (String(attrValue) !== elmAttrValue) {
4709
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
4710
+ nodesAreCompatible = false;
4711
+ }
4712
+ }
4713
+
4714
+ return nodesAreCompatible;
4715
+ }
4716
+
4717
+ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4718
+ const {
4719
+ data: {
4720
+ className,
4721
+ classMap
4722
+ },
4723
+ owner: {
4724
+ renderer
4725
+ }
4726
+ } = vnode;
4727
+ let nodesAreCompatible = true;
4728
+ let vnodeClassName;
4729
+
4730
+ if (!isUndefined$1(className) && String(className) !== elm.className) {
4731
+ // className is used when class is bound to an expr.
4732
+ nodesAreCompatible = false;
4733
+ vnodeClassName = className;
4734
+ } else if (!isUndefined$1(classMap)) {
4735
+ // classMap is used when class is set to static value.
4736
+ const classList = renderer.getClassList(elm);
4737
+ let computedClassName = ''; // all classes from the vnode should be in the element.classList
4738
+
4739
+ for (const name in classMap) {
4740
+ computedClassName += ' ' + name;
4741
+
4742
+ if (!classList.contains(name)) {
4743
+ nodesAreCompatible = false;
4744
+ }
4745
+ }
4746
+
4747
+ vnodeClassName = computedClassName.trim();
4748
+
4749
+ if (classList.length > keys(classMap).length) {
4750
+ nodesAreCompatible = false;
4751
+ }
4752
+ }
4753
+
4754
+ if (!nodesAreCompatible) {
4755
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
4756
+ }
4757
+
4758
+ return nodesAreCompatible;
4759
+ }
4760
+
4761
+ function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
4762
+ const {
4763
+ data: {
4764
+ style,
4765
+ styleDecls
4766
+ },
4767
+ owner: {
4768
+ renderer
4769
+ }
4770
+ } = vnode;
4771
+ const elmStyle = renderer.getAttribute(elm, 'style') || '';
4772
+ let vnodeStyle;
4773
+ let nodesAreCompatible = true;
4774
+
4775
+ if (!isUndefined$1(style) && style !== elmStyle) {
4776
+ nodesAreCompatible = false;
4777
+ vnodeStyle = style;
4778
+ } else if (!isUndefined$1(styleDecls)) {
4779
+ const parsedVnodeStyle = parseStyleText(elmStyle);
4780
+ const expectedStyle = []; // styleMap is used when style is set to static value.
4781
+
4782
+ for (let i = 0, n = styleDecls.length; i < n; i++) {
4783
+ const [prop, value, important] = styleDecls[i];
4784
+ expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
4785
+ const parsedPropValue = parsedVnodeStyle[prop];
4786
+
4787
+ if (isUndefined$1(parsedPropValue)) {
4788
+ nodesAreCompatible = false;
4789
+ } else if (!parsedPropValue.startsWith(value)) {
4790
+ nodesAreCompatible = false;
4791
+ } else if (important && !parsedPropValue.endsWith('!important')) {
4792
+ nodesAreCompatible = false;
4793
+ }
4794
+ }
4795
+
4796
+ if (keys(parsedVnodeStyle).length > styleDecls.length) {
4797
+ nodesAreCompatible = false;
4798
+ }
4799
+
4800
+ vnodeStyle = ArrayJoin.call(expectedStyle, ';');
4801
+ }
4802
+
4803
+ if (!nodesAreCompatible) {
4804
+ // style is used when class is bound to an expr.
4805
+ logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
4806
+ }
4807
+
4808
+ return nodesAreCompatible;
4809
+ }
4810
+
4811
+ function throwHydrationError() {
4812
+ assert.fail('Server rendered elements do not match client side generated elements');
4813
+ }
4814
+
4815
+ function hydrateChildrenHook(elmChildren, children, vm) {
4816
+ var _a, _b;
4817
+
4818
+ if (process.env.NODE_ENV !== 'production') {
4819
+ const filteredVNodes = ArrayFilter.call(children, vnode => !!vnode);
4820
+
4821
+ if (elmChildren.length !== filteredVNodes.length) {
4822
+ logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
4823
+ throwHydrationError();
4824
+ }
4825
+ }
4826
+
4827
+ let elmCurrentChildIdx = 0;
4828
+
4829
+ for (let j = 0, n = children.length; j < n; j++) {
4830
+ const ch = children[j];
4831
+
4832
+ if (ch != null) {
4833
+ const childNode = elmChildren[elmCurrentChildIdx];
4834
+
4835
+ if (process.env.NODE_ENV !== 'production') {
4836
+ // VComments and VTexts validation is handled in their hooks
4837
+ if (isElementNode(childNode)) {
4838
+ if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
4839
+ logError(`Hydration mismatch: expecting element with tag "${(_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase()}" but found "${childNode.tagName.toLowerCase()}".`, vm);
4840
+ throwHydrationError();
4841
+ } // Note: props are not yet set
4842
+
4843
+
4844
+ const hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
4845
+ const hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
4846
+ const hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
4847
+ const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
4848
+
4849
+ if (!isVNodeAndElementCompatible) {
4850
+ throwHydrationError();
4851
+ }
4852
+ }
4853
+ }
4854
+
4855
+ ch.hook.hydrate(ch, childNode);
4856
+ elmCurrentChildIdx++;
4857
+ }
4858
+ }
4859
+ }
4860
+
4617
4861
  function updateCustomElmHook(oldVnode, vnode) {
4618
4862
  // Attrs need to be applied to element before props
4619
4863
  // IE11 will wipe out value on radio inputs if value
@@ -4697,38 +4941,6 @@ function getUpgradableConstructor(tagName, renderer) {
4697
4941
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4698
4942
  */
4699
4943
 
4700
- /**
4701
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4702
- * libraries to sanitize HTML content. This hook process the content passed via the template to
4703
- * lwc:inner-html directive.
4704
- * It is meant to be overridden with setSanitizeHtmlContentHook
4705
- */
4706
-
4707
-
4708
- let sanitizeHtmlContentHook = () => {
4709
- // locker-service patches this function during runtime to sanitize HTML content.
4710
- throw new Error('sanitizeHtmlContent hook must be implemented.');
4711
- };
4712
- /**
4713
- * Sets the sanitizeHtmlContentHook.
4714
- *
4715
- * @param newHookImpl
4716
- * @returns oldHookImplementation.
4717
- */
4718
-
4719
-
4720
- function setSanitizeHtmlContentHook(newHookImpl) {
4721
- const currentHook = sanitizeHtmlContentHook;
4722
- sanitizeHtmlContentHook = newHookImpl;
4723
- return currentHook;
4724
- }
4725
- /*
4726
- * Copyright (c) 2018, salesforce.com, inc.
4727
- * All rights reserved.
4728
- * SPDX-License-Identifier: MIT
4729
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4730
- */
4731
-
4732
4944
 
4733
4945
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
4734
4946
  const SymbolIterator = Symbol.iterator;
@@ -4747,7 +4959,26 @@ const TextHook = {
4747
4959
  update: updateNodeHook,
4748
4960
  insert: insertNodeHook,
4749
4961
  move: insertNodeHook,
4750
- remove: removeNodeHook
4962
+ remove: removeNodeHook,
4963
+ hydrate: (vNode, node) => {
4964
+ var _a;
4965
+
4966
+ if (process.env.NODE_ENV !== 'production') {
4967
+ // eslint-disable-next-line lwc-internal/no-global-node
4968
+ if (node.nodeType !== Node.TEXT_NODE) {
4969
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
4970
+ assert.fail('Hydration mismatch: incorrect node type received.');
4971
+ }
4972
+
4973
+ if (node.nodeValue !== vNode.text) {
4974
+ logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
4975
+ }
4976
+ } // always set the text value to the one from the vnode.
4977
+
4978
+
4979
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
4980
+ vNode.elm = node;
4981
+ }
4751
4982
  };
4752
4983
  const CommentHook = {
4753
4984
  create: vnode => {
@@ -4765,7 +4996,26 @@ const CommentHook = {
4765
4996
  update: updateNodeHook,
4766
4997
  insert: insertNodeHook,
4767
4998
  move: insertNodeHook,
4768
- remove: removeNodeHook
4999
+ remove: removeNodeHook,
5000
+ hydrate: (vNode, node) => {
5001
+ var _a;
5002
+
5003
+ if (process.env.NODE_ENV !== 'production') {
5004
+ // eslint-disable-next-line lwc-internal/no-global-node
5005
+ if (node.nodeType !== Node.COMMENT_NODE) {
5006
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5007
+ assert.fail('Hydration mismatch: incorrect node type received.');
5008
+ }
5009
+
5010
+ if (node.nodeValue !== vNode.text) {
5011
+ logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
5012
+ }
5013
+ } // always set the text value to the one from the vnode.
5014
+
5015
+
5016
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5017
+ vNode.elm = node;
5018
+ }
4769
5019
  }; // insert is called after update, which is used somewhere else (via a module)
4770
5020
  // to mark the vm as inserted, that means we cannot use update as the main channel
4771
5021
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -4805,6 +5055,38 @@ const ElementHook = {
4805
5055
  remove: (vnode, parentNode) => {
4806
5056
  removeNodeHook(vnode, parentNode);
4807
5057
  removeElmHook(vnode);
5058
+ },
5059
+ hydrate: (vnode, node) => {
5060
+ const elm = node;
5061
+ vnode.elm = elm;
5062
+ const {
5063
+ context
5064
+ } = vnode.data;
5065
+ const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
5066
+ /* manual */
5067
+ );
5068
+
5069
+ if (isDomManual) {
5070
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5071
+ // remove the innerHTML from props so it reuses the existing dom elements.
5072
+ const {
5073
+ props
5074
+ } = vnode.data;
5075
+
5076
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5077
+ if (elm.innerHTML === props.innerHTML) {
5078
+ delete props.innerHTML;
5079
+ } else {
5080
+ logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
5081
+ }
5082
+ }
5083
+ }
5084
+
5085
+ hydrateElmHook(vnode);
5086
+
5087
+ if (!isDomManual) {
5088
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
5089
+ }
4808
5090
  }
4809
5091
  };
4810
5092
  const CustomElementHook = {
@@ -4896,6 +5178,44 @@ const CustomElementHook = {
4896
5178
  // will take care of disconnecting any child VM attached to its shadow as well.
4897
5179
  removeVM(vm);
4898
5180
  }
5181
+ },
5182
+ hydrate: (vnode, elm) => {
5183
+ // the element is created, but the vm is not
5184
+ const {
5185
+ sel,
5186
+ mode,
5187
+ ctor,
5188
+ owner
5189
+ } = vnode;
5190
+ const def = getComponentInternalDef(ctor);
5191
+ createVM(elm, def, {
5192
+ mode,
5193
+ owner,
5194
+ tagName: sel,
5195
+ renderer: owner.renderer
5196
+ });
5197
+ vnode.elm = elm;
5198
+ const vm = getAssociatedVM(elm);
5199
+ allocateChildrenHook(vnode, vm);
5200
+ hydrateElmHook(vnode); // Insert hook section:
5201
+
5202
+ if (process.env.NODE_ENV !== 'production') {
5203
+ assert.isTrue(vm.state === 0
5204
+ /* created */
5205
+ , `${vm} cannot be recycled.`);
5206
+ }
5207
+
5208
+ runConnectedCallback(vm);
5209
+
5210
+ if (vm.renderMode !== 0
5211
+ /* Light */
5212
+ ) {
5213
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5214
+ // Note: for Light DOM, this is handled while hydrating the VM
5215
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
5216
+ }
5217
+
5218
+ hydrateVM(vm);
4899
5219
  }
4900
5220
  };
4901
5221
 
@@ -5104,7 +5424,7 @@ function i(iterable, factory) {
5104
5424
  next = iterator.next();
5105
5425
  last = next.done; // template factory logic based on the previous collected value
5106
5426
 
5107
- const vnode = factory(value, j, j === 0, last);
5427
+ const vnode = factory(value, j, j === 0, last === true);
5108
5428
 
5109
5429
  if (isArray$1(vnode)) {
5110
5430
  ArrayPush$1.apply(list, vnode);
@@ -5208,7 +5528,7 @@ function co(text) {
5208
5528
 
5209
5529
 
5210
5530
  function d(value) {
5211
- return value == null ? '' : value;
5531
+ return value == null ? '' : String(value);
5212
5532
  } // [b]ind function
5213
5533
 
5214
5534
 
@@ -5370,6 +5690,26 @@ function sc(vnodes) {
5370
5690
 
5371
5691
  markAsDynamicChildren(vnodes);
5372
5692
  return vnodes;
5693
+ }
5694
+ /**
5695
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
5696
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
5697
+ * lwc:inner-html directive.
5698
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
5699
+ */
5700
+
5701
+
5702
+ let sanitizeHtmlContentHook = () => {
5703
+ // locker-service patches this function during runtime to sanitize HTML content.
5704
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
5705
+ };
5706
+ /**
5707
+ * Sets the sanitizeHtmlContentHook.
5708
+ */
5709
+
5710
+
5711
+ function setSanitizeHtmlContentHook(newHookImpl) {
5712
+ sanitizeHtmlContentHook = newHookImpl;
5373
5713
  } // [s]anitize [h]tml [c]ontent
5374
5714
 
5375
5715
 
@@ -5377,24 +5717,22 @@ function shc(content) {
5377
5717
  return sanitizeHtmlContentHook(content);
5378
5718
  }
5379
5719
 
5380
- var api = /*#__PURE__*/Object.freeze({
5381
- __proto__: null,
5382
- h: h,
5383
- ti: ti,
5384
- s: s,
5385
- c: c,
5386
- i: i,
5387
- f: f,
5388
- t: t,
5389
- co: co,
5390
- d: d,
5391
- b: b,
5392
- k: k,
5393
- gid: gid,
5394
- fid: fid,
5395
- dc: dc,
5396
- sc: sc,
5397
- shc: shc
5720
+ const api = freeze({
5721
+ s,
5722
+ h,
5723
+ c,
5724
+ i,
5725
+ f,
5726
+ t,
5727
+ d,
5728
+ b,
5729
+ k,
5730
+ co,
5731
+ dc,
5732
+ ti,
5733
+ gid,
5734
+ fid,
5735
+ shc
5398
5736
  });
5399
5737
  /*
5400
5738
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5408,12 +5746,12 @@ function makeHostToken(token) {
5408
5746
  }
5409
5747
 
5410
5748
  function createInlineStyleVNode(content) {
5411
- return h('style', {
5749
+ return api.h('style', {
5412
5750
  key: 'style',
5413
5751
  attrs: {
5414
5752
  type: 'text/css'
5415
5753
  }
5416
- }, [t(content)]);
5754
+ }, [api.t(content)]);
5417
5755
  }
5418
5756
 
5419
5757
  function updateStylesheetToken(vm, template) {
@@ -5481,6 +5819,7 @@ function updateStylesheetToken(vm, template) {
5481
5819
 
5482
5820
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5483
5821
  const content = [];
5822
+ let root;
5484
5823
 
5485
5824
  for (let i = 0; i < stylesheets.length; i++) {
5486
5825
  let stylesheet = stylesheets[i];
@@ -5493,23 +5832,46 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5493
5832
  // the component instance might be attempting to use an old version of
5494
5833
  // the stylesheet, while internally, we have a replacement for it.
5495
5834
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5496
- } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5497
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5835
+ }
5498
5836
 
5837
+ const isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5838
+
5839
+ const scopeToken = isScopedCss || vm.shadowMode === 1
5840
+ /* Synthetic */
5841
+ && vm.renderMode === 1
5842
+ /* Shadow */
5843
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5844
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5499
5845
 
5500
- const isScopedCss = stylesheet[KEY__SCOPED_CSS];
5501
5846
  const useActualHostSelector = vm.renderMode === 0
5502
5847
  /* Light */
5503
5848
  ? !isScopedCss : vm.shadowMode === 0
5504
5849
  /* Native */
5505
- ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5850
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5851
+ // we use an attribute selector on the host to simulate :dir().
5506
5852
 
5507
- const scopeToken = isScopedCss || vm.shadowMode === 1
5508
- /* Synthetic */
5509
- && vm.renderMode === 1
5853
+ let useNativeDirPseudoclass;
5854
+
5855
+ if (vm.renderMode === 1
5510
5856
  /* Shadow */
5511
- ? stylesheetToken : undefined;
5512
- ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
5857
+ ) {
5858
+ useNativeDirPseudoclass = vm.shadowMode === 0
5859
+ /* Native */
5860
+ ;
5861
+ } else {
5862
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
5863
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
5864
+ if (isUndefined$1(root)) {
5865
+ // Only calculate the root once as necessary
5866
+ root = getNearestShadowComponent(vm);
5867
+ }
5868
+
5869
+ useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
5870
+ /* Native */
5871
+ ;
5872
+ }
5873
+
5874
+ ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5513
5875
  }
5514
5876
  }
5515
5877
 
@@ -5533,14 +5895,12 @@ function getStylesheetsContent(vm, template) {
5533
5895
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5534
5896
 
5535
5897
 
5536
- function getNearestNativeShadowComponent(vm) {
5898
+ function getNearestShadowComponent(vm) {
5537
5899
  let owner = vm;
5538
5900
 
5539
5901
  while (!isNull(owner)) {
5540
5902
  if (owner.renderMode === 1
5541
5903
  /* Shadow */
5542
- && owner.shadowMode === 0
5543
- /* Native */
5544
5904
  ) {
5545
5905
  return owner;
5546
5906
  }
@@ -5551,6 +5911,20 @@ function getNearestNativeShadowComponent(vm) {
5551
5911
  return owner;
5552
5912
  }
5553
5913
 
5914
+ function getNearestNativeShadowComponent(vm) {
5915
+ const owner = getNearestShadowComponent(vm);
5916
+
5917
+ if (!isNull(owner) && owner.shadowMode === 1
5918
+ /* Synthetic */
5919
+ ) {
5920
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
5921
+ // synthetic, we know we won't find a native component if we go any further.
5922
+ return null;
5923
+ }
5924
+
5925
+ return owner;
5926
+ }
5927
+
5554
5928
  function createStylesheet(vm, stylesheets) {
5555
5929
  const {
5556
5930
  renderer,
@@ -5566,7 +5940,10 @@ function createStylesheet(vm, stylesheets) {
5566
5940
  for (let i = 0; i < stylesheets.length; i++) {
5567
5941
  renderer.insertGlobalStylesheet(stylesheets[i]);
5568
5942
  }
5569
- } else if (renderer.ssr) {
5943
+ } else if (renderer.ssr || renderer.isHydrating()) {
5944
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
5945
+ // This works in the client, because the stylesheets are created, and cached in the VM
5946
+ // the first time the VM renders.
5570
5947
  // native shadow or light DOM, SSR
5571
5948
  const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
5572
5949
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -6146,6 +6523,10 @@ function disconnectRootElement(elm) {
6146
6523
 
6147
6524
  function appendVM(vm) {
6148
6525
  rehydrate(vm);
6526
+ }
6527
+
6528
+ function hydrateVM(vm) {
6529
+ hydrate(vm);
6149
6530
  } // just in case the component comes back, with this we guarantee re-rendering it
6150
6531
  // while preventing any attempt to rehydration until after reinsertion.
6151
6532
 
@@ -6379,6 +6760,22 @@ function rehydrate(vm) {
6379
6760
  }
6380
6761
  }
6381
6762
 
6763
+ function hydrate(vm) {
6764
+ if (isTrue(vm.isDirty)) {
6765
+ // manually diffing/patching here.
6766
+ // This routine is:
6767
+ // patchShadowRoot(vm, children);
6768
+ // -> addVnodes.
6769
+ const children = renderComponent$1(vm);
6770
+ vm.children = children;
6771
+ const vmChildren = vm.renderMode === 0
6772
+ /* Light */
6773
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
6774
+ hydrateChildrenHook(vmChildren, children, vm);
6775
+ runRenderedCallback(vm);
6776
+ }
6777
+ }
6778
+
6382
6779
  function patchShadowRoot(vm, newCh) {
6383
6780
  const {
6384
6781
  children: oldCh
@@ -7187,28 +7584,12 @@ function readonly(obj) {
7187
7584
 
7188
7585
  let hooksAreSet = false;
7189
7586
 
7190
- function overrideHooks(hooks) {
7191
- const oldHooks = {};
7192
-
7193
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
7194
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7195
- }
7196
-
7197
- return oldHooks;
7198
- }
7199
-
7200
7587
  function setHooks(hooks) {
7201
7588
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7202
- overrideHooks(hooks);
7203
7589
  hooksAreSet = true;
7590
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7204
7591
  }
7205
-
7206
- function setHooksForTest(hooks) {
7207
- if (process.env.NODE_ENV !== 'production') {
7208
- return overrideHooks(hooks);
7209
- }
7210
- }
7211
- /* version: 2.5.5-canary1 */
7592
+ /* version: 2.5.9 */
7212
7593
 
7213
7594
  /*
7214
7595
  * Copyright (c) 2020, salesforce.com, inc.
@@ -7238,7 +7619,7 @@ var HostNodeType;
7238
7619
  const CLASSNAMES_SEPARATOR = /\s+/g;
7239
7620
 
7240
7621
  function classNameToTokenList(value) {
7241
- return new Set(value.trim().split(CLASSNAMES_SEPARATOR));
7622
+ return new Set(value.split(CLASSNAMES_SEPARATOR).filter(str => str.length));
7242
7623
  }
7243
7624
 
7244
7625
  function tokenListToClassName(values) {
@@ -7300,6 +7681,11 @@ class HTMLElement$1 {
7300
7681
 
7301
7682
  const renderer = {
7302
7683
  ssr: true,
7684
+
7685
+ isHydrating() {
7686
+ return false;
7687
+ },
7688
+
7303
7689
  isNativeShadowDefined: false,
7304
7690
  isSyntheticShadowDefined: false,
7305
7691
 
@@ -7507,18 +7893,18 @@ const renderer = {
7507
7893
  },
7508
7894
 
7509
7895
  setCSSStyleProperty(element, name, value, important) {
7510
- let styleAttribute = element.attributes.find(attr => attr.name === 'style' && isNull(attr.namespace));
7896
+ const styleAttribute = element.attributes.find(attr => attr.name === 'style' && isNull(attr.namespace));
7897
+ const serializedProperty = `${name}: ${value}${important ? ' !important' : ''}`;
7511
7898
 
7512
7899
  if (isUndefined$1(styleAttribute)) {
7513
- styleAttribute = {
7900
+ element.attributes.push({
7514
7901
  name: 'style',
7515
7902
  namespace: null,
7516
- value: ''
7517
- };
7518
- element.attributes.push(styleAttribute);
7903
+ value: serializedProperty
7904
+ });
7905
+ } else {
7906
+ styleAttribute.value += `; ${serializedProperty}`;
7519
7907
  }
7520
-
7521
- styleAttribute.value = `${styleAttribute.value}; ${name}: ${value}${important ? ' !important' : ''}`;
7522
7908
  },
7523
7909
 
7524
7910
  isConnected(node) {
@@ -7699,6 +8085,6 @@ function renderComponent(tagName, Ctor, props = {}) {
7699
8085
 
7700
8086
  freeze(LightningElement);
7701
8087
  seal(LightningElement.prototype);
7702
- /* version: 2.5.5-canary1 */
8088
+ /* version: 2.5.9 */
7703
8089
 
7704
- export { LightningElement, api$1 as api, createContextProvider, getComponentDef, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, renderComponent, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, setHooksForTest, track, unwrap, wire };
8090
+ export { LightningElement, api$1 as api, createContextProvider, getComponentDef, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, renderComponent, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, track, unwrap, wire };