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
@@ -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();
@@ -299,7 +299,7 @@ function htmlPropertyToAttribute(propName) {
299
299
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
300
300
  return attributeName;
301
301
  }
302
- /** version: 2.5.8 */
302
+ /** version: 2.5.9 */
303
303
 
304
304
  /*
305
305
  * Copyright (c) 2018, salesforce.com, inc.
@@ -479,7 +479,7 @@ function setFeatureFlagForTest(name, value) {
479
479
  setFeatureFlag(name, value);
480
480
  }
481
481
  }
482
- /** version: 2.5.8 */
482
+ /** version: 2.5.9 */
483
483
 
484
484
  /* proxy-compat-disable */
485
485
 
@@ -1929,7 +1929,6 @@ const {
1929
1929
  getPrototypeOf,
1930
1930
  create: ObjectCreate,
1931
1931
  defineProperty: ObjectDefineProperty,
1932
- defineProperties: ObjectDefineProperties,
1933
1932
  isExtensible,
1934
1933
  getOwnPropertyDescriptor,
1935
1934
  getOwnPropertyNames,
@@ -1939,8 +1938,7 @@ const {
1939
1938
  } = Object;
1940
1939
  const {
1941
1940
  push: ArrayPush,
1942
- concat: ArrayConcat,
1943
- map: ArrayMap
1941
+ concat: ArrayConcat
1944
1942
  } = Array.prototype;
1945
1943
  const OtS = {}.toString;
1946
1944
 
@@ -2005,7 +2003,9 @@ class BaseProxyHandler {
2005
2003
  // but it will always be compatible with the previous descriptor
2006
2004
  // to preserve the object invariants, which makes these lines safe.
2007
2005
 
2008
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
2006
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
2007
+
2008
+ /* istanbul ignore else */
2009
2009
 
2010
2010
  if (!isUndefined(originalDescriptor)) {
2011
2011
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -2033,11 +2033,17 @@ class BaseProxyHandler {
2033
2033
 
2034
2034
  preventExtensions(shadowTarget);
2035
2035
  } // Shared Traps
2036
+ // TODO: apply() is never called
2037
+
2038
+ /* istanbul ignore next */
2036
2039
 
2037
2040
 
2038
2041
  apply(shadowTarget, thisArg, argArray) {
2039
2042
  /* No op */
2040
- }
2043
+ } // TODO: construct() is never called
2044
+
2045
+ /* istanbul ignore next */
2046
+
2041
2047
 
2042
2048
  construct(shadowTarget, argArray, newTarget) {
2043
2049
  /* No op */
@@ -2150,8 +2156,8 @@ class BaseProxyHandler {
2150
2156
 
2151
2157
  }
2152
2158
 
2153
- const getterMap = new WeakMap();
2154
- const setterMap = new WeakMap();
2159
+ const getterMap$1 = new WeakMap();
2160
+ const setterMap$1 = new WeakMap();
2155
2161
  const reverseGetterMap = new WeakMap();
2156
2162
  const reverseSetterMap = new WeakMap();
2157
2163
 
@@ -2161,7 +2167,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2161
2167
  }
2162
2168
 
2163
2169
  wrapGetter(originalGet) {
2164
- const wrappedGetter = getterMap.get(originalGet);
2170
+ const wrappedGetter = getterMap$1.get(originalGet);
2165
2171
 
2166
2172
  if (!isUndefined(wrappedGetter)) {
2167
2173
  return wrappedGetter;
@@ -2174,13 +2180,13 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2174
2180
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2175
2181
  };
2176
2182
 
2177
- getterMap.set(originalGet, get);
2183
+ getterMap$1.set(originalGet, get);
2178
2184
  reverseGetterMap.set(get, originalGet);
2179
2185
  return get;
2180
2186
  }
2181
2187
 
2182
2188
  wrapSetter(originalSet) {
2183
- const wrappedSetter = setterMap.get(originalSet);
2189
+ const wrappedSetter = setterMap$1.get(originalSet);
2184
2190
 
2185
2191
  if (!isUndefined(wrappedSetter)) {
2186
2192
  return wrappedSetter;
@@ -2191,7 +2197,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2191
2197
  originalSet.call(unwrap$1(this), unwrap$1(v));
2192
2198
  };
2193
2199
 
2194
- setterMap.set(originalSet, set);
2200
+ setterMap$1.set(originalSet, set);
2195
2201
  reverseSetterMap.set(set, originalSet);
2196
2202
  return set;
2197
2203
  }
@@ -2232,7 +2238,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2232
2238
  return unwrap$1(redGet.call(handler.wrapValue(this)));
2233
2239
  };
2234
2240
 
2235
- getterMap.set(get, redGet);
2241
+ getterMap$1.set(get, redGet);
2236
2242
  reverseGetterMap.set(redGet, get);
2237
2243
  return get;
2238
2244
  }
@@ -2251,7 +2257,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2251
2257
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
2252
2258
  };
2253
2259
 
2254
- setterMap.set(set, redSet);
2260
+ setterMap$1.set(set, redSet);
2255
2261
  reverseSetterMap.set(redSet, set);
2256
2262
  return set;
2257
2263
  }
@@ -2292,6 +2298,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2292
2298
  }
2293
2299
 
2294
2300
  setPrototypeOf(shadowTarget, prototype) {
2301
+ /* istanbul ignore else */
2295
2302
  if (process.env.NODE_ENV !== 'production') {
2296
2303
  throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
2297
2304
  }
@@ -2305,6 +2312,11 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2305
2312
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
2306
2313
  // the preventExtension call, in which case we should not attempt to lock down
2307
2314
  // the shadow target.
2315
+ // TODO: It should not actually be possible to reach this `if` statement.
2316
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
2317
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
2318
+
2319
+ /* istanbul ignore if */
2308
2320
 
2309
2321
  if (isExtensible(originalTarget)) {
2310
2322
  return false;
@@ -2346,8 +2358,8 @@ class ReactiveProxyHandler extends BaseProxyHandler {
2346
2358
 
2347
2359
  }
2348
2360
 
2349
- const getterMap$1 = new WeakMap();
2350
- const setterMap$1 = new WeakMap();
2361
+ const getterMap = new WeakMap();
2362
+ const setterMap = new WeakMap();
2351
2363
 
2352
2364
  class ReadOnlyHandler extends BaseProxyHandler {
2353
2365
  wrapValue(value) {
@@ -2355,7 +2367,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
2355
2367
  }
2356
2368
 
2357
2369
  wrapGetter(originalGet) {
2358
- const wrappedGetter = getterMap$1.get(originalGet);
2370
+ const wrappedGetter = getterMap.get(originalGet);
2359
2371
 
2360
2372
  if (!isUndefined(wrappedGetter)) {
2361
2373
  return wrappedGetter;
@@ -2368,12 +2380,12 @@ class ReadOnlyHandler extends BaseProxyHandler {
2368
2380
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2369
2381
  };
2370
2382
 
2371
- getterMap$1.set(originalGet, get);
2383
+ getterMap.set(originalGet, get);
2372
2384
  return get;
2373
2385
  }
2374
2386
 
2375
2387
  wrapSetter(originalSet) {
2376
- const wrappedSetter = setterMap$1.get(originalSet);
2388
+ const wrappedSetter = setterMap.get(originalSet);
2377
2389
 
2378
2390
  if (!isUndefined(wrappedSetter)) {
2379
2391
  return wrappedSetter;
@@ -2382,6 +2394,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
2382
2394
  const handler = this;
2383
2395
 
2384
2396
  const set = function (v) {
2397
+ /* istanbul ignore else */
2385
2398
  if (process.env.NODE_ENV !== 'production') {
2386
2399
  const {
2387
2400
  originalTarget
@@ -2390,33 +2403,41 @@ class ReadOnlyHandler extends BaseProxyHandler {
2390
2403
  }
2391
2404
  };
2392
2405
 
2393
- setterMap$1.set(originalSet, set);
2406
+ setterMap.set(originalSet, set);
2394
2407
  return set;
2395
2408
  }
2396
2409
 
2397
2410
  set(shadowTarget, key, value) {
2411
+ /* istanbul ignore else */
2398
2412
  if (process.env.NODE_ENV !== 'production') {
2399
2413
  const {
2400
2414
  originalTarget
2401
2415
  } = this;
2402
- throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2416
+ 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.`;
2417
+ throw new Error(msg);
2403
2418
  }
2419
+ /* istanbul ignore next */
2420
+
2404
2421
 
2405
2422
  return false;
2406
2423
  }
2407
2424
 
2408
2425
  deleteProperty(shadowTarget, key) {
2426
+ /* istanbul ignore else */
2409
2427
  if (process.env.NODE_ENV !== 'production') {
2410
2428
  const {
2411
2429
  originalTarget
2412
2430
  } = this;
2413
2431
  throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2414
2432
  }
2433
+ /* istanbul ignore next */
2434
+
2415
2435
 
2416
2436
  return false;
2417
2437
  }
2418
2438
 
2419
2439
  setPrototypeOf(shadowTarget, prototype) {
2440
+ /* istanbul ignore else */
2420
2441
  if (process.env.NODE_ENV !== 'production') {
2421
2442
  const {
2422
2443
  originalTarget
@@ -2426,23 +2447,29 @@ class ReadOnlyHandler extends BaseProxyHandler {
2426
2447
  }
2427
2448
 
2428
2449
  preventExtensions(shadowTarget) {
2450
+ /* istanbul ignore else */
2429
2451
  if (process.env.NODE_ENV !== 'production') {
2430
2452
  const {
2431
2453
  originalTarget
2432
2454
  } = this;
2433
2455
  throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
2434
2456
  }
2457
+ /* istanbul ignore next */
2458
+
2435
2459
 
2436
2460
  return false;
2437
2461
  }
2438
2462
 
2439
2463
  defineProperty(shadowTarget, key, descriptor) {
2464
+ /* istanbul ignore else */
2440
2465
  if (process.env.NODE_ENV !== 'production') {
2441
2466
  const {
2442
2467
  originalTarget
2443
2468
  } = this;
2444
2469
  throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
2445
2470
  }
2471
+ /* istanbul ignore next */
2472
+
2446
2473
 
2447
2474
  return false;
2448
2475
  }
@@ -2500,6 +2527,8 @@ const formatter = {
2500
2527
  }; // Inspired from paulmillr/es6-shim
2501
2528
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2502
2529
 
2530
+ /* istanbul ignore next */
2531
+
2503
2532
  function getGlobal() {
2504
2533
  // the only reliable means to get the global object is `Function('return this')()`
2505
2534
  // However, this causes CSP violations in Chrome apps.
@@ -2524,6 +2553,7 @@ function getGlobal() {
2524
2553
  }
2525
2554
 
2526
2555
  function init() {
2556
+ /* istanbul ignore if */
2527
2557
  if (process.env.NODE_ENV === 'production') {
2528
2558
  // this method should never leak to prod
2529
2559
  throw new ReferenceError();
@@ -2538,6 +2568,8 @@ function init() {
2538
2568
  ArrayPush.call(devtoolsFormatters, formatter);
2539
2569
  global.devtoolsFormatters = devtoolsFormatters;
2540
2570
  }
2571
+ /* istanbul ignore else */
2572
+
2541
2573
 
2542
2574
  if (process.env.NODE_ENV !== 'production') {
2543
2575
  init();
@@ -2584,7 +2616,8 @@ class ReactiveMembrane {
2584
2616
  this.valueMutated = defaultValueMutated;
2585
2617
  this.valueObserved = defaultValueObserved;
2586
2618
  this.valueIsObservable = defaultValueIsObservable;
2587
- this.objectGraph = new WeakMap();
2619
+ this.readOnlyObjectGraph = new WeakMap();
2620
+ this.reactiveObjectGraph = new WeakMap();
2588
2621
 
2589
2622
  if (!isUndefined(options)) {
2590
2623
  const {
@@ -2607,10 +2640,13 @@ class ReactiveMembrane {
2607
2640
  const distorted = this.valueDistortion(unwrappedValue);
2608
2641
 
2609
2642
  if (this.valueIsObservable(distorted)) {
2610
- const o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2611
- // we return the readonly.
2643
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2644
+ // when trying to extract the writable version of a readonly
2645
+ // we return the readonly.
2646
+ return value;
2647
+ }
2612
2648
 
2613
- return o.readOnly === value ? value : o.reactive;
2649
+ return this.getReactiveHandler(unwrappedValue, distorted);
2614
2650
  }
2615
2651
 
2616
2652
  return distorted;
@@ -2621,7 +2657,7 @@ class ReactiveMembrane {
2621
2657
  const distorted = this.valueDistortion(value);
2622
2658
 
2623
2659
  if (this.valueIsObservable(distorted)) {
2624
- return this.getReactiveState(value, distorted).readOnly;
2660
+ return this.getReadOnlyHandler(value, distorted);
2625
2661
  }
2626
2662
 
2627
2663
  return distorted;
@@ -2631,47 +2667,36 @@ class ReactiveMembrane {
2631
2667
  return unwrap$1(p);
2632
2668
  }
2633
2669
 
2634
- getReactiveState(value, distortedValue) {
2635
- const {
2636
- objectGraph
2637
- } = this;
2638
- let reactiveState = objectGraph.get(distortedValue);
2670
+ getReactiveHandler(value, distortedValue) {
2671
+ let proxy = this.reactiveObjectGraph.get(distortedValue);
2639
2672
 
2640
- if (reactiveState) {
2641
- return reactiveState;
2673
+ if (isUndefined(proxy)) {
2674
+ // caching the proxy after the first time it is accessed
2675
+ const handler = new ReactiveProxyHandler(this, distortedValue);
2676
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2677
+ registerProxy(proxy, value);
2678
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2642
2679
  }
2643
2680
 
2644
- const membrane = this;
2645
- reactiveState = {
2646
- get reactive() {
2647
- const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2648
-
2649
- const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2650
- registerProxy(proxy, value);
2651
- ObjectDefineProperty(this, 'reactive', {
2652
- value: proxy
2653
- });
2654
- return proxy;
2655
- },
2681
+ return proxy;
2682
+ }
2656
2683
 
2657
- get readOnly() {
2658
- const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2684
+ getReadOnlyHandler(value, distortedValue) {
2685
+ let proxy = this.readOnlyObjectGraph.get(distortedValue);
2659
2686
 
2660
- const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2661
- registerProxy(proxy, value);
2662
- ObjectDefineProperty(this, 'readOnly', {
2663
- value: proxy
2664
- });
2665
- return proxy;
2666
- }
2687
+ if (isUndefined(proxy)) {
2688
+ // caching the proxy after the first time it is accessed
2689
+ const handler = new ReadOnlyHandler(this, distortedValue);
2690
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2691
+ registerProxy(proxy, value);
2692
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2693
+ }
2667
2694
 
2668
- };
2669
- objectGraph.set(distortedValue, reactiveState);
2670
- return reactiveState;
2695
+ return proxy;
2671
2696
  }
2672
2697
 
2673
2698
  }
2674
- /** version: 1.0.0 */
2699
+ /** version: 1.1.5 */
2675
2700
 
2676
2701
  /*
2677
2702
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4823,7 +4848,7 @@ function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4823
4848
  for (const [attrName, attrValue] of Object.entries(attrs)) {
4824
4849
  const elmAttrValue = renderer.getAttribute(elm, attrName);
4825
4850
 
4826
- if (attrValue !== elmAttrValue) {
4851
+ if (String(attrValue) !== elmAttrValue) {
4827
4852
  logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
4828
4853
  nodesAreCompatible = false;
4829
4854
  }
@@ -4845,7 +4870,7 @@ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4845
4870
  let nodesAreCompatible = true;
4846
4871
  let vnodeClassName;
4847
4872
 
4848
- if (!isUndefined$1(className) && className !== elm.className) {
4873
+ if (!isUndefined$1(className) && String(className) !== elm.className) {
4849
4874
  // className is used when class is bound to an expr.
4850
4875
  nodesAreCompatible = false;
4851
4876
  vnodeClassName = className;
@@ -5646,7 +5671,7 @@ function co(text) {
5646
5671
 
5647
5672
 
5648
5673
  function d(value) {
5649
- return value == null ? '' : value;
5674
+ return value == null ? '' : String(value);
5650
5675
  } // [b]ind function
5651
5676
 
5652
5677
 
@@ -5937,6 +5962,7 @@ function updateStylesheetToken(vm, template) {
5937
5962
 
5938
5963
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5939
5964
  const content = [];
5965
+ let root;
5940
5966
 
5941
5967
  for (let i = 0; i < stylesheets.length; i++) {
5942
5968
  let stylesheet = stylesheets[i];
@@ -5949,23 +5975,46 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5949
5975
  // the component instance might be attempting to use an old version of
5950
5976
  // the stylesheet, while internally, we have a replacement for it.
5951
5977
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5952
- } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5953
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5978
+ }
5954
5979
 
5980
+ const isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5981
+
5982
+ const scopeToken = isScopedCss || vm.shadowMode === 1
5983
+ /* Synthetic */
5984
+ && vm.renderMode === 1
5985
+ /* Shadow */
5986
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5987
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5955
5988
 
5956
- const isScopedCss = stylesheet[KEY__SCOPED_CSS];
5957
5989
  const useActualHostSelector = vm.renderMode === 0
5958
5990
  /* Light */
5959
5991
  ? !isScopedCss : vm.shadowMode === 0
5960
5992
  /* Native */
5961
- ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5993
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5994
+ // we use an attribute selector on the host to simulate :dir().
5962
5995
 
5963
- const scopeToken = isScopedCss || vm.shadowMode === 1
5964
- /* Synthetic */
5965
- && vm.renderMode === 1
5996
+ let useNativeDirPseudoclass;
5997
+
5998
+ if (vm.renderMode === 1
5966
5999
  /* Shadow */
5967
- ? stylesheetToken : undefined;
5968
- ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
6000
+ ) {
6001
+ useNativeDirPseudoclass = vm.shadowMode === 0
6002
+ /* Native */
6003
+ ;
6004
+ } else {
6005
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
6006
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
6007
+ if (isUndefined$1(root)) {
6008
+ // Only calculate the root once as necessary
6009
+ root = getNearestShadowComponent(vm);
6010
+ }
6011
+
6012
+ useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
6013
+ /* Native */
6014
+ ;
6015
+ }
6016
+
6017
+ ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5969
6018
  }
5970
6019
  }
5971
6020
 
@@ -5989,14 +6038,12 @@ function getStylesheetsContent(vm, template) {
5989
6038
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5990
6039
 
5991
6040
 
5992
- function getNearestNativeShadowComponent(vm) {
6041
+ function getNearestShadowComponent(vm) {
5993
6042
  let owner = vm;
5994
6043
 
5995
6044
  while (!isNull(owner)) {
5996
6045
  if (owner.renderMode === 1
5997
6046
  /* Shadow */
5998
- && owner.shadowMode === 0
5999
- /* Native */
6000
6047
  ) {
6001
6048
  return owner;
6002
6049
  }
@@ -6007,6 +6054,20 @@ function getNearestNativeShadowComponent(vm) {
6007
6054
  return owner;
6008
6055
  }
6009
6056
 
6057
+ function getNearestNativeShadowComponent(vm) {
6058
+ const owner = getNearestShadowComponent(vm);
6059
+
6060
+ if (!isNull(owner) && owner.shadowMode === 1
6061
+ /* Synthetic */
6062
+ ) {
6063
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
6064
+ // synthetic, we know we won't find a native component if we go any further.
6065
+ return null;
6066
+ }
6067
+
6068
+ return owner;
6069
+ }
6070
+
6010
6071
  function createStylesheet(vm, stylesheets) {
6011
6072
  const {
6012
6073
  renderer,
@@ -6022,7 +6083,7 @@ function createStylesheet(vm, stylesheets) {
6022
6083
  for (let i = 0; i < stylesheets.length; i++) {
6023
6084
  renderer.insertGlobalStylesheet(stylesheets[i]);
6024
6085
  }
6025
- } else if (renderer.ssr || renderer.isHydrating) {
6086
+ } else if (renderer.ssr || renderer.isHydrating()) {
6026
6087
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
6027
6088
  // This works in the client, because the stylesheets are created, and cached in the VM
6028
6089
  // the first time the VM renders.
@@ -7747,7 +7808,7 @@ function setHooks(hooks) {
7747
7808
  hooksAreSet = true;
7748
7809
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7749
7810
  }
7750
- /* version: 2.5.8 */
7811
+ /* version: 2.5.9 */
7751
7812
 
7752
7813
  /*
7753
7814
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7900,7 +7961,7 @@ function setIsHydrating(v) {
7900
7961
  const renderer = {
7901
7962
  ssr: false,
7902
7963
 
7903
- get isHydrating() {
7964
+ isHydrating() {
7904
7965
  return isHydrating;
7905
7966
  },
7906
7967
 
@@ -8403,6 +8464,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
8403
8464
  });
8404
8465
  freeze(LightningElement);
8405
8466
  seal(LightningElement.prototype);
8406
- /* version: 2.5.8 */
8467
+ /* version: 2.5.9 */
8407
8468
 
8408
8469
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };