@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.
@@ -1,5 +1,5 @@
1
1
  /* proxy-compat-disable */
2
- import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, assign, assert, keys, StringCharCodeAt, isString, StringSlice, freeze, defineProperties, forEach, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, getPropertyDescriptor, isObject, AriaPropNameToAttrNameMap, defineProperty, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, htmlPropertyToAttribute, ArraySlice, hasOwnProperty as hasOwnProperty$1, ArrayFilter, noop, isArray as isArray$1, isNumber, StringReplace, KEY__SHADOW_RESOLVER, KEY__SCOPED_CSS, ArrayUnshift, isFrozen } from '@lwc/shared';
2
+ import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, assign, assert, keys, StringCharCodeAt, isString, StringSlice, freeze, defineProperties, forEach, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, getPropertyDescriptor, isObject, AriaPropNameToAttrNameMap, defineProperty, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, htmlPropertyToAttribute, ArraySlice, hasOwnProperty as hasOwnProperty$1, ArrayFilter, isArray as isArray$1, isNumber, StringReplace, KEY__SHADOW_RESOLVER, KEY__SCOPED_CSS, noop, ArrayUnshift, isFrozen } from '@lwc/shared';
3
3
  import { runtimeFlags } from '@lwc/features';
4
4
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
5
5
 
@@ -1425,10 +1425,10 @@ const {
1425
1425
  isArray
1426
1426
  } = Array;
1427
1427
  const {
1428
+ prototype: ObjectDotPrototype,
1428
1429
  getPrototypeOf,
1429
1430
  create: ObjectCreate,
1430
1431
  defineProperty: ObjectDefineProperty,
1431
- defineProperties: ObjectDefineProperties,
1432
1432
  isExtensible,
1433
1433
  getOwnPropertyDescriptor,
1434
1434
  getOwnPropertyNames,
@@ -1438,8 +1438,7 @@ const {
1438
1438
  } = Object;
1439
1439
  const {
1440
1440
  push: ArrayPush,
1441
- concat: ArrayConcat,
1442
- map: ArrayMap
1441
+ concat: ArrayConcat
1443
1442
  } = Array.prototype;
1444
1443
  const OtS = {}.toString;
1445
1444
 
@@ -1504,7 +1503,9 @@ class BaseProxyHandler {
1504
1503
  // but it will always be compatible with the previous descriptor
1505
1504
  // to preserve the object invariants, which makes these lines safe.
1506
1505
 
1507
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
1506
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1507
+
1508
+ /* istanbul ignore else */
1508
1509
 
1509
1510
  if (!isUndefined(originalDescriptor)) {
1510
1511
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1532,11 +1533,17 @@ class BaseProxyHandler {
1532
1533
 
1533
1534
  preventExtensions(shadowTarget);
1534
1535
  } // Shared Traps
1536
+ // TODO: apply() is never called
1537
+
1538
+ /* istanbul ignore next */
1535
1539
 
1536
1540
 
1537
1541
  apply(shadowTarget, thisArg, argArray) {
1538
1542
  /* No op */
1539
- }
1543
+ } // TODO: construct() is never called
1544
+
1545
+ /* istanbul ignore next */
1546
+
1540
1547
 
1541
1548
  construct(shadowTarget, argArray, newTarget) {
1542
1549
  /* No op */
@@ -1649,8 +1656,8 @@ class BaseProxyHandler {
1649
1656
 
1650
1657
  }
1651
1658
 
1652
- const getterMap = new WeakMap();
1653
- const setterMap = new WeakMap();
1659
+ const getterMap$1 = new WeakMap();
1660
+ const setterMap$1 = new WeakMap();
1654
1661
  const reverseGetterMap = new WeakMap();
1655
1662
  const reverseSetterMap = new WeakMap();
1656
1663
 
@@ -1660,7 +1667,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1660
1667
  }
1661
1668
 
1662
1669
  wrapGetter(originalGet) {
1663
- const wrappedGetter = getterMap.get(originalGet);
1670
+ const wrappedGetter = getterMap$1.get(originalGet);
1664
1671
 
1665
1672
  if (!isUndefined(wrappedGetter)) {
1666
1673
  return wrappedGetter;
@@ -1673,13 +1680,13 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1673
1680
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1674
1681
  };
1675
1682
 
1676
- getterMap.set(originalGet, get);
1683
+ getterMap$1.set(originalGet, get);
1677
1684
  reverseGetterMap.set(get, originalGet);
1678
1685
  return get;
1679
1686
  }
1680
1687
 
1681
1688
  wrapSetter(originalSet) {
1682
- const wrappedSetter = setterMap.get(originalSet);
1689
+ const wrappedSetter = setterMap$1.get(originalSet);
1683
1690
 
1684
1691
  if (!isUndefined(wrappedSetter)) {
1685
1692
  return wrappedSetter;
@@ -1690,7 +1697,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1690
1697
  originalSet.call(unwrap$1(this), unwrap$1(v));
1691
1698
  };
1692
1699
 
1693
- setterMap.set(originalSet, set);
1700
+ setterMap$1.set(originalSet, set);
1694
1701
  reverseSetterMap.set(set, originalSet);
1695
1702
  return set;
1696
1703
  }
@@ -1731,7 +1738,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1731
1738
  return unwrap$1(redGet.call(handler.wrapValue(this)));
1732
1739
  };
1733
1740
 
1734
- getterMap.set(get, redGet);
1741
+ getterMap$1.set(get, redGet);
1735
1742
  reverseGetterMap.set(redGet, get);
1736
1743
  return get;
1737
1744
  }
@@ -1750,7 +1757,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1750
1757
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
1751
1758
  };
1752
1759
 
1753
- setterMap.set(set, redSet);
1760
+ setterMap$1.set(set, redSet);
1754
1761
  reverseSetterMap.set(redSet, set);
1755
1762
  return set;
1756
1763
  }
@@ -1791,6 +1798,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1791
1798
  }
1792
1799
 
1793
1800
  setPrototypeOf(shadowTarget, prototype) {
1801
+ /* istanbul ignore else */
1794
1802
  if (process.env.NODE_ENV !== 'production') {
1795
1803
  throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
1796
1804
  }
@@ -1804,6 +1812,11 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1804
1812
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
1805
1813
  // the preventExtension call, in which case we should not attempt to lock down
1806
1814
  // the shadow target.
1815
+ // TODO: It should not actually be possible to reach this `if` statement.
1816
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
1817
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
1818
+
1819
+ /* istanbul ignore if */
1807
1820
 
1808
1821
  if (isExtensible(originalTarget)) {
1809
1822
  return false;
@@ -1845,8 +1858,8 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1845
1858
 
1846
1859
  }
1847
1860
 
1848
- const getterMap$1 = new WeakMap();
1849
- const setterMap$1 = new WeakMap();
1861
+ const getterMap = new WeakMap();
1862
+ const setterMap = new WeakMap();
1850
1863
 
1851
1864
  class ReadOnlyHandler extends BaseProxyHandler {
1852
1865
  wrapValue(value) {
@@ -1854,7 +1867,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
1854
1867
  }
1855
1868
 
1856
1869
  wrapGetter(originalGet) {
1857
- const wrappedGetter = getterMap$1.get(originalGet);
1870
+ const wrappedGetter = getterMap.get(originalGet);
1858
1871
 
1859
1872
  if (!isUndefined(wrappedGetter)) {
1860
1873
  return wrappedGetter;
@@ -1867,12 +1880,12 @@ class ReadOnlyHandler extends BaseProxyHandler {
1867
1880
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1868
1881
  };
1869
1882
 
1870
- getterMap$1.set(originalGet, get);
1883
+ getterMap.set(originalGet, get);
1871
1884
  return get;
1872
1885
  }
1873
1886
 
1874
1887
  wrapSetter(originalSet) {
1875
- const wrappedSetter = setterMap$1.get(originalSet);
1888
+ const wrappedSetter = setterMap.get(originalSet);
1876
1889
 
1877
1890
  if (!isUndefined(wrappedSetter)) {
1878
1891
  return wrappedSetter;
@@ -1881,6 +1894,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
1881
1894
  const handler = this;
1882
1895
 
1883
1896
  const set = function (v) {
1897
+ /* istanbul ignore else */
1884
1898
  if (process.env.NODE_ENV !== 'production') {
1885
1899
  const {
1886
1900
  originalTarget
@@ -1889,33 +1903,41 @@ class ReadOnlyHandler extends BaseProxyHandler {
1889
1903
  }
1890
1904
  };
1891
1905
 
1892
- setterMap$1.set(originalSet, set);
1906
+ setterMap.set(originalSet, set);
1893
1907
  return set;
1894
1908
  }
1895
1909
 
1896
1910
  set(shadowTarget, key, value) {
1911
+ /* istanbul ignore else */
1897
1912
  if (process.env.NODE_ENV !== 'production') {
1898
1913
  const {
1899
1914
  originalTarget
1900
1915
  } = this;
1901
- throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1916
+ 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.`;
1917
+ throw new Error(msg);
1902
1918
  }
1919
+ /* istanbul ignore next */
1920
+
1903
1921
 
1904
1922
  return false;
1905
1923
  }
1906
1924
 
1907
1925
  deleteProperty(shadowTarget, key) {
1926
+ /* istanbul ignore else */
1908
1927
  if (process.env.NODE_ENV !== 'production') {
1909
1928
  const {
1910
1929
  originalTarget
1911
1930
  } = this;
1912
1931
  throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1913
1932
  }
1933
+ /* istanbul ignore next */
1934
+
1914
1935
 
1915
1936
  return false;
1916
1937
  }
1917
1938
 
1918
1939
  setPrototypeOf(shadowTarget, prototype) {
1940
+ /* istanbul ignore else */
1919
1941
  if (process.env.NODE_ENV !== 'production') {
1920
1942
  const {
1921
1943
  originalTarget
@@ -1925,23 +1947,29 @@ class ReadOnlyHandler extends BaseProxyHandler {
1925
1947
  }
1926
1948
 
1927
1949
  preventExtensions(shadowTarget) {
1950
+ /* istanbul ignore else */
1928
1951
  if (process.env.NODE_ENV !== 'production') {
1929
1952
  const {
1930
1953
  originalTarget
1931
1954
  } = this;
1932
1955
  throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
1933
1956
  }
1957
+ /* istanbul ignore next */
1958
+
1934
1959
 
1935
1960
  return false;
1936
1961
  }
1937
1962
 
1938
1963
  defineProperty(shadowTarget, key, descriptor) {
1964
+ /* istanbul ignore else */
1939
1965
  if (process.env.NODE_ENV !== 'production') {
1940
1966
  const {
1941
1967
  originalTarget
1942
1968
  } = this;
1943
1969
  throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1944
1970
  }
1971
+ /* istanbul ignore next */
1972
+
1945
1973
 
1946
1974
  return false;
1947
1975
  }
@@ -1999,6 +2027,8 @@ const formatter = {
1999
2027
  }; // Inspired from paulmillr/es6-shim
2000
2028
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2001
2029
 
2030
+ /* istanbul ignore next */
2031
+
2002
2032
  function getGlobal() {
2003
2033
  // the only reliable means to get the global object is `Function('return this')()`
2004
2034
  // However, this causes CSP violations in Chrome apps.
@@ -2023,6 +2053,7 @@ function getGlobal() {
2023
2053
  }
2024
2054
 
2025
2055
  function init() {
2056
+ /* istanbul ignore if */
2026
2057
  if (process.env.NODE_ENV === 'production') {
2027
2058
  // this method should never leak to prod
2028
2059
  throw new ReferenceError();
@@ -2037,13 +2068,13 @@ function init() {
2037
2068
  ArrayPush.call(devtoolsFormatters, formatter);
2038
2069
  global.devtoolsFormatters = devtoolsFormatters;
2039
2070
  }
2071
+ /* istanbul ignore else */
2072
+
2040
2073
 
2041
2074
  if (process.env.NODE_ENV !== 'production') {
2042
2075
  init();
2043
2076
  }
2044
2077
 
2045
- const ObjectDotPrototype = Object.prototype;
2046
-
2047
2078
  function defaultValueIsObservable(value) {
2048
2079
  // intentionally checking for null
2049
2080
  if (value === null) {
@@ -2071,106 +2102,85 @@ const defaultValueMutated = (obj, key) => {
2071
2102
  /* do nothing */
2072
2103
  };
2073
2104
 
2074
- const defaultValueDistortion = value => value;
2075
-
2076
2105
  function createShadowTarget(value) {
2077
2106
  return isArray(value) ? [] : {};
2078
2107
  }
2079
2108
 
2080
- class ReactiveMembrane {
2081
- constructor(options) {
2082
- this.valueDistortion = defaultValueDistortion;
2083
- this.valueMutated = defaultValueMutated;
2084
- this.valueObserved = defaultValueObserved;
2085
- this.valueIsObservable = defaultValueIsObservable;
2086
- this.objectGraph = new WeakMap();
2087
-
2088
- if (!isUndefined(options)) {
2089
- const {
2090
- valueDistortion,
2091
- valueMutated,
2092
- valueObserved,
2093
- valueIsObservable,
2094
- tagPropertyKey
2095
- } = options;
2096
- this.valueDistortion = isFunction(valueDistortion) ? valueDistortion : defaultValueDistortion;
2097
- this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
2098
- this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
2099
- this.valueIsObservable = isFunction(valueIsObservable) ? valueIsObservable : defaultValueIsObservable;
2100
- this.tagPropertyKey = tagPropertyKey;
2101
- }
2109
+ class ObservableMembrane {
2110
+ constructor(options = {}) {
2111
+ this.readOnlyObjectGraph = new WeakMap();
2112
+ this.reactiveObjectGraph = new WeakMap();
2113
+ const {
2114
+ valueMutated,
2115
+ valueObserved,
2116
+ valueIsObservable,
2117
+ tagPropertyKey
2118
+ } = options;
2119
+ this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
2120
+ this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
2121
+ this.valueIsObservable = isFunction(valueIsObservable) ? valueIsObservable : defaultValueIsObservable;
2122
+ this.tagPropertyKey = tagPropertyKey;
2102
2123
  }
2103
2124
 
2104
2125
  getProxy(value) {
2105
2126
  const unwrappedValue = unwrap$1(value);
2106
- const distorted = this.valueDistortion(unwrappedValue);
2107
2127
 
2108
- if (this.valueIsObservable(distorted)) {
2109
- const o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2110
- // we return the readonly.
2128
+ if (this.valueIsObservable(unwrappedValue)) {
2129
+ // When trying to extract the writable version of a readonly we return the readonly.
2130
+ if (this.readOnlyObjectGraph.get(unwrappedValue) === value) {
2131
+ return value;
2132
+ }
2111
2133
 
2112
- return o.readOnly === value ? value : o.reactive;
2134
+ return this.getReactiveHandler(unwrappedValue);
2113
2135
  }
2114
2136
 
2115
- return distorted;
2137
+ return unwrappedValue;
2116
2138
  }
2117
2139
 
2118
2140
  getReadOnlyProxy(value) {
2119
2141
  value = unwrap$1(value);
2120
- const distorted = this.valueDistortion(value);
2121
2142
 
2122
- if (this.valueIsObservable(distorted)) {
2123
- return this.getReactiveState(value, distorted).readOnly;
2143
+ if (this.valueIsObservable(value)) {
2144
+ return this.getReadOnlyHandler(value);
2124
2145
  }
2125
2146
 
2126
- return distorted;
2147
+ return value;
2127
2148
  }
2128
2149
 
2129
2150
  unwrapProxy(p) {
2130
2151
  return unwrap$1(p);
2131
2152
  }
2132
2153
 
2133
- getReactiveState(value, distortedValue) {
2134
- const {
2135
- objectGraph
2136
- } = this;
2137
- let reactiveState = objectGraph.get(distortedValue);
2154
+ getReactiveHandler(value) {
2155
+ let proxy = this.reactiveObjectGraph.get(value);
2138
2156
 
2139
- if (reactiveState) {
2140
- return reactiveState;
2157
+ if (isUndefined(proxy)) {
2158
+ // caching the proxy after the first time it is accessed
2159
+ const handler = new ReactiveProxyHandler(this, value);
2160
+ proxy = new Proxy(createShadowTarget(value), handler);
2161
+ registerProxy(proxy, value);
2162
+ this.reactiveObjectGraph.set(value, proxy);
2141
2163
  }
2142
2164
 
2143
- const membrane = this;
2144
- reactiveState = {
2145
- get reactive() {
2146
- const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2147
-
2148
- const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2149
- registerProxy(proxy, value);
2150
- ObjectDefineProperty(this, 'reactive', {
2151
- value: proxy
2152
- });
2153
- return proxy;
2154
- },
2165
+ return proxy;
2166
+ }
2155
2167
 
2156
- get readOnly() {
2157
- const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2168
+ getReadOnlyHandler(value) {
2169
+ let proxy = this.readOnlyObjectGraph.get(value);
2158
2170
 
2159
- const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2160
- registerProxy(proxy, value);
2161
- ObjectDefineProperty(this, 'readOnly', {
2162
- value: proxy
2163
- });
2164
- return proxy;
2165
- }
2171
+ if (isUndefined(proxy)) {
2172
+ // caching the proxy after the first time it is accessed
2173
+ const handler = new ReadOnlyHandler(this, value);
2174
+ proxy = new Proxy(createShadowTarget(value), handler);
2175
+ registerProxy(proxy, value);
2176
+ this.readOnlyObjectGraph.set(value, proxy);
2177
+ }
2166
2178
 
2167
- };
2168
- objectGraph.set(distortedValue, reactiveState);
2169
- return reactiveState;
2179
+ return proxy;
2170
2180
  }
2171
2181
 
2172
2182
  }
2173
- /** version: 1.0.0 */
2183
+ /** version: 2.0.0 */
2174
2184
 
2175
2185
  /*
2176
2186
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2179,15 +2189,9 @@ class ReactiveMembrane {
2179
2189
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2180
2190
  */
2181
2191
  const lockerLivePropertyKey = Symbol.for('@@lockerLiveValue');
2182
-
2183
- function valueDistortion(value) {
2184
- return value;
2185
- }
2186
-
2187
- const reactiveMembrane = new ReactiveMembrane({
2192
+ const reactiveMembrane = new ObservableMembrane({
2188
2193
  valueObserved,
2189
2194
  valueMutated,
2190
- valueDistortion,
2191
2195
  tagPropertyKey: lockerLivePropertyKey
2192
2196
  });
2193
2197
  /**
@@ -2196,16 +2200,9 @@ const reactiveMembrane = new ReactiveMembrane({
2196
2200
  * change or being removed.
2197
2201
  */
2198
2202
 
2199
- const unwrap = function (value) {
2200
- const unwrapped = reactiveMembrane.unwrapProxy(value);
2201
-
2202
- if (unwrapped !== value) {
2203
- // if value is a proxy, unwrap to access original value and apply distortion
2204
- return valueDistortion(unwrapped);
2205
- }
2206
-
2207
- return value;
2208
- };
2203
+ function unwrap(value) {
2204
+ return reactiveMembrane.unwrapProxy(value);
2205
+ }
2209
2206
 
2210
2207
  /*
2211
2208
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4154,13 +4151,15 @@ function updateElmHook(oldVnode, vnode) {
4154
4151
  }
4155
4152
  function updateChildrenHook(oldVnode, vnode) {
4156
4153
  const {
4157
- children,
4158
- owner
4154
+ elm,
4155
+ children
4159
4156
  } = vnode;
4160
- const fn = hasDynamicChildren(children) ? updateDynamicChildren : updateStaticChildren;
4161
- runWithBoundaryProtection(owner, owner.owner, noop, () => {
4162
- fn(vnode.elm, oldVnode.children, children);
4163
- }, noop);
4157
+
4158
+ if (hasDynamicChildren(children)) {
4159
+ updateDynamicChildren(elm, oldVnode.children, children);
4160
+ } else {
4161
+ updateStaticChildren(elm, oldVnode.children, children);
4162
+ }
4164
4163
  }
4165
4164
  function allocateChildrenHook(vnode, vm) {
4166
4165
  // A component with slots will re-render because:
@@ -5388,6 +5387,7 @@ function updateStylesheetToken(vm, template) {
5388
5387
 
5389
5388
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5390
5389
  const content = [];
5390
+ let root;
5391
5391
 
5392
5392
  for (let i = 0; i < stylesheets.length; i++) {
5393
5393
  let stylesheet = stylesheets[i];
@@ -5400,23 +5400,46 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5400
5400
  // the component instance might be attempting to use an old version of
5401
5401
  // the stylesheet, while internally, we have a replacement for it.
5402
5402
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5403
- } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5404
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5403
+ }
5405
5404
 
5405
+ const isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5406
+
5407
+ const scopeToken = isScopedCss || vm.shadowMode === 1
5408
+ /* Synthetic */
5409
+ && vm.renderMode === 1
5410
+ /* Shadow */
5411
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5412
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5406
5413
 
5407
- const isScopedCss = stylesheet[KEY__SCOPED_CSS];
5408
5414
  const useActualHostSelector = vm.renderMode === 0
5409
5415
  /* Light */
5410
5416
  ? !isScopedCss : vm.shadowMode === 0
5411
5417
  /* Native */
5412
- ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5418
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5419
+ // we use an attribute selector on the host to simulate :dir().
5413
5420
 
5414
- const scopeToken = isScopedCss || vm.shadowMode === 1
5415
- /* Synthetic */
5416
- && vm.renderMode === 1
5421
+ let useNativeDirPseudoclass;
5422
+
5423
+ if (vm.renderMode === 1
5417
5424
  /* Shadow */
5418
- ? stylesheetToken : undefined;
5419
- ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
5425
+ ) {
5426
+ useNativeDirPseudoclass = vm.shadowMode === 0
5427
+ /* Native */
5428
+ ;
5429
+ } else {
5430
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
5431
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
5432
+ if (isUndefined$1(root)) {
5433
+ // Only calculate the root once as necessary
5434
+ root = getNearestShadowComponent(vm);
5435
+ }
5436
+
5437
+ useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
5438
+ /* Native */
5439
+ ;
5440
+ }
5441
+
5442
+ ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5420
5443
  }
5421
5444
  }
5422
5445
 
@@ -5439,14 +5462,12 @@ function getStylesheetsContent(vm, template) {
5439
5462
  // perf testing has not shown it to be a huge improvement yet:
5440
5463
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5441
5464
 
5442
- function getNearestNativeShadowComponent(vm) {
5465
+ function getNearestShadowComponent(vm) {
5443
5466
  let owner = vm;
5444
5467
 
5445
5468
  while (!isNull(owner)) {
5446
5469
  if (owner.renderMode === 1
5447
5470
  /* Shadow */
5448
- && owner.shadowMode === 0
5449
- /* Native */
5450
5471
  ) {
5451
5472
  return owner;
5452
5473
  }
@@ -5457,6 +5478,20 @@ function getNearestNativeShadowComponent(vm) {
5457
5478
  return owner;
5458
5479
  }
5459
5480
 
5481
+ function getNearestNativeShadowComponent(vm) {
5482
+ const owner = getNearestShadowComponent(vm);
5483
+
5484
+ if (!isNull(owner) && owner.shadowMode === 1
5485
+ /* Synthetic */
5486
+ ) {
5487
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
5488
+ // synthetic, we know we won't find a native component if we go any further.
5489
+ return null;
5490
+ }
5491
+
5492
+ return owner;
5493
+ }
5494
+
5460
5495
  function createStylesheet(vm, stylesheets) {
5461
5496
  const {
5462
5497
  renderer,
@@ -5572,7 +5607,7 @@ function logOperationStart(opId, vm) {
5572
5607
  if (isProfilerEnabled) {
5573
5608
  currentDispatcher(opId, 0
5574
5609
  /* Start */
5575
- , vm.tagName, vm.idx);
5610
+ , vm.tagName, vm.idx, vm.renderMode, vm.shadowMode);
5576
5611
  }
5577
5612
  }
5578
5613
  function logOperationEnd(opId, vm) {
@@ -5585,7 +5620,7 @@ function logOperationEnd(opId, vm) {
5585
5620
  if (isProfilerEnabled) {
5586
5621
  currentDispatcher(opId, 1
5587
5622
  /* Stop */
5588
- , vm.tagName, vm.idx);
5623
+ , vm.tagName, vm.idx, vm.renderMode, vm.shadowMode);
5589
5624
  }
5590
5625
  }
5591
5626
  function logGlobalOperationStart(opId, vm) {
@@ -5598,7 +5633,7 @@ function logGlobalOperationStart(opId, vm) {
5598
5633
  if (isProfilerEnabled) {
5599
5634
  currentDispatcher(opId, 0
5600
5635
  /* Start */
5601
- , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx);
5636
+ , 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);
5602
5637
  }
5603
5638
  }
5604
5639
  function logGlobalOperationEnd(opId, vm) {
@@ -5611,7 +5646,7 @@ function logGlobalOperationEnd(opId, vm) {
5611
5646
  if (isProfilerEnabled) {
5612
5647
  currentDispatcher(opId, 1
5613
5648
  /* Stop */
5614
- , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx);
5649
+ , 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);
5615
5650
  }
5616
5651
  }
5617
5652
 
@@ -5764,6 +5799,7 @@ function evaluateTemplate(vm, html) {
5764
5799
 
5765
5800
  return vnodes;
5766
5801
  }
5802
+
5767
5803
  function computeHasScopedStyles(template) {
5768
5804
  const {
5769
5805
  stylesheets
@@ -7149,4 +7185,4 @@ function setHooks(hooks) {
7149
7185
  }
7150
7186
 
7151
7187
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentDef, getComponentInternalDef, getUpgradableConstructor, hydrateRootElement, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
7152
- /* version: 2.5.10-alpha1 */
7188
+ /* version: 2.7.0 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.5.10-alpha1",
3
+ "version": "2.7.0",
4
4
  "description": "Core LWC engine APIs.",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -24,14 +24,14 @@
24
24
  "types/"
25
25
  ],
26
26
  "dependencies": {
27
- "@lwc/features": "2.5.10-alpha1",
28
- "@lwc/shared": "2.5.10-alpha1"
27
+ "@lwc/features": "2.7.0",
28
+ "@lwc/shared": "2.7.0"
29
29
  },
30
30
  "devDependencies": {
31
- "observable-membrane": "1.1.5"
31
+ "observable-membrane": "2.0.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "b96b2d24f545c14a5c8984ab01081290afd5dc39"
36
+ "gitHead": "656663a9f95f90bd648c6fc2200201afc0156393"
37
37
  }