lwc 2.5.8 → 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 (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +141 -80
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +141 -80
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +124 -76
  5. package/dist/engine-dom/iife/es5/engine-dom.js +150 -85
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +133 -81
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +141 -80
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +124 -76
  11. package/dist/engine-dom/umd/es5/engine-dom.js +150 -85
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +133 -81
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +141 -80
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +141 -80
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +8 -8
@@ -123,7 +123,7 @@ var LWC = (function (exports) {
123
123
  ArrayFilter = _Array$prototype.filter,
124
124
  ArrayIndexOf = _Array$prototype.indexOf,
125
125
  ArrayJoin = _Array$prototype.join,
126
- ArrayMap$1 = _Array$prototype.map,
126
+ ArrayMap = _Array$prototype.map,
127
127
  ArrayPush$1 = _Array$prototype.push,
128
128
  ArraySlice = _Array$prototype.slice,
129
129
  ArraySplice = _Array$prototype.splice,
@@ -184,7 +184,7 @@ var LWC = (function (exports) {
184
184
  // Array.prototype.toString directly will cause an error Iterate through
185
185
  // all the items and handle individually.
186
186
  if (isArray$1(obj)) {
187
- return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
187
+ return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
188
188
  }
189
189
 
190
190
  return obj.toString();
@@ -348,7 +348,7 @@ var LWC = (function (exports) {
348
348
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
349
349
  return attributeName;
350
350
  }
351
- /** version: 2.5.8 */
351
+ /** version: 2.5.9 */
352
352
 
353
353
  /*
354
354
  * Copyright (c) 2018, salesforce.com, inc.
@@ -528,7 +528,7 @@ var LWC = (function (exports) {
528
528
  setFeatureFlag(name, value);
529
529
  }
530
530
  }
531
- /** version: 2.5.8 */
531
+ /** version: 2.5.9 */
532
532
 
533
533
  /* proxy-compat-disable */
534
534
 
@@ -1990,7 +1990,10 @@ var LWC = (function (exports) {
1990
1990
  // but it will always be compatible with the previous descriptor
1991
1991
  // to preserve the object invariants, which makes these lines safe.
1992
1992
 
1993
- var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key);
1993
+ var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1994
+
1995
+ /* istanbul ignore else */
1996
+
1994
1997
 
1995
1998
  if (!isUndefined(originalDescriptor)) {
1996
1999
  var wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -2015,12 +2018,18 @@ var LWC = (function (exports) {
2015
2018
 
2016
2019
  _preventExtensions(shadowTarget);
2017
2020
  } // Shared Traps
2021
+ // TODO: apply() is never called
2022
+
2023
+ /* istanbul ignore next */
2018
2024
 
2019
2025
  }, {
2020
2026
  key: "apply",
2021
2027
  value: function apply(shadowTarget, thisArg, argArray) {
2022
2028
  /* No op */
2023
- }
2029
+ } // TODO: construct() is never called
2030
+
2031
+ /* istanbul ignore next */
2032
+
2024
2033
  }, {
2025
2034
  key: "construct",
2026
2035
  value: function construct(shadowTarget, argArray, newTarget) {
@@ -2125,8 +2134,8 @@ var LWC = (function (exports) {
2125
2134
  return BaseProxyHandler;
2126
2135
  }();
2127
2136
 
2128
- var getterMap = new WeakMap();
2129
- var setterMap = new WeakMap();
2137
+ var getterMap$1 = new WeakMap();
2138
+ var setterMap$1 = new WeakMap();
2130
2139
  var reverseGetterMap = new WeakMap();
2131
2140
  var reverseSetterMap = new WeakMap();
2132
2141
 
@@ -2149,7 +2158,7 @@ var LWC = (function (exports) {
2149
2158
  }, {
2150
2159
  key: "wrapGetter",
2151
2160
  value: function wrapGetter(originalGet) {
2152
- var wrappedGetter = getterMap.get(originalGet);
2161
+ var wrappedGetter = getterMap$1.get(originalGet);
2153
2162
 
2154
2163
  if (!isUndefined(wrappedGetter)) {
2155
2164
  return wrappedGetter;
@@ -2162,14 +2171,14 @@ var LWC = (function (exports) {
2162
2171
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2163
2172
  };
2164
2173
 
2165
- getterMap.set(originalGet, get);
2174
+ getterMap$1.set(originalGet, get);
2166
2175
  reverseGetterMap.set(get, originalGet);
2167
2176
  return get;
2168
2177
  }
2169
2178
  }, {
2170
2179
  key: "wrapSetter",
2171
2180
  value: function wrapSetter(originalSet) {
2172
- var wrappedSetter = setterMap.get(originalSet);
2181
+ var wrappedSetter = setterMap$1.get(originalSet);
2173
2182
 
2174
2183
  if (!isUndefined(wrappedSetter)) {
2175
2184
  return wrappedSetter;
@@ -2180,7 +2189,7 @@ var LWC = (function (exports) {
2180
2189
  originalSet.call(unwrap$1(this), unwrap$1(v));
2181
2190
  };
2182
2191
 
2183
- setterMap.set(originalSet, set);
2192
+ setterMap$1.set(originalSet, set);
2184
2193
  reverseSetterMap.set(set, originalSet);
2185
2194
  return set;
2186
2195
  }
@@ -2221,7 +2230,7 @@ var LWC = (function (exports) {
2221
2230
  return unwrap$1(redGet.call(handler.wrapValue(this)));
2222
2231
  };
2223
2232
 
2224
- getterMap.set(get, redGet);
2233
+ getterMap$1.set(get, redGet);
2225
2234
  reverseGetterMap.set(redGet, get);
2226
2235
  return get;
2227
2236
  }
@@ -2241,7 +2250,7 @@ var LWC = (function (exports) {
2241
2250
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
2242
2251
  };
2243
2252
 
2244
- setterMap.set(set, redSet);
2253
+ setterMap$1.set(set, redSet);
2245
2254
  reverseSetterMap.set(redSet, set);
2246
2255
  return set;
2247
2256
  }
@@ -2277,6 +2286,7 @@ var LWC = (function (exports) {
2277
2286
  }, {
2278
2287
  key: "setPrototypeOf",
2279
2288
  value: function setPrototypeOf(shadowTarget, prototype) {
2289
+ /* istanbul ignore else */
2280
2290
  if (process.env.NODE_ENV !== 'production') {
2281
2291
  throw new Error("Invalid setPrototypeOf invocation for reactive proxy ".concat(toString(this.originalTarget), ". Prototype of reactive objects cannot be changed."));
2282
2292
  }
@@ -2290,6 +2300,11 @@ var LWC = (function (exports) {
2290
2300
  _preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
2291
2301
  // the preventExtension call, in which case we should not attempt to lock down
2292
2302
  // the shadow target.
2303
+ // TODO: It should not actually be possible to reach this `if` statement.
2304
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
2305
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
2306
+
2307
+ /* istanbul ignore if */
2293
2308
 
2294
2309
 
2295
2310
  if (_isExtensible(originalTarget)) {
@@ -2332,8 +2347,8 @@ var LWC = (function (exports) {
2332
2347
  return ReactiveProxyHandler;
2333
2348
  }(BaseProxyHandler);
2334
2349
 
2335
- var getterMap$1 = new WeakMap();
2336
- var setterMap$1 = new WeakMap();
2350
+ var getterMap = new WeakMap();
2351
+ var setterMap = new WeakMap();
2337
2352
 
2338
2353
  var ReadOnlyHandler = /*#__PURE__*/function (_BaseProxyHandler2) {
2339
2354
  _inherits(ReadOnlyHandler, _BaseProxyHandler2);
@@ -2354,7 +2369,7 @@ var LWC = (function (exports) {
2354
2369
  }, {
2355
2370
  key: "wrapGetter",
2356
2371
  value: function wrapGetter(originalGet) {
2357
- var wrappedGetter = getterMap$1.get(originalGet);
2372
+ var wrappedGetter = getterMap.get(originalGet);
2358
2373
 
2359
2374
  if (!isUndefined(wrappedGetter)) {
2360
2375
  return wrappedGetter;
@@ -2367,13 +2382,13 @@ var LWC = (function (exports) {
2367
2382
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2368
2383
  };
2369
2384
 
2370
- getterMap$1.set(originalGet, get);
2385
+ getterMap.set(originalGet, get);
2371
2386
  return get;
2372
2387
  }
2373
2388
  }, {
2374
2389
  key: "wrapSetter",
2375
2390
  value: function wrapSetter(originalSet) {
2376
- var wrappedSetter = setterMap$1.get(originalSet);
2391
+ var wrappedSetter = setterMap.get(originalSet);
2377
2392
 
2378
2393
  if (!isUndefined(wrappedSetter)) {
2379
2394
  return wrappedSetter;
@@ -2382,38 +2397,47 @@ var LWC = (function (exports) {
2382
2397
  var handler = this;
2383
2398
 
2384
2399
  var set = function set(v) {
2400
+ /* istanbul ignore else */
2385
2401
  if (process.env.NODE_ENV !== 'production') {
2386
2402
  var originalTarget = handler.originalTarget;
2387
2403
  throw new Error("Invalid mutation: Cannot invoke a setter on \"".concat(originalTarget, "\". \"").concat(originalTarget, "\" is read-only."));
2388
2404
  }
2389
2405
  };
2390
2406
 
2391
- setterMap$1.set(originalSet, set);
2407
+ setterMap.set(originalSet, set);
2392
2408
  return set;
2393
2409
  }
2394
2410
  }, {
2395
2411
  key: "set",
2396
2412
  value: function set(shadowTarget, key, value) {
2413
+ /* istanbul ignore else */
2397
2414
  if (process.env.NODE_ENV !== 'production') {
2398
2415
  var originalTarget = this.originalTarget;
2399
- throw new Error("Invalid mutation: Cannot set \"".concat(key.toString(), "\" on \"").concat(originalTarget, "\". \"").concat(originalTarget, "\" is read-only."));
2416
+ var msg = isArray(originalTarget) ? "Invalid mutation: Cannot mutate array at index ".concat(key.toString(), ". Array is read-only.") : "Invalid mutation: Cannot set \"".concat(key.toString(), "\" on \"").concat(originalTarget, "\". \"").concat(originalTarget, "\" is read-only.");
2417
+ throw new Error(msg);
2400
2418
  }
2419
+ /* istanbul ignore next */
2420
+
2401
2421
 
2402
2422
  return false;
2403
2423
  }
2404
2424
  }, {
2405
2425
  key: "deleteProperty",
2406
2426
  value: function deleteProperty(shadowTarget, key) {
2427
+ /* istanbul ignore else */
2407
2428
  if (process.env.NODE_ENV !== 'production') {
2408
2429
  var originalTarget = this.originalTarget;
2409
2430
  throw new Error("Invalid mutation: Cannot delete \"".concat(key.toString(), "\" on \"").concat(originalTarget, "\". \"").concat(originalTarget, "\" is read-only."));
2410
2431
  }
2432
+ /* istanbul ignore next */
2433
+
2411
2434
 
2412
2435
  return false;
2413
2436
  }
2414
2437
  }, {
2415
2438
  key: "setPrototypeOf",
2416
2439
  value: function setPrototypeOf(shadowTarget, prototype) {
2440
+ /* istanbul ignore else */
2417
2441
  if (process.env.NODE_ENV !== 'production') {
2418
2442
  var originalTarget = this.originalTarget;
2419
2443
  throw new Error("Invalid prototype mutation: Cannot set prototype on \"".concat(originalTarget, "\". \"").concat(originalTarget, "\" prototype is read-only."));
@@ -2422,20 +2446,26 @@ var LWC = (function (exports) {
2422
2446
  }, {
2423
2447
  key: "preventExtensions",
2424
2448
  value: function preventExtensions(shadowTarget) {
2449
+ /* istanbul ignore else */
2425
2450
  if (process.env.NODE_ENV !== 'production') {
2426
2451
  var originalTarget = this.originalTarget;
2427
2452
  throw new Error("Invalid mutation: Cannot preventExtensions on ".concat(originalTarget, "\". \"").concat(originalTarget, " is read-only."));
2428
2453
  }
2454
+ /* istanbul ignore next */
2455
+
2429
2456
 
2430
2457
  return false;
2431
2458
  }
2432
2459
  }, {
2433
2460
  key: "defineProperty",
2434
2461
  value: function defineProperty(shadowTarget, key, descriptor) {
2462
+ /* istanbul ignore else */
2435
2463
  if (process.env.NODE_ENV !== 'production') {
2436
2464
  var originalTarget = this.originalTarget;
2437
2465
  throw new Error("Invalid mutation: Cannot defineProperty \"".concat(key.toString(), "\" on \"").concat(originalTarget, "\". \"").concat(originalTarget, "\" is read-only."));
2438
2466
  }
2467
+ /* istanbul ignore next */
2468
+
2439
2469
 
2440
2470
  return false;
2441
2471
  }
@@ -2495,6 +2525,8 @@ var LWC = (function (exports) {
2495
2525
  }; // Inspired from paulmillr/es6-shim
2496
2526
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2497
2527
 
2528
+ /* istanbul ignore next */
2529
+
2498
2530
  function getGlobal() {
2499
2531
  // the only reliable means to get the global object is `Function('return this')()`
2500
2532
  // However, this causes CSP violations in Chrome apps.
@@ -2519,6 +2551,7 @@ var LWC = (function (exports) {
2519
2551
  }
2520
2552
 
2521
2553
  function init() {
2554
+ /* istanbul ignore if */
2522
2555
  if (process.env.NODE_ENV === 'production') {
2523
2556
  // this method should never leak to prod
2524
2557
  throw new ReferenceError();
@@ -2533,6 +2566,8 @@ var LWC = (function (exports) {
2533
2566
  ArrayPush.call(devtoolsFormatters, formatter);
2534
2567
  global.devtoolsFormatters = devtoolsFormatters;
2535
2568
  }
2569
+ /* istanbul ignore else */
2570
+
2536
2571
 
2537
2572
  if (process.env.NODE_ENV !== 'production') {
2538
2573
  init();
@@ -2584,7 +2619,8 @@ var LWC = (function (exports) {
2584
2619
  this.valueMutated = defaultValueMutated;
2585
2620
  this.valueObserved = defaultValueObserved;
2586
2621
  this.valueIsObservable = defaultValueIsObservable;
2587
- this.objectGraph = new WeakMap();
2622
+ this.readOnlyObjectGraph = new WeakMap();
2623
+ this.reactiveObjectGraph = new WeakMap();
2588
2624
 
2589
2625
  if (!isUndefined(options)) {
2590
2626
  var _valueDistortion = options.valueDistortion,
@@ -2607,10 +2643,13 @@ var LWC = (function (exports) {
2607
2643
  var distorted = this.valueDistortion(unwrappedValue);
2608
2644
 
2609
2645
  if (this.valueIsObservable(distorted)) {
2610
- var o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2611
- // we return the readonly.
2646
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2647
+ // when trying to extract the writable version of a readonly
2648
+ // we return the readonly.
2649
+ return value;
2650
+ }
2612
2651
 
2613
- return o.readOnly === value ? value : o.reactive;
2652
+ return this.getReactiveHandler(unwrappedValue, distorted);
2614
2653
  }
2615
2654
 
2616
2655
  return distorted;
@@ -2622,7 +2661,7 @@ var LWC = (function (exports) {
2622
2661
  var distorted = this.valueDistortion(value);
2623
2662
 
2624
2663
  if (this.valueIsObservable(distorted)) {
2625
- return this.getReactiveState(value, distorted).readOnly;
2664
+ return this.getReadOnlyHandler(value, distorted);
2626
2665
  }
2627
2666
 
2628
2667
  return distorted;
@@ -2633,48 +2672,40 @@ var LWC = (function (exports) {
2633
2672
  return unwrap$1(p);
2634
2673
  }
2635
2674
  }, {
2636
- key: "getReactiveState",
2637
- value: function getReactiveState(value, distortedValue) {
2638
- var objectGraph = this.objectGraph;
2639
- var reactiveState = objectGraph.get(distortedValue);
2640
-
2641
- if (reactiveState) {
2642
- return reactiveState;
2675
+ key: "getReactiveHandler",
2676
+ value: function getReactiveHandler(value, distortedValue) {
2677
+ var proxy = this.reactiveObjectGraph.get(distortedValue);
2678
+
2679
+ if (isUndefined(proxy)) {
2680
+ // caching the proxy after the first time it is accessed
2681
+ var handler = new ReactiveProxyHandler(this, distortedValue);
2682
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2683
+ registerProxy(proxy, value);
2684
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2643
2685
  }
2644
2686
 
2645
- var membrane = this;
2646
- reactiveState = {
2647
- get reactive() {
2648
- var reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2649
-
2650
- var proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2651
- registerProxy(proxy, value);
2652
- ObjectDefineProperty(this, 'reactive', {
2653
- value: proxy
2654
- });
2655
- return proxy;
2656
- },
2657
-
2658
- get readOnly() {
2659
- var readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2660
-
2661
- var proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2662
- registerProxy(proxy, value);
2663
- ObjectDefineProperty(this, 'readOnly', {
2664
- value: proxy
2665
- });
2666
- return proxy;
2667
- }
2687
+ return proxy;
2688
+ }
2689
+ }, {
2690
+ key: "getReadOnlyHandler",
2691
+ value: function getReadOnlyHandler(value, distortedValue) {
2692
+ var proxy = this.readOnlyObjectGraph.get(distortedValue);
2693
+
2694
+ if (isUndefined(proxy)) {
2695
+ // caching the proxy after the first time it is accessed
2696
+ var handler = new ReadOnlyHandler(this, distortedValue);
2697
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2698
+ registerProxy(proxy, value);
2699
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2700
+ }
2668
2701
 
2669
- };
2670
- objectGraph.set(distortedValue, reactiveState);
2671
- return reactiveState;
2702
+ return proxy;
2672
2703
  }
2673
2704
  }]);
2674
2705
 
2675
2706
  return ReactiveMembrane;
2676
2707
  }();
2677
- /** version: 1.0.0 */
2708
+ /** version: 1.1.5 */
2678
2709
 
2679
2710
  /*
2680
2711
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4735,7 +4766,7 @@ var LWC = (function (exports) {
4735
4766
 
4736
4767
  var elmAttrValue = renderer.getAttribute(elm, attrName);
4737
4768
 
4738
- if (attrValue !== elmAttrValue) {
4769
+ if (String(attrValue) !== elmAttrValue) {
4739
4770
  logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), vnode.owner);
4740
4771
  nodesAreCompatible = false;
4741
4772
  }
@@ -4752,7 +4783,7 @@ var LWC = (function (exports) {
4752
4783
  var nodesAreCompatible = true;
4753
4784
  var vnodeClassName;
4754
4785
 
4755
- if (!isUndefined$1(className) && className !== elm.className) {
4786
+ if (!isUndefined$1(className) && String(className) !== elm.className) {
4756
4787
  // className is used when class is bound to an expr.
4757
4788
  nodesAreCompatible = false;
4758
4789
  vnodeClassName = className;
@@ -5530,7 +5561,7 @@ var LWC = (function (exports) {
5530
5561
 
5531
5562
 
5532
5563
  function d(value) {
5533
- return value == null ? '' : value;
5564
+ return value == null ? '' : String(value);
5534
5565
  } // [b]ind function
5535
5566
 
5536
5567
 
@@ -5811,6 +5842,7 @@ var LWC = (function (exports) {
5811
5842
 
5812
5843
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5813
5844
  var content = [];
5845
+ var root;
5814
5846
 
5815
5847
  for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5816
5848
  var stylesheet = stylesheets[_i16];
@@ -5823,23 +5855,46 @@ var LWC = (function (exports) {
5823
5855
  // the component instance might be attempting to use an old version of
5824
5856
  // the stylesheet, while internally, we have a replacement for it.
5825
5857
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5826
- } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5827
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5858
+ }
5828
5859
 
5860
+ var isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5861
+
5862
+ var scopeToken = isScopedCss || vm.shadowMode === 1
5863
+ /* Synthetic */
5864
+ && vm.renderMode === 1
5865
+ /* Shadow */
5866
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5867
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5829
5868
 
5830
- var isScopedCss = stylesheet[KEY__SCOPED_CSS];
5831
5869
  var useActualHostSelector = vm.renderMode === 0
5832
5870
  /* Light */
5833
5871
  ? !isScopedCss : vm.shadowMode === 0
5834
5872
  /* Native */
5835
- ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5873
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5874
+ // we use an attribute selector on the host to simulate :dir().
5836
5875
 
5837
- var scopeToken = isScopedCss || vm.shadowMode === 1
5838
- /* Synthetic */
5839
- && vm.renderMode === 1
5876
+ var useNativeDirPseudoclass = void 0;
5877
+
5878
+ if (vm.renderMode === 1
5840
5879
  /* Shadow */
5841
- ? stylesheetToken : undefined;
5842
- ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
5880
+ ) {
5881
+ useNativeDirPseudoclass = vm.shadowMode === 0
5882
+ /* Native */
5883
+ ;
5884
+ } else {
5885
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
5886
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
5887
+ if (isUndefined$1(root)) {
5888
+ // Only calculate the root once as necessary
5889
+ root = getNearestShadowComponent(vm);
5890
+ }
5891
+
5892
+ useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
5893
+ /* Native */
5894
+ ;
5895
+ }
5896
+
5897
+ ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5843
5898
  }
5844
5899
  }
5845
5900
 
@@ -5861,14 +5916,12 @@ var LWC = (function (exports) {
5861
5916
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5862
5917
 
5863
5918
 
5864
- function getNearestNativeShadowComponent(vm) {
5919
+ function getNearestShadowComponent(vm) {
5865
5920
  var owner = vm;
5866
5921
 
5867
5922
  while (!isNull(owner)) {
5868
5923
  if (owner.renderMode === 1
5869
5924
  /* Shadow */
5870
- && owner.shadowMode === 0
5871
- /* Native */
5872
5925
  ) {
5873
5926
  return owner;
5874
5927
  }
@@ -5879,6 +5932,20 @@ var LWC = (function (exports) {
5879
5932
  return owner;
5880
5933
  }
5881
5934
 
5935
+ function getNearestNativeShadowComponent(vm) {
5936
+ var owner = getNearestShadowComponent(vm);
5937
+
5938
+ if (!isNull(owner) && owner.shadowMode === 1
5939
+ /* Synthetic */
5940
+ ) {
5941
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
5942
+ // synthetic, we know we won't find a native component if we go any further.
5943
+ return null;
5944
+ }
5945
+
5946
+ return owner;
5947
+ }
5948
+
5882
5949
  function createStylesheet(vm, stylesheets) {
5883
5950
  var renderer = vm.renderer,
5884
5951
  renderMode = vm.renderMode,
@@ -5892,7 +5959,7 @@ var LWC = (function (exports) {
5892
5959
  for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5893
5960
  renderer.insertGlobalStylesheet(stylesheets[_i17]);
5894
5961
  }
5895
- } else if (renderer.ssr || renderer.isHydrating) {
5962
+ } else if (renderer.ssr || renderer.isHydrating()) {
5896
5963
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
5897
5964
  // This works in the client, because the stylesheets are created, and cached in the VM
5898
5965
  // the first time the VM renders.
@@ -7548,7 +7615,7 @@ var LWC = (function (exports) {
7548
7615
  hooksAreSet = true;
7549
7616
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7550
7617
  }
7551
- /* version: 2.5.8 */
7618
+ /* version: 2.5.9 */
7552
7619
 
7553
7620
  /*
7554
7621
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7703,19 +7770,17 @@ var LWC = (function (exports) {
7703
7770
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7704
7771
  }
7705
7772
 
7706
- var isHydrating = false;
7773
+ var _isHydrating = false;
7707
7774
 
7708
7775
  function setIsHydrating(v) {
7709
- isHydrating = v;
7776
+ _isHydrating = v;
7710
7777
  }
7711
7778
 
7712
7779
  var renderer = {
7713
7780
  ssr: false,
7714
-
7715
- get isHydrating() {
7716
- return isHydrating;
7781
+ isHydrating: function isHydrating() {
7782
+ return _isHydrating;
7717
7783
  },
7718
-
7719
7784
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
7720
7785
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
7721
7786
  createElement: function createElement(tagName, namespace) {
@@ -7737,7 +7802,7 @@ var LWC = (function (exports) {
7737
7802
  return node.nextSibling;
7738
7803
  },
7739
7804
  attachShadow: function attachShadow(element, options) {
7740
- if (isHydrating) {
7805
+ if (_isHydrating) {
7741
7806
  return element.shadowRoot;
7742
7807
  }
7743
7808
 
@@ -8203,7 +8268,7 @@ var LWC = (function (exports) {
8203
8268
  });
8204
8269
  freeze(LightningElement);
8205
8270
  seal(LightningElement.prototype);
8206
- /* version: 2.5.8 */
8271
+ /* version: 2.5.9 */
8207
8272
 
8208
8273
  exports.LightningElement = LightningElement;
8209
8274
  exports.__unstable__ProfilerControl = profilerControl;