@lwc/engine-core 2.5.8 → 2.5.11

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.
@@ -1431,7 +1431,6 @@ const {
1431
1431
  getPrototypeOf,
1432
1432
  create: ObjectCreate,
1433
1433
  defineProperty: ObjectDefineProperty,
1434
- defineProperties: ObjectDefineProperties,
1435
1434
  isExtensible,
1436
1435
  getOwnPropertyDescriptor,
1437
1436
  getOwnPropertyNames,
@@ -1441,8 +1440,7 @@ const {
1441
1440
  } = Object;
1442
1441
  const {
1443
1442
  push: ArrayPush,
1444
- concat: ArrayConcat,
1445
- map: ArrayMap
1443
+ concat: ArrayConcat
1446
1444
  } = Array.prototype;
1447
1445
  const OtS = {}.toString;
1448
1446
 
@@ -1507,7 +1505,9 @@ class BaseProxyHandler {
1507
1505
  // but it will always be compatible with the previous descriptor
1508
1506
  // to preserve the object invariants, which makes these lines safe.
1509
1507
 
1510
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
1508
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1509
+
1510
+ /* istanbul ignore else */
1511
1511
 
1512
1512
  if (!isUndefined(originalDescriptor)) {
1513
1513
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1535,11 +1535,17 @@ class BaseProxyHandler {
1535
1535
 
1536
1536
  preventExtensions(shadowTarget);
1537
1537
  } // Shared Traps
1538
+ // TODO: apply() is never called
1539
+
1540
+ /* istanbul ignore next */
1538
1541
 
1539
1542
 
1540
1543
  apply(shadowTarget, thisArg, argArray) {
1541
1544
  /* No op */
1542
- }
1545
+ } // TODO: construct() is never called
1546
+
1547
+ /* istanbul ignore next */
1548
+
1543
1549
 
1544
1550
  construct(shadowTarget, argArray, newTarget) {
1545
1551
  /* No op */
@@ -1652,8 +1658,8 @@ class BaseProxyHandler {
1652
1658
 
1653
1659
  }
1654
1660
 
1655
- const getterMap = new WeakMap();
1656
- const setterMap = new WeakMap();
1661
+ const getterMap$1 = new WeakMap();
1662
+ const setterMap$1 = new WeakMap();
1657
1663
  const reverseGetterMap = new WeakMap();
1658
1664
  const reverseSetterMap = new WeakMap();
1659
1665
 
@@ -1663,7 +1669,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1663
1669
  }
1664
1670
 
1665
1671
  wrapGetter(originalGet) {
1666
- const wrappedGetter = getterMap.get(originalGet);
1672
+ const wrappedGetter = getterMap$1.get(originalGet);
1667
1673
 
1668
1674
  if (!isUndefined(wrappedGetter)) {
1669
1675
  return wrappedGetter;
@@ -1676,13 +1682,13 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1676
1682
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1677
1683
  };
1678
1684
 
1679
- getterMap.set(originalGet, get);
1685
+ getterMap$1.set(originalGet, get);
1680
1686
  reverseGetterMap.set(get, originalGet);
1681
1687
  return get;
1682
1688
  }
1683
1689
 
1684
1690
  wrapSetter(originalSet) {
1685
- const wrappedSetter = setterMap.get(originalSet);
1691
+ const wrappedSetter = setterMap$1.get(originalSet);
1686
1692
 
1687
1693
  if (!isUndefined(wrappedSetter)) {
1688
1694
  return wrappedSetter;
@@ -1693,7 +1699,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1693
1699
  originalSet.call(unwrap$1(this), unwrap$1(v));
1694
1700
  };
1695
1701
 
1696
- setterMap.set(originalSet, set);
1702
+ setterMap$1.set(originalSet, set);
1697
1703
  reverseSetterMap.set(set, originalSet);
1698
1704
  return set;
1699
1705
  }
@@ -1734,7 +1740,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1734
1740
  return unwrap$1(redGet.call(handler.wrapValue(this)));
1735
1741
  };
1736
1742
 
1737
- getterMap.set(get, redGet);
1743
+ getterMap$1.set(get, redGet);
1738
1744
  reverseGetterMap.set(redGet, get);
1739
1745
  return get;
1740
1746
  }
@@ -1753,7 +1759,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1753
1759
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
1754
1760
  };
1755
1761
 
1756
- setterMap.set(set, redSet);
1762
+ setterMap$1.set(set, redSet);
1757
1763
  reverseSetterMap.set(redSet, set);
1758
1764
  return set;
1759
1765
  }
@@ -1794,6 +1800,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1794
1800
  }
1795
1801
 
1796
1802
  setPrototypeOf(shadowTarget, prototype) {
1803
+ /* istanbul ignore else */
1797
1804
  if (process.env.NODE_ENV !== 'production') {
1798
1805
  throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
1799
1806
  }
@@ -1807,6 +1814,11 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1807
1814
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
1808
1815
  // the preventExtension call, in which case we should not attempt to lock down
1809
1816
  // the shadow target.
1817
+ // TODO: It should not actually be possible to reach this `if` statement.
1818
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
1819
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
1820
+
1821
+ /* istanbul ignore if */
1810
1822
 
1811
1823
  if (isExtensible(originalTarget)) {
1812
1824
  return false;
@@ -1848,8 +1860,8 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1848
1860
 
1849
1861
  }
1850
1862
 
1851
- const getterMap$1 = new WeakMap();
1852
- const setterMap$1 = new WeakMap();
1863
+ const getterMap = new WeakMap();
1864
+ const setterMap = new WeakMap();
1853
1865
 
1854
1866
  class ReadOnlyHandler extends BaseProxyHandler {
1855
1867
  wrapValue(value) {
@@ -1857,7 +1869,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
1857
1869
  }
1858
1870
 
1859
1871
  wrapGetter(originalGet) {
1860
- const wrappedGetter = getterMap$1.get(originalGet);
1872
+ const wrappedGetter = getterMap.get(originalGet);
1861
1873
 
1862
1874
  if (!isUndefined(wrappedGetter)) {
1863
1875
  return wrappedGetter;
@@ -1870,12 +1882,12 @@ class ReadOnlyHandler extends BaseProxyHandler {
1870
1882
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1871
1883
  };
1872
1884
 
1873
- getterMap$1.set(originalGet, get);
1885
+ getterMap.set(originalGet, get);
1874
1886
  return get;
1875
1887
  }
1876
1888
 
1877
1889
  wrapSetter(originalSet) {
1878
- const wrappedSetter = setterMap$1.get(originalSet);
1890
+ const wrappedSetter = setterMap.get(originalSet);
1879
1891
 
1880
1892
  if (!isUndefined(wrappedSetter)) {
1881
1893
  return wrappedSetter;
@@ -1884,6 +1896,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
1884
1896
  const handler = this;
1885
1897
 
1886
1898
  const set = function (v) {
1899
+ /* istanbul ignore else */
1887
1900
  if (process.env.NODE_ENV !== 'production') {
1888
1901
  const {
1889
1902
  originalTarget
@@ -1892,33 +1905,41 @@ class ReadOnlyHandler extends BaseProxyHandler {
1892
1905
  }
1893
1906
  };
1894
1907
 
1895
- setterMap$1.set(originalSet, set);
1908
+ setterMap.set(originalSet, set);
1896
1909
  return set;
1897
1910
  }
1898
1911
 
1899
1912
  set(shadowTarget, key, value) {
1913
+ /* istanbul ignore else */
1900
1914
  if (process.env.NODE_ENV !== 'production') {
1901
1915
  const {
1902
1916
  originalTarget
1903
1917
  } = this;
1904
- throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1918
+ 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.`;
1919
+ throw new Error(msg);
1905
1920
  }
1921
+ /* istanbul ignore next */
1922
+
1906
1923
 
1907
1924
  return false;
1908
1925
  }
1909
1926
 
1910
1927
  deleteProperty(shadowTarget, key) {
1928
+ /* istanbul ignore else */
1911
1929
  if (process.env.NODE_ENV !== 'production') {
1912
1930
  const {
1913
1931
  originalTarget
1914
1932
  } = this;
1915
1933
  throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1916
1934
  }
1935
+ /* istanbul ignore next */
1936
+
1917
1937
 
1918
1938
  return false;
1919
1939
  }
1920
1940
 
1921
1941
  setPrototypeOf(shadowTarget, prototype) {
1942
+ /* istanbul ignore else */
1922
1943
  if (process.env.NODE_ENV !== 'production') {
1923
1944
  const {
1924
1945
  originalTarget
@@ -1928,23 +1949,29 @@ class ReadOnlyHandler extends BaseProxyHandler {
1928
1949
  }
1929
1950
 
1930
1951
  preventExtensions(shadowTarget) {
1952
+ /* istanbul ignore else */
1931
1953
  if (process.env.NODE_ENV !== 'production') {
1932
1954
  const {
1933
1955
  originalTarget
1934
1956
  } = this;
1935
1957
  throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
1936
1958
  }
1959
+ /* istanbul ignore next */
1960
+
1937
1961
 
1938
1962
  return false;
1939
1963
  }
1940
1964
 
1941
1965
  defineProperty(shadowTarget, key, descriptor) {
1966
+ /* istanbul ignore else */
1942
1967
  if (process.env.NODE_ENV !== 'production') {
1943
1968
  const {
1944
1969
  originalTarget
1945
1970
  } = this;
1946
1971
  throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1947
1972
  }
1973
+ /* istanbul ignore next */
1974
+
1948
1975
 
1949
1976
  return false;
1950
1977
  }
@@ -2002,6 +2029,8 @@ const formatter = {
2002
2029
  }; // Inspired from paulmillr/es6-shim
2003
2030
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2004
2031
 
2032
+ /* istanbul ignore next */
2033
+
2005
2034
  function getGlobal() {
2006
2035
  // the only reliable means to get the global object is `Function('return this')()`
2007
2036
  // However, this causes CSP violations in Chrome apps.
@@ -2026,6 +2055,7 @@ function getGlobal() {
2026
2055
  }
2027
2056
 
2028
2057
  function init() {
2058
+ /* istanbul ignore if */
2029
2059
  if (process.env.NODE_ENV === 'production') {
2030
2060
  // this method should never leak to prod
2031
2061
  throw new ReferenceError();
@@ -2040,6 +2070,8 @@ function init() {
2040
2070
  ArrayPush.call(devtoolsFormatters, formatter);
2041
2071
  global.devtoolsFormatters = devtoolsFormatters;
2042
2072
  }
2073
+ /* istanbul ignore else */
2074
+
2043
2075
 
2044
2076
  if (process.env.NODE_ENV !== 'production') {
2045
2077
  init();
@@ -2086,7 +2118,8 @@ class ReactiveMembrane {
2086
2118
  this.valueMutated = defaultValueMutated;
2087
2119
  this.valueObserved = defaultValueObserved;
2088
2120
  this.valueIsObservable = defaultValueIsObservable;
2089
- this.objectGraph = new WeakMap();
2121
+ this.readOnlyObjectGraph = new WeakMap();
2122
+ this.reactiveObjectGraph = new WeakMap();
2090
2123
 
2091
2124
  if (!isUndefined(options)) {
2092
2125
  const {
@@ -2109,10 +2142,13 @@ class ReactiveMembrane {
2109
2142
  const distorted = this.valueDistortion(unwrappedValue);
2110
2143
 
2111
2144
  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.
2145
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2146
+ // when trying to extract the writable version of a readonly
2147
+ // we return the readonly.
2148
+ return value;
2149
+ }
2114
2150
 
2115
- return o.readOnly === value ? value : o.reactive;
2151
+ return this.getReactiveHandler(unwrappedValue, distorted);
2116
2152
  }
2117
2153
 
2118
2154
  return distorted;
@@ -2123,7 +2159,7 @@ class ReactiveMembrane {
2123
2159
  const distorted = this.valueDistortion(value);
2124
2160
 
2125
2161
  if (this.valueIsObservable(distorted)) {
2126
- return this.getReactiveState(value, distorted).readOnly;
2162
+ return this.getReadOnlyHandler(value, distorted);
2127
2163
  }
2128
2164
 
2129
2165
  return distorted;
@@ -2133,47 +2169,36 @@ class ReactiveMembrane {
2133
2169
  return unwrap$1(p);
2134
2170
  }
2135
2171
 
2136
- getReactiveState(value, distortedValue) {
2137
- const {
2138
- objectGraph
2139
- } = this;
2140
- let reactiveState = objectGraph.get(distortedValue);
2172
+ getReactiveHandler(value, distortedValue) {
2173
+ let proxy = this.reactiveObjectGraph.get(distortedValue);
2141
2174
 
2142
- if (reactiveState) {
2143
- return reactiveState;
2175
+ if (isUndefined(proxy)) {
2176
+ // caching the proxy after the first time it is accessed
2177
+ const handler = new ReactiveProxyHandler(this, distortedValue);
2178
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2179
+ registerProxy(proxy, value);
2180
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2144
2181
  }
2145
2182
 
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
- },
2183
+ return proxy;
2184
+ }
2158
2185
 
2159
- get readOnly() {
2160
- const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2186
+ getReadOnlyHandler(value, distortedValue) {
2187
+ let proxy = this.readOnlyObjectGraph.get(distortedValue);
2161
2188
 
2162
- const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2163
- registerProxy(proxy, value);
2164
- ObjectDefineProperty(this, 'readOnly', {
2165
- value: proxy
2166
- });
2167
- return proxy;
2168
- }
2189
+ if (isUndefined(proxy)) {
2190
+ // caching the proxy after the first time it is accessed
2191
+ const handler = new ReadOnlyHandler(this, distortedValue);
2192
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2193
+ registerProxy(proxy, value);
2194
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2195
+ }
2169
2196
 
2170
- };
2171
- objectGraph.set(distortedValue, reactiveState);
2172
- return reactiveState;
2197
+ return proxy;
2173
2198
  }
2174
2199
 
2175
2200
  }
2176
- /** version: 1.0.0 */
2201
+ /** version: 1.1.5 */
2177
2202
 
2178
2203
  /*
2179
2204
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4283,7 +4308,7 @@ function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4283
4308
  for (const [attrName, attrValue] of Object.entries(attrs)) {
4284
4309
  const elmAttrValue = renderer.getAttribute(elm, attrName);
4285
4310
 
4286
- if (attrValue !== elmAttrValue) {
4311
+ if (String(attrValue) !== elmAttrValue) {
4287
4312
  logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
4288
4313
  nodesAreCompatible = false;
4289
4314
  }
@@ -4305,7 +4330,7 @@ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4305
4330
  let nodesAreCompatible = true;
4306
4331
  let vnodeClassName;
4307
4332
 
4308
- if (!shared.isUndefined(className) && className !== elm.className) {
4333
+ if (!shared.isUndefined(className) && String(className) !== elm.className) {
4309
4334
  // className is used when class is bound to an expr.
4310
4335
  nodesAreCompatible = false;
4311
4336
  vnodeClassName = className;
@@ -5100,7 +5125,7 @@ function co(text) {
5100
5125
 
5101
5126
 
5102
5127
  function d(value) {
5103
- return value == null ? '' : value;
5128
+ return value == null ? '' : String(value);
5104
5129
  } // [b]ind function
5105
5130
 
5106
5131
 
@@ -5475,7 +5500,7 @@ function createStylesheet(vm, stylesheets) {
5475
5500
  for (let i = 0; i < stylesheets.length; i++) {
5476
5501
  renderer.insertGlobalStylesheet(stylesheets[i]);
5477
5502
  }
5478
- } else if (renderer.ssr || renderer.isHydrating) {
5503
+ } else if (renderer.ssr || renderer.isHydrating()) {
5479
5504
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
5480
5505
  // This works in the client, because the stylesheets are created, and cached in the VM
5481
5506
  // the first time the VM renders.
@@ -7185,4 +7210,4 @@ exports.swapTemplate = swapTemplate;
7185
7210
  exports.track = track;
7186
7211
  exports.unwrap = unwrap;
7187
7212
  exports.wire = wire;
7188
- /* version: 2.5.8 */
7213
+ /* version: 2.5.11 */
@@ -1428,7 +1428,6 @@ const {
1428
1428
  getPrototypeOf,
1429
1429
  create: ObjectCreate,
1430
1430
  defineProperty: ObjectDefineProperty,
1431
- defineProperties: ObjectDefineProperties,
1432
1431
  isExtensible,
1433
1432
  getOwnPropertyDescriptor,
1434
1433
  getOwnPropertyNames,
@@ -1438,8 +1437,7 @@ const {
1438
1437
  } = Object;
1439
1438
  const {
1440
1439
  push: ArrayPush,
1441
- concat: ArrayConcat,
1442
- map: ArrayMap
1440
+ concat: ArrayConcat
1443
1441
  } = Array.prototype;
1444
1442
  const OtS = {}.toString;
1445
1443
 
@@ -1504,7 +1502,9 @@ class BaseProxyHandler {
1504
1502
  // but it will always be compatible with the previous descriptor
1505
1503
  // to preserve the object invariants, which makes these lines safe.
1506
1504
 
1507
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
1505
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1506
+
1507
+ /* istanbul ignore else */
1508
1508
 
1509
1509
  if (!isUndefined(originalDescriptor)) {
1510
1510
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1532,11 +1532,17 @@ class BaseProxyHandler {
1532
1532
 
1533
1533
  preventExtensions(shadowTarget);
1534
1534
  } // Shared Traps
1535
+ // TODO: apply() is never called
1536
+
1537
+ /* istanbul ignore next */
1535
1538
 
1536
1539
 
1537
1540
  apply(shadowTarget, thisArg, argArray) {
1538
1541
  /* No op */
1539
- }
1542
+ } // TODO: construct() is never called
1543
+
1544
+ /* istanbul ignore next */
1545
+
1540
1546
 
1541
1547
  construct(shadowTarget, argArray, newTarget) {
1542
1548
  /* No op */
@@ -1649,8 +1655,8 @@ class BaseProxyHandler {
1649
1655
 
1650
1656
  }
1651
1657
 
1652
- const getterMap = new WeakMap();
1653
- const setterMap = new WeakMap();
1658
+ const getterMap$1 = new WeakMap();
1659
+ const setterMap$1 = new WeakMap();
1654
1660
  const reverseGetterMap = new WeakMap();
1655
1661
  const reverseSetterMap = new WeakMap();
1656
1662
 
@@ -1660,7 +1666,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1660
1666
  }
1661
1667
 
1662
1668
  wrapGetter(originalGet) {
1663
- const wrappedGetter = getterMap.get(originalGet);
1669
+ const wrappedGetter = getterMap$1.get(originalGet);
1664
1670
 
1665
1671
  if (!isUndefined(wrappedGetter)) {
1666
1672
  return wrappedGetter;
@@ -1673,13 +1679,13 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1673
1679
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1674
1680
  };
1675
1681
 
1676
- getterMap.set(originalGet, get);
1682
+ getterMap$1.set(originalGet, get);
1677
1683
  reverseGetterMap.set(get, originalGet);
1678
1684
  return get;
1679
1685
  }
1680
1686
 
1681
1687
  wrapSetter(originalSet) {
1682
- const wrappedSetter = setterMap.get(originalSet);
1688
+ const wrappedSetter = setterMap$1.get(originalSet);
1683
1689
 
1684
1690
  if (!isUndefined(wrappedSetter)) {
1685
1691
  return wrappedSetter;
@@ -1690,7 +1696,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1690
1696
  originalSet.call(unwrap$1(this), unwrap$1(v));
1691
1697
  };
1692
1698
 
1693
- setterMap.set(originalSet, set);
1699
+ setterMap$1.set(originalSet, set);
1694
1700
  reverseSetterMap.set(set, originalSet);
1695
1701
  return set;
1696
1702
  }
@@ -1731,7 +1737,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1731
1737
  return unwrap$1(redGet.call(handler.wrapValue(this)));
1732
1738
  };
1733
1739
 
1734
- getterMap.set(get, redGet);
1740
+ getterMap$1.set(get, redGet);
1735
1741
  reverseGetterMap.set(redGet, get);
1736
1742
  return get;
1737
1743
  }
@@ -1750,7 +1756,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1750
1756
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
1751
1757
  };
1752
1758
 
1753
- setterMap.set(set, redSet);
1759
+ setterMap$1.set(set, redSet);
1754
1760
  reverseSetterMap.set(redSet, set);
1755
1761
  return set;
1756
1762
  }
@@ -1791,6 +1797,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1791
1797
  }
1792
1798
 
1793
1799
  setPrototypeOf(shadowTarget, prototype) {
1800
+ /* istanbul ignore else */
1794
1801
  if (process.env.NODE_ENV !== 'production') {
1795
1802
  throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
1796
1803
  }
@@ -1804,6 +1811,11 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1804
1811
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
1805
1812
  // the preventExtension call, in which case we should not attempt to lock down
1806
1813
  // the shadow target.
1814
+ // TODO: It should not actually be possible to reach this `if` statement.
1815
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
1816
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
1817
+
1818
+ /* istanbul ignore if */
1807
1819
 
1808
1820
  if (isExtensible(originalTarget)) {
1809
1821
  return false;
@@ -1845,8 +1857,8 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1845
1857
 
1846
1858
  }
1847
1859
 
1848
- const getterMap$1 = new WeakMap();
1849
- const setterMap$1 = new WeakMap();
1860
+ const getterMap = new WeakMap();
1861
+ const setterMap = new WeakMap();
1850
1862
 
1851
1863
  class ReadOnlyHandler extends BaseProxyHandler {
1852
1864
  wrapValue(value) {
@@ -1854,7 +1866,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
1854
1866
  }
1855
1867
 
1856
1868
  wrapGetter(originalGet) {
1857
- const wrappedGetter = getterMap$1.get(originalGet);
1869
+ const wrappedGetter = getterMap.get(originalGet);
1858
1870
 
1859
1871
  if (!isUndefined(wrappedGetter)) {
1860
1872
  return wrappedGetter;
@@ -1867,12 +1879,12 @@ class ReadOnlyHandler extends BaseProxyHandler {
1867
1879
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1868
1880
  };
1869
1881
 
1870
- getterMap$1.set(originalGet, get);
1882
+ getterMap.set(originalGet, get);
1871
1883
  return get;
1872
1884
  }
1873
1885
 
1874
1886
  wrapSetter(originalSet) {
1875
- const wrappedSetter = setterMap$1.get(originalSet);
1887
+ const wrappedSetter = setterMap.get(originalSet);
1876
1888
 
1877
1889
  if (!isUndefined(wrappedSetter)) {
1878
1890
  return wrappedSetter;
@@ -1881,6 +1893,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
1881
1893
  const handler = this;
1882
1894
 
1883
1895
  const set = function (v) {
1896
+ /* istanbul ignore else */
1884
1897
  if (process.env.NODE_ENV !== 'production') {
1885
1898
  const {
1886
1899
  originalTarget
@@ -1889,33 +1902,41 @@ class ReadOnlyHandler extends BaseProxyHandler {
1889
1902
  }
1890
1903
  };
1891
1904
 
1892
- setterMap$1.set(originalSet, set);
1905
+ setterMap.set(originalSet, set);
1893
1906
  return set;
1894
1907
  }
1895
1908
 
1896
1909
  set(shadowTarget, key, value) {
1910
+ /* istanbul ignore else */
1897
1911
  if (process.env.NODE_ENV !== 'production') {
1898
1912
  const {
1899
1913
  originalTarget
1900
1914
  } = this;
1901
- throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1915
+ 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.`;
1916
+ throw new Error(msg);
1902
1917
  }
1918
+ /* istanbul ignore next */
1919
+
1903
1920
 
1904
1921
  return false;
1905
1922
  }
1906
1923
 
1907
1924
  deleteProperty(shadowTarget, key) {
1925
+ /* istanbul ignore else */
1908
1926
  if (process.env.NODE_ENV !== 'production') {
1909
1927
  const {
1910
1928
  originalTarget
1911
1929
  } = this;
1912
1930
  throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1913
1931
  }
1932
+ /* istanbul ignore next */
1933
+
1914
1934
 
1915
1935
  return false;
1916
1936
  }
1917
1937
 
1918
1938
  setPrototypeOf(shadowTarget, prototype) {
1939
+ /* istanbul ignore else */
1919
1940
  if (process.env.NODE_ENV !== 'production') {
1920
1941
  const {
1921
1942
  originalTarget
@@ -1925,23 +1946,29 @@ class ReadOnlyHandler extends BaseProxyHandler {
1925
1946
  }
1926
1947
 
1927
1948
  preventExtensions(shadowTarget) {
1949
+ /* istanbul ignore else */
1928
1950
  if (process.env.NODE_ENV !== 'production') {
1929
1951
  const {
1930
1952
  originalTarget
1931
1953
  } = this;
1932
1954
  throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
1933
1955
  }
1956
+ /* istanbul ignore next */
1957
+
1934
1958
 
1935
1959
  return false;
1936
1960
  }
1937
1961
 
1938
1962
  defineProperty(shadowTarget, key, descriptor) {
1963
+ /* istanbul ignore else */
1939
1964
  if (process.env.NODE_ENV !== 'production') {
1940
1965
  const {
1941
1966
  originalTarget
1942
1967
  } = this;
1943
1968
  throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1944
1969
  }
1970
+ /* istanbul ignore next */
1971
+
1945
1972
 
1946
1973
  return false;
1947
1974
  }
@@ -1999,6 +2026,8 @@ const formatter = {
1999
2026
  }; // Inspired from paulmillr/es6-shim
2000
2027
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2001
2028
 
2029
+ /* istanbul ignore next */
2030
+
2002
2031
  function getGlobal() {
2003
2032
  // the only reliable means to get the global object is `Function('return this')()`
2004
2033
  // However, this causes CSP violations in Chrome apps.
@@ -2023,6 +2052,7 @@ function getGlobal() {
2023
2052
  }
2024
2053
 
2025
2054
  function init() {
2055
+ /* istanbul ignore if */
2026
2056
  if (process.env.NODE_ENV === 'production') {
2027
2057
  // this method should never leak to prod
2028
2058
  throw new ReferenceError();
@@ -2037,6 +2067,8 @@ function init() {
2037
2067
  ArrayPush.call(devtoolsFormatters, formatter);
2038
2068
  global.devtoolsFormatters = devtoolsFormatters;
2039
2069
  }
2070
+ /* istanbul ignore else */
2071
+
2040
2072
 
2041
2073
  if (process.env.NODE_ENV !== 'production') {
2042
2074
  init();
@@ -2083,7 +2115,8 @@ class ReactiveMembrane {
2083
2115
  this.valueMutated = defaultValueMutated;
2084
2116
  this.valueObserved = defaultValueObserved;
2085
2117
  this.valueIsObservable = defaultValueIsObservable;
2086
- this.objectGraph = new WeakMap();
2118
+ this.readOnlyObjectGraph = new WeakMap();
2119
+ this.reactiveObjectGraph = new WeakMap();
2087
2120
 
2088
2121
  if (!isUndefined(options)) {
2089
2122
  const {
@@ -2106,10 +2139,13 @@ class ReactiveMembrane {
2106
2139
  const distorted = this.valueDistortion(unwrappedValue);
2107
2140
 
2108
2141
  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.
2142
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2143
+ // when trying to extract the writable version of a readonly
2144
+ // we return the readonly.
2145
+ return value;
2146
+ }
2111
2147
 
2112
- return o.readOnly === value ? value : o.reactive;
2148
+ return this.getReactiveHandler(unwrappedValue, distorted);
2113
2149
  }
2114
2150
 
2115
2151
  return distorted;
@@ -2120,7 +2156,7 @@ class ReactiveMembrane {
2120
2156
  const distorted = this.valueDistortion(value);
2121
2157
 
2122
2158
  if (this.valueIsObservable(distorted)) {
2123
- return this.getReactiveState(value, distorted).readOnly;
2159
+ return this.getReadOnlyHandler(value, distorted);
2124
2160
  }
2125
2161
 
2126
2162
  return distorted;
@@ -2130,47 +2166,36 @@ class ReactiveMembrane {
2130
2166
  return unwrap$1(p);
2131
2167
  }
2132
2168
 
2133
- getReactiveState(value, distortedValue) {
2134
- const {
2135
- objectGraph
2136
- } = this;
2137
- let reactiveState = objectGraph.get(distortedValue);
2169
+ getReactiveHandler(value, distortedValue) {
2170
+ let proxy = this.reactiveObjectGraph.get(distortedValue);
2138
2171
 
2139
- if (reactiveState) {
2140
- return reactiveState;
2172
+ if (isUndefined(proxy)) {
2173
+ // caching the proxy after the first time it is accessed
2174
+ const handler = new ReactiveProxyHandler(this, distortedValue);
2175
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2176
+ registerProxy(proxy, value);
2177
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2141
2178
  }
2142
2179
 
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
- },
2180
+ return proxy;
2181
+ }
2155
2182
 
2156
- get readOnly() {
2157
- const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2183
+ getReadOnlyHandler(value, distortedValue) {
2184
+ let proxy = this.readOnlyObjectGraph.get(distortedValue);
2158
2185
 
2159
- const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2160
- registerProxy(proxy, value);
2161
- ObjectDefineProperty(this, 'readOnly', {
2162
- value: proxy
2163
- });
2164
- return proxy;
2165
- }
2186
+ if (isUndefined(proxy)) {
2187
+ // caching the proxy after the first time it is accessed
2188
+ const handler = new ReadOnlyHandler(this, distortedValue);
2189
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2190
+ registerProxy(proxy, value);
2191
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2192
+ }
2166
2193
 
2167
- };
2168
- objectGraph.set(distortedValue, reactiveState);
2169
- return reactiveState;
2194
+ return proxy;
2170
2195
  }
2171
2196
 
2172
2197
  }
2173
- /** version: 1.0.0 */
2198
+ /** version: 1.1.5 */
2174
2199
 
2175
2200
  /*
2176
2201
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4280,7 +4305,7 @@ function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4280
4305
  for (const [attrName, attrValue] of Object.entries(attrs)) {
4281
4306
  const elmAttrValue = renderer.getAttribute(elm, attrName);
4282
4307
 
4283
- if (attrValue !== elmAttrValue) {
4308
+ if (String(attrValue) !== elmAttrValue) {
4284
4309
  logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
4285
4310
  nodesAreCompatible = false;
4286
4311
  }
@@ -4302,7 +4327,7 @@ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4302
4327
  let nodesAreCompatible = true;
4303
4328
  let vnodeClassName;
4304
4329
 
4305
- if (!isUndefined$1(className) && className !== elm.className) {
4330
+ if (!isUndefined$1(className) && String(className) !== elm.className) {
4306
4331
  // className is used when class is bound to an expr.
4307
4332
  nodesAreCompatible = false;
4308
4333
  vnodeClassName = className;
@@ -5097,7 +5122,7 @@ function co(text) {
5097
5122
 
5098
5123
 
5099
5124
  function d(value) {
5100
- return value == null ? '' : value;
5125
+ return value == null ? '' : String(value);
5101
5126
  } // [b]ind function
5102
5127
 
5103
5128
 
@@ -5472,7 +5497,7 @@ function createStylesheet(vm, stylesheets) {
5472
5497
  for (let i = 0; i < stylesheets.length; i++) {
5473
5498
  renderer.insertGlobalStylesheet(stylesheets[i]);
5474
5499
  }
5475
- } else if (renderer.ssr || renderer.isHydrating) {
5500
+ } else if (renderer.ssr || renderer.isHydrating()) {
5476
5501
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
5477
5502
  // This works in the client, because the stylesheets are created, and cached in the VM
5478
5503
  // the first time the VM renders.
@@ -7149,4 +7174,4 @@ function setHooks(hooks) {
7149
7174
  }
7150
7175
 
7151
7176
  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.8 */
7177
+ /* version: 2.5.11 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.5.8",
3
+ "version": "2.5.11",
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.8",
28
- "@lwc/shared": "2.5.8"
27
+ "@lwc/features": "2.5.11",
28
+ "@lwc/shared": "2.5.11"
29
29
  },
30
30
  "devDependencies": {
31
- "observable-membrane": "1.0.1"
31
+ "observable-membrane": "1.1.5"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "223513a6a4e070b3243db0a345024a184f82dc08"
36
+ "gitHead": "2e72bcacbf105ef92277372bb4e52f8280d7fa72"
37
37
  }
@@ -12,7 +12,7 @@ declare function i(iterable: Iterable<any>, factory: (value: any, index: number,
12
12
  declare function f(items: any[]): any[];
13
13
  declare function t(text: string): VText;
14
14
  declare function co(text: string): VComment;
15
- declare function d(value: any): string | any;
15
+ declare function d(value: any): string;
16
16
  declare function b(fn: EventListener): EventListener;
17
17
  declare function k(compilerKey: number, obj: any): string | void;
18
18
  declare function gid(id: string | undefined | null): string | null | undefined;
@@ -2,7 +2,7 @@ export declare type HostNode = any;
2
2
  export declare type HostElement = any;
3
3
  export interface Renderer<N = HostNode, E = HostElement> {
4
4
  ssr: boolean;
5
- readonly isHydrating: boolean;
5
+ isHydrating(): boolean;
6
6
  isNativeShadowDefined: boolean;
7
7
  isSyntheticShadowDefined: boolean;
8
8
  insert(node: N, parent: E, anchor: N | null): void;