@lwc/engine-core 2.5.10-alpha1 → 2.7.0

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.
@@ -1428,10 +1428,10 @@ const {
1428
1428
  isArray
1429
1429
  } = Array;
1430
1430
  const {
1431
+ prototype: ObjectDotPrototype,
1431
1432
  getPrototypeOf,
1432
1433
  create: ObjectCreate,
1433
1434
  defineProperty: ObjectDefineProperty,
1434
- defineProperties: ObjectDefineProperties,
1435
1435
  isExtensible,
1436
1436
  getOwnPropertyDescriptor,
1437
1437
  getOwnPropertyNames,
@@ -1441,8 +1441,7 @@ const {
1441
1441
  } = Object;
1442
1442
  const {
1443
1443
  push: ArrayPush,
1444
- concat: ArrayConcat,
1445
- map: ArrayMap
1444
+ concat: ArrayConcat
1446
1445
  } = Array.prototype;
1447
1446
  const OtS = {}.toString;
1448
1447
 
@@ -1507,7 +1506,9 @@ class BaseProxyHandler {
1507
1506
  // but it will always be compatible with the previous descriptor
1508
1507
  // to preserve the object invariants, which makes these lines safe.
1509
1508
 
1510
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
1509
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1510
+
1511
+ /* istanbul ignore else */
1511
1512
 
1512
1513
  if (!isUndefined(originalDescriptor)) {
1513
1514
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1535,11 +1536,17 @@ class BaseProxyHandler {
1535
1536
 
1536
1537
  preventExtensions(shadowTarget);
1537
1538
  } // Shared Traps
1539
+ // TODO: apply() is never called
1540
+
1541
+ /* istanbul ignore next */
1538
1542
 
1539
1543
 
1540
1544
  apply(shadowTarget, thisArg, argArray) {
1541
1545
  /* No op */
1542
- }
1546
+ } // TODO: construct() is never called
1547
+
1548
+ /* istanbul ignore next */
1549
+
1543
1550
 
1544
1551
  construct(shadowTarget, argArray, newTarget) {
1545
1552
  /* No op */
@@ -1652,8 +1659,8 @@ class BaseProxyHandler {
1652
1659
 
1653
1660
  }
1654
1661
 
1655
- const getterMap = new WeakMap();
1656
- const setterMap = new WeakMap();
1662
+ const getterMap$1 = new WeakMap();
1663
+ const setterMap$1 = new WeakMap();
1657
1664
  const reverseGetterMap = new WeakMap();
1658
1665
  const reverseSetterMap = new WeakMap();
1659
1666
 
@@ -1663,7 +1670,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1663
1670
  }
1664
1671
 
1665
1672
  wrapGetter(originalGet) {
1666
- const wrappedGetter = getterMap.get(originalGet);
1673
+ const wrappedGetter = getterMap$1.get(originalGet);
1667
1674
 
1668
1675
  if (!isUndefined(wrappedGetter)) {
1669
1676
  return wrappedGetter;
@@ -1676,13 +1683,13 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1676
1683
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1677
1684
  };
1678
1685
 
1679
- getterMap.set(originalGet, get);
1686
+ getterMap$1.set(originalGet, get);
1680
1687
  reverseGetterMap.set(get, originalGet);
1681
1688
  return get;
1682
1689
  }
1683
1690
 
1684
1691
  wrapSetter(originalSet) {
1685
- const wrappedSetter = setterMap.get(originalSet);
1692
+ const wrappedSetter = setterMap$1.get(originalSet);
1686
1693
 
1687
1694
  if (!isUndefined(wrappedSetter)) {
1688
1695
  return wrappedSetter;
@@ -1693,7 +1700,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1693
1700
  originalSet.call(unwrap$1(this), unwrap$1(v));
1694
1701
  };
1695
1702
 
1696
- setterMap.set(originalSet, set);
1703
+ setterMap$1.set(originalSet, set);
1697
1704
  reverseSetterMap.set(set, originalSet);
1698
1705
  return set;
1699
1706
  }
@@ -1734,7 +1741,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1734
1741
  return unwrap$1(redGet.call(handler.wrapValue(this)));
1735
1742
  };
1736
1743
 
1737
- getterMap.set(get, redGet);
1744
+ getterMap$1.set(get, redGet);
1738
1745
  reverseGetterMap.set(redGet, get);
1739
1746
  return get;
1740
1747
  }
@@ -1753,7 +1760,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1753
1760
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
1754
1761
  };
1755
1762
 
1756
- setterMap.set(set, redSet);
1763
+ setterMap$1.set(set, redSet);
1757
1764
  reverseSetterMap.set(redSet, set);
1758
1765
  return set;
1759
1766
  }
@@ -1794,6 +1801,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1794
1801
  }
1795
1802
 
1796
1803
  setPrototypeOf(shadowTarget, prototype) {
1804
+ /* istanbul ignore else */
1797
1805
  if (process.env.NODE_ENV !== 'production') {
1798
1806
  throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
1799
1807
  }
@@ -1807,6 +1815,11 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1807
1815
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
1808
1816
  // the preventExtension call, in which case we should not attempt to lock down
1809
1817
  // the shadow target.
1818
+ // TODO: It should not actually be possible to reach this `if` statement.
1819
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
1820
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
1821
+
1822
+ /* istanbul ignore if */
1810
1823
 
1811
1824
  if (isExtensible(originalTarget)) {
1812
1825
  return false;
@@ -1848,8 +1861,8 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1848
1861
 
1849
1862
  }
1850
1863
 
1851
- const getterMap$1 = new WeakMap();
1852
- const setterMap$1 = new WeakMap();
1864
+ const getterMap = new WeakMap();
1865
+ const setterMap = new WeakMap();
1853
1866
 
1854
1867
  class ReadOnlyHandler extends BaseProxyHandler {
1855
1868
  wrapValue(value) {
@@ -1857,7 +1870,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
1857
1870
  }
1858
1871
 
1859
1872
  wrapGetter(originalGet) {
1860
- const wrappedGetter = getterMap$1.get(originalGet);
1873
+ const wrappedGetter = getterMap.get(originalGet);
1861
1874
 
1862
1875
  if (!isUndefined(wrappedGetter)) {
1863
1876
  return wrappedGetter;
@@ -1870,12 +1883,12 @@ class ReadOnlyHandler extends BaseProxyHandler {
1870
1883
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1871
1884
  };
1872
1885
 
1873
- getterMap$1.set(originalGet, get);
1886
+ getterMap.set(originalGet, get);
1874
1887
  return get;
1875
1888
  }
1876
1889
 
1877
1890
  wrapSetter(originalSet) {
1878
- const wrappedSetter = setterMap$1.get(originalSet);
1891
+ const wrappedSetter = setterMap.get(originalSet);
1879
1892
 
1880
1893
  if (!isUndefined(wrappedSetter)) {
1881
1894
  return wrappedSetter;
@@ -1884,6 +1897,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
1884
1897
  const handler = this;
1885
1898
 
1886
1899
  const set = function (v) {
1900
+ /* istanbul ignore else */
1887
1901
  if (process.env.NODE_ENV !== 'production') {
1888
1902
  const {
1889
1903
  originalTarget
@@ -1892,33 +1906,41 @@ class ReadOnlyHandler extends BaseProxyHandler {
1892
1906
  }
1893
1907
  };
1894
1908
 
1895
- setterMap$1.set(originalSet, set);
1909
+ setterMap.set(originalSet, set);
1896
1910
  return set;
1897
1911
  }
1898
1912
 
1899
1913
  set(shadowTarget, key, value) {
1914
+ /* istanbul ignore else */
1900
1915
  if (process.env.NODE_ENV !== 'production') {
1901
1916
  const {
1902
1917
  originalTarget
1903
1918
  } = this;
1904
- throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1919
+ 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.`;
1920
+ throw new Error(msg);
1905
1921
  }
1922
+ /* istanbul ignore next */
1923
+
1906
1924
 
1907
1925
  return false;
1908
1926
  }
1909
1927
 
1910
1928
  deleteProperty(shadowTarget, key) {
1929
+ /* istanbul ignore else */
1911
1930
  if (process.env.NODE_ENV !== 'production') {
1912
1931
  const {
1913
1932
  originalTarget
1914
1933
  } = this;
1915
1934
  throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1916
1935
  }
1936
+ /* istanbul ignore next */
1937
+
1917
1938
 
1918
1939
  return false;
1919
1940
  }
1920
1941
 
1921
1942
  setPrototypeOf(shadowTarget, prototype) {
1943
+ /* istanbul ignore else */
1922
1944
  if (process.env.NODE_ENV !== 'production') {
1923
1945
  const {
1924
1946
  originalTarget
@@ -1928,23 +1950,29 @@ class ReadOnlyHandler extends BaseProxyHandler {
1928
1950
  }
1929
1951
 
1930
1952
  preventExtensions(shadowTarget) {
1953
+ /* istanbul ignore else */
1931
1954
  if (process.env.NODE_ENV !== 'production') {
1932
1955
  const {
1933
1956
  originalTarget
1934
1957
  } = this;
1935
1958
  throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
1936
1959
  }
1960
+ /* istanbul ignore next */
1961
+
1937
1962
 
1938
1963
  return false;
1939
1964
  }
1940
1965
 
1941
1966
  defineProperty(shadowTarget, key, descriptor) {
1967
+ /* istanbul ignore else */
1942
1968
  if (process.env.NODE_ENV !== 'production') {
1943
1969
  const {
1944
1970
  originalTarget
1945
1971
  } = this;
1946
1972
  throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1947
1973
  }
1974
+ /* istanbul ignore next */
1975
+
1948
1976
 
1949
1977
  return false;
1950
1978
  }
@@ -2002,6 +2030,8 @@ const formatter = {
2002
2030
  }; // Inspired from paulmillr/es6-shim
2003
2031
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2004
2032
 
2033
+ /* istanbul ignore next */
2034
+
2005
2035
  function getGlobal() {
2006
2036
  // the only reliable means to get the global object is `Function('return this')()`
2007
2037
  // However, this causes CSP violations in Chrome apps.
@@ -2026,6 +2056,7 @@ function getGlobal() {
2026
2056
  }
2027
2057
 
2028
2058
  function init() {
2059
+ /* istanbul ignore if */
2029
2060
  if (process.env.NODE_ENV === 'production') {
2030
2061
  // this method should never leak to prod
2031
2062
  throw new ReferenceError();
@@ -2040,13 +2071,13 @@ function init() {
2040
2071
  ArrayPush.call(devtoolsFormatters, formatter);
2041
2072
  global.devtoolsFormatters = devtoolsFormatters;
2042
2073
  }
2074
+ /* istanbul ignore else */
2075
+
2043
2076
 
2044
2077
  if (process.env.NODE_ENV !== 'production') {
2045
2078
  init();
2046
2079
  }
2047
2080
 
2048
- const ObjectDotPrototype = Object.prototype;
2049
-
2050
2081
  function defaultValueIsObservable(value) {
2051
2082
  // intentionally checking for null
2052
2083
  if (value === null) {
@@ -2074,106 +2105,85 @@ const defaultValueMutated = (obj, key) => {
2074
2105
  /* do nothing */
2075
2106
  };
2076
2107
 
2077
- const defaultValueDistortion = value => value;
2078
-
2079
2108
  function createShadowTarget(value) {
2080
2109
  return isArray(value) ? [] : {};
2081
2110
  }
2082
2111
 
2083
- class ReactiveMembrane {
2084
- constructor(options) {
2085
- this.valueDistortion = defaultValueDistortion;
2086
- this.valueMutated = defaultValueMutated;
2087
- this.valueObserved = defaultValueObserved;
2088
- this.valueIsObservable = defaultValueIsObservable;
2089
- this.objectGraph = new WeakMap();
2090
-
2091
- if (!isUndefined(options)) {
2092
- const {
2093
- valueDistortion,
2094
- valueMutated,
2095
- valueObserved,
2096
- valueIsObservable,
2097
- tagPropertyKey
2098
- } = options;
2099
- this.valueDistortion = isFunction(valueDistortion) ? valueDistortion : defaultValueDistortion;
2100
- this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
2101
- this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
2102
- this.valueIsObservable = isFunction(valueIsObservable) ? valueIsObservable : defaultValueIsObservable;
2103
- this.tagPropertyKey = tagPropertyKey;
2104
- }
2112
+ class ObservableMembrane {
2113
+ constructor(options = {}) {
2114
+ this.readOnlyObjectGraph = new WeakMap();
2115
+ this.reactiveObjectGraph = new WeakMap();
2116
+ const {
2117
+ valueMutated,
2118
+ valueObserved,
2119
+ valueIsObservable,
2120
+ tagPropertyKey
2121
+ } = options;
2122
+ this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
2123
+ this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
2124
+ this.valueIsObservable = isFunction(valueIsObservable) ? valueIsObservable : defaultValueIsObservable;
2125
+ this.tagPropertyKey = tagPropertyKey;
2105
2126
  }
2106
2127
 
2107
2128
  getProxy(value) {
2108
2129
  const unwrappedValue = unwrap$1(value);
2109
- const distorted = this.valueDistortion(unwrappedValue);
2110
2130
 
2111
- if (this.valueIsObservable(distorted)) {
2112
- const o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2113
- // we return the readonly.
2131
+ if (this.valueIsObservable(unwrappedValue)) {
2132
+ // When trying to extract the writable version of a readonly we return the readonly.
2133
+ if (this.readOnlyObjectGraph.get(unwrappedValue) === value) {
2134
+ return value;
2135
+ }
2114
2136
 
2115
- return o.readOnly === value ? value : o.reactive;
2137
+ return this.getReactiveHandler(unwrappedValue);
2116
2138
  }
2117
2139
 
2118
- return distorted;
2140
+ return unwrappedValue;
2119
2141
  }
2120
2142
 
2121
2143
  getReadOnlyProxy(value) {
2122
2144
  value = unwrap$1(value);
2123
- const distorted = this.valueDistortion(value);
2124
2145
 
2125
- if (this.valueIsObservable(distorted)) {
2126
- return this.getReactiveState(value, distorted).readOnly;
2146
+ if (this.valueIsObservable(value)) {
2147
+ return this.getReadOnlyHandler(value);
2127
2148
  }
2128
2149
 
2129
- return distorted;
2150
+ return value;
2130
2151
  }
2131
2152
 
2132
2153
  unwrapProxy(p) {
2133
2154
  return unwrap$1(p);
2134
2155
  }
2135
2156
 
2136
- getReactiveState(value, distortedValue) {
2137
- const {
2138
- objectGraph
2139
- } = this;
2140
- let reactiveState = objectGraph.get(distortedValue);
2157
+ getReactiveHandler(value) {
2158
+ let proxy = this.reactiveObjectGraph.get(value);
2141
2159
 
2142
- if (reactiveState) {
2143
- return reactiveState;
2160
+ if (isUndefined(proxy)) {
2161
+ // caching the proxy after the first time it is accessed
2162
+ const handler = new ReactiveProxyHandler(this, value);
2163
+ proxy = new Proxy(createShadowTarget(value), handler);
2164
+ registerProxy(proxy, value);
2165
+ this.reactiveObjectGraph.set(value, proxy);
2144
2166
  }
2145
2167
 
2146
- const membrane = this;
2147
- reactiveState = {
2148
- get reactive() {
2149
- const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2150
-
2151
- const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2152
- registerProxy(proxy, value);
2153
- ObjectDefineProperty(this, 'reactive', {
2154
- value: proxy
2155
- });
2156
- return proxy;
2157
- },
2168
+ return proxy;
2169
+ }
2158
2170
 
2159
- get readOnly() {
2160
- const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2171
+ getReadOnlyHandler(value) {
2172
+ let proxy = this.readOnlyObjectGraph.get(value);
2161
2173
 
2162
- const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2163
- registerProxy(proxy, value);
2164
- ObjectDefineProperty(this, 'readOnly', {
2165
- value: proxy
2166
- });
2167
- return proxy;
2168
- }
2174
+ if (isUndefined(proxy)) {
2175
+ // caching the proxy after the first time it is accessed
2176
+ const handler = new ReadOnlyHandler(this, value);
2177
+ proxy = new Proxy(createShadowTarget(value), handler);
2178
+ registerProxy(proxy, value);
2179
+ this.readOnlyObjectGraph.set(value, proxy);
2180
+ }
2169
2181
 
2170
- };
2171
- objectGraph.set(distortedValue, reactiveState);
2172
- return reactiveState;
2182
+ return proxy;
2173
2183
  }
2174
2184
 
2175
2185
  }
2176
- /** version: 1.0.0 */
2186
+ /** version: 2.0.0 */
2177
2187
 
2178
2188
  /*
2179
2189
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2182,15 +2192,9 @@ class ReactiveMembrane {
2182
2192
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2183
2193
  */
2184
2194
  const lockerLivePropertyKey = Symbol.for('@@lockerLiveValue');
2185
-
2186
- function valueDistortion(value) {
2187
- return value;
2188
- }
2189
-
2190
- const reactiveMembrane = new ReactiveMembrane({
2195
+ const reactiveMembrane = new ObservableMembrane({
2191
2196
  valueObserved,
2192
2197
  valueMutated,
2193
- valueDistortion,
2194
2198
  tagPropertyKey: lockerLivePropertyKey
2195
2199
  });
2196
2200
  /**
@@ -2199,16 +2203,9 @@ const reactiveMembrane = new ReactiveMembrane({
2199
2203
  * change or being removed.
2200
2204
  */
2201
2205
 
2202
- const unwrap = function (value) {
2203
- const unwrapped = reactiveMembrane.unwrapProxy(value);
2204
-
2205
- if (unwrapped !== value) {
2206
- // if value is a proxy, unwrap to access original value and apply distortion
2207
- return valueDistortion(unwrapped);
2208
- }
2209
-
2210
- return value;
2211
- };
2206
+ function unwrap(value) {
2207
+ return reactiveMembrane.unwrapProxy(value);
2208
+ }
2212
2209
 
2213
2210
  /*
2214
2211
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4157,13 +4154,15 @@ function updateElmHook(oldVnode, vnode) {
4157
4154
  }
4158
4155
  function updateChildrenHook(oldVnode, vnode) {
4159
4156
  const {
4160
- children,
4161
- owner
4157
+ elm,
4158
+ children
4162
4159
  } = vnode;
4163
- const fn = hasDynamicChildren(children) ? updateDynamicChildren : updateStaticChildren;
4164
- runWithBoundaryProtection(owner, owner.owner, shared.noop, () => {
4165
- fn(vnode.elm, oldVnode.children, children);
4166
- }, shared.noop);
4160
+
4161
+ if (hasDynamicChildren(children)) {
4162
+ updateDynamicChildren(elm, oldVnode.children, children);
4163
+ } else {
4164
+ updateStaticChildren(elm, oldVnode.children, children);
4165
+ }
4167
4166
  }
4168
4167
  function allocateChildrenHook(vnode, vm) {
4169
4168
  // A component with slots will re-render because:
@@ -5391,6 +5390,7 @@ function updateStylesheetToken(vm, template) {
5391
5390
 
5392
5391
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5393
5392
  const content = [];
5393
+ let root;
5394
5394
 
5395
5395
  for (let i = 0; i < stylesheets.length; i++) {
5396
5396
  let stylesheet = stylesheets[i];
@@ -5403,23 +5403,46 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5403
5403
  // the component instance might be attempting to use an old version of
5404
5404
  // the stylesheet, while internally, we have a replacement for it.
5405
5405
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5406
- } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5407
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5406
+ }
5407
+
5408
+ const isScopedCss = stylesheet[shared.KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5408
5409
 
5410
+ const scopeToken = isScopedCss || vm.shadowMode === 1
5411
+ /* Synthetic */
5412
+ && vm.renderMode === 1
5413
+ /* Shadow */
5414
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5415
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5409
5416
 
5410
- const isScopedCss = stylesheet[shared.KEY__SCOPED_CSS];
5411
5417
  const useActualHostSelector = vm.renderMode === 0
5412
5418
  /* Light */
5413
5419
  ? !isScopedCss : vm.shadowMode === 0
5414
5420
  /* Native */
5415
- ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5421
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5422
+ // we use an attribute selector on the host to simulate :dir().
5416
5423
 
5417
- const scopeToken = isScopedCss || vm.shadowMode === 1
5418
- /* Synthetic */
5419
- && vm.renderMode === 1
5424
+ let useNativeDirPseudoclass;
5425
+
5426
+ if (vm.renderMode === 1
5420
5427
  /* Shadow */
5421
- ? stylesheetToken : undefined;
5422
- shared.ArrayPush.call(content, stylesheet(useActualHostSelector, scopeToken));
5428
+ ) {
5429
+ useNativeDirPseudoclass = vm.shadowMode === 0
5430
+ /* Native */
5431
+ ;
5432
+ } else {
5433
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
5434
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
5435
+ if (shared.isUndefined(root)) {
5436
+ // Only calculate the root once as necessary
5437
+ root = getNearestShadowComponent(vm);
5438
+ }
5439
+
5440
+ useNativeDirPseudoclass = shared.isNull(root) || root.shadowMode === 0
5441
+ /* Native */
5442
+ ;
5443
+ }
5444
+
5445
+ shared.ArrayPush.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5423
5446
  }
5424
5447
  }
5425
5448
 
@@ -5442,14 +5465,12 @@ function getStylesheetsContent(vm, template) {
5442
5465
  // perf testing has not shown it to be a huge improvement yet:
5443
5466
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5444
5467
 
5445
- function getNearestNativeShadowComponent(vm) {
5468
+ function getNearestShadowComponent(vm) {
5446
5469
  let owner = vm;
5447
5470
 
5448
5471
  while (!shared.isNull(owner)) {
5449
5472
  if (owner.renderMode === 1
5450
5473
  /* Shadow */
5451
- && owner.shadowMode === 0
5452
- /* Native */
5453
5474
  ) {
5454
5475
  return owner;
5455
5476
  }
@@ -5460,6 +5481,20 @@ function getNearestNativeShadowComponent(vm) {
5460
5481
  return owner;
5461
5482
  }
5462
5483
 
5484
+ function getNearestNativeShadowComponent(vm) {
5485
+ const owner = getNearestShadowComponent(vm);
5486
+
5487
+ if (!shared.isNull(owner) && owner.shadowMode === 1
5488
+ /* Synthetic */
5489
+ ) {
5490
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
5491
+ // synthetic, we know we won't find a native component if we go any further.
5492
+ return null;
5493
+ }
5494
+
5495
+ return owner;
5496
+ }
5497
+
5463
5498
  function createStylesheet(vm, stylesheets) {
5464
5499
  const {
5465
5500
  renderer,
@@ -5575,7 +5610,7 @@ function logOperationStart(opId, vm) {
5575
5610
  if (isProfilerEnabled) {
5576
5611
  currentDispatcher(opId, 0
5577
5612
  /* Start */
5578
- , vm.tagName, vm.idx);
5613
+ , vm.tagName, vm.idx, vm.renderMode, vm.shadowMode);
5579
5614
  }
5580
5615
  }
5581
5616
  function logOperationEnd(opId, vm) {
@@ -5588,7 +5623,7 @@ function logOperationEnd(opId, vm) {
5588
5623
  if (isProfilerEnabled) {
5589
5624
  currentDispatcher(opId, 1
5590
5625
  /* Stop */
5591
- , vm.tagName, vm.idx);
5626
+ , vm.tagName, vm.idx, vm.renderMode, vm.shadowMode);
5592
5627
  }
5593
5628
  }
5594
5629
  function logGlobalOperationStart(opId, vm) {
@@ -5601,7 +5636,7 @@ function logGlobalOperationStart(opId, vm) {
5601
5636
  if (isProfilerEnabled) {
5602
5637
  currentDispatcher(opId, 0
5603
5638
  /* Start */
5604
- , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx);
5639
+ , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx, vm === null || vm === void 0 ? void 0 : vm.renderMode, vm === null || vm === void 0 ? void 0 : vm.shadowMode);
5605
5640
  }
5606
5641
  }
5607
5642
  function logGlobalOperationEnd(opId, vm) {
@@ -5614,7 +5649,7 @@ function logGlobalOperationEnd(opId, vm) {
5614
5649
  if (isProfilerEnabled) {
5615
5650
  currentDispatcher(opId, 1
5616
5651
  /* Stop */
5617
- , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx);
5652
+ , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx, vm === null || vm === void 0 ? void 0 : vm.renderMode, vm === null || vm === void 0 ? void 0 : vm.shadowMode);
5618
5653
  }
5619
5654
  }
5620
5655
 
@@ -5767,6 +5802,7 @@ function evaluateTemplate(vm, html) {
5767
5802
 
5768
5803
  return vnodes;
5769
5804
  }
5805
+
5770
5806
  function computeHasScopedStyles(template) {
5771
5807
  const {
5772
5808
  stylesheets
@@ -7153,15 +7189,11 @@ function setHooks(hooks) {
7153
7189
 
7154
7190
  Object.defineProperty(exports, 'setFeatureFlag', {
7155
7191
  enumerable: true,
7156
- get: function () {
7157
- return features.setFeatureFlag;
7158
- }
7192
+ get: function () { return features.setFeatureFlag; }
7159
7193
  });
7160
7194
  Object.defineProperty(exports, 'setFeatureFlagForTest', {
7161
7195
  enumerable: true,
7162
- get: function () {
7163
- return features.setFeatureFlagForTest;
7164
- }
7196
+ get: function () { return features.setFeatureFlagForTest; }
7165
7197
  });
7166
7198
  exports.LightningElement = LightningElement;
7167
7199
  exports.__unstable__ProfilerControl = profilerControl;
@@ -7189,4 +7221,4 @@ exports.swapTemplate = swapTemplate;
7189
7221
  exports.track = track;
7190
7222
  exports.unwrap = unwrap;
7191
7223
  exports.wire = wire;
7192
- /* version: 2.5.10-alpha1 */
7224
+ /* version: 2.7.0 */