@estjs/template 0.0.16-beta.6 → 0.0.16-beta.8

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.
@@ -852,12 +852,14 @@ var Component = class {
852
852
  if (!root) return;
853
853
  this.releaseSpecialProps();
854
854
  for (const key of Object.getOwnPropertyNames(props)) {
855
- const value = readProp(props, key);
856
855
  if (key === REF_KEY) {
856
+ const value = readProp(props, key);
857
857
  this.rootRefCleanup = this.bindRootRef(value, root);
858
858
  continue;
859
859
  }
860
- if (isOn(key) && isFunction(value)) {
860
+ if (isOn(key)) {
861
+ const value = readProp(props, key);
862
+ if (!isFunction(value)) continue;
861
863
  const eventName = key.slice(2).toLowerCase();
862
864
  this.rootEventCleanups.push(addEvent(root, eventName, value));
863
865
  }
@@ -1291,8 +1293,9 @@ function omitProps(target, keys) {
1291
1293
 
1292
1294
  // src/components/Fragment.ts
1293
1295
  function Fragment(props) {
1294
- if (!props || props.children == null) return null;
1295
- return props.children;
1296
+ const children = props == null ? void 0 : props.children;
1297
+ if (children == null) return null;
1298
+ return children;
1296
1299
  }
1297
1300
  Fragment[FRAGMENT_COMPONENT] = true;
1298
1301
  function isFragment(node) {
@@ -1816,7 +1819,7 @@ function For(props) {
1816
1819
  if (isFunction(input)) return (_b = input()) != null ? _b : [];
1817
1820
  return input != null ? input : [];
1818
1821
  };
1819
- const getKey = (item) => keyFn ? keyFn(item) : item;
1822
+ const getKey = (item, index) => keyFn ? keyFn(item, index) : item;
1820
1823
  const normalizeNodes = (value) => {
1821
1824
  if (Array.isArray(value)) {
1822
1825
  const nodes = [];
@@ -1851,14 +1854,14 @@ function For(props) {
1851
1854
  }
1852
1855
  fallbackNodes = [];
1853
1856
  };
1854
- const renderItem = (item, index, parent, before) => {
1857
+ const renderItem = (item, index, parent, before, key = getKey(item, index)) => {
1855
1858
  const parentScope = getActiveScope();
1856
1859
  const scope = createScope(parentScope);
1857
1860
  let mountedNodes = [];
1858
1861
  runWithScope(scope, () => {
1859
1862
  mountedNodes = mountValue(renderFn(item, index), parent, before);
1860
1863
  });
1861
- return { key: getKey(item), item, nodes: mountedNodes, scope };
1864
+ return { key, item, nodes: mountedNodes, scope };
1862
1865
  };
1863
1866
  const disposeItem = (entry) => {
1864
1867
  disposeScope(entry.scope);
@@ -1927,7 +1930,7 @@ function For(props) {
1927
1930
  let maxOldSeen = 0;
1928
1931
  const newKeys = new Array(newLen);
1929
1932
  for (let i = 0; i < newLen; i++) {
1930
- newKeys[i] = getKey(newItems[i]);
1933
+ newKeys[i] = getKey(newItems[i], i);
1931
1934
  }
1932
1935
  for (let i = 0; i < newLen; i++) {
1933
1936
  const item = newItems[i];
@@ -1944,11 +1947,11 @@ function For(props) {
1944
1947
  } else {
1945
1948
  if (!batchFragment) batchFragment = document.createDocumentFragment();
1946
1949
  disposeItem(reused);
1947
- newEntries[i] = renderItem(item, i, batchFragment, null);
1950
+ newEntries[i] = renderItem(item, i, batchFragment, null, key);
1948
1951
  }
1949
1952
  } else {
1950
1953
  if (!batchFragment) batchFragment = document.createDocumentFragment();
1951
- newEntries[i] = renderItem(item, i, batchFragment, null);
1954
+ newEntries[i] = renderItem(item, i, batchFragment, null, key);
1952
1955
  }
1953
1956
  }
1954
1957
  for (const list of oldKeyMap.values()) {