webdetta 0.1.235 → 0.1.237

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webdetta",
3
- "version": "0.1.235",
3
+ "version": "0.1.237",
4
4
  "author": "Fedot Kriutchenko <fodyadev@gmail.com>",
5
5
  "description": "",
6
6
  "license": "MIT",
@@ -15,6 +15,7 @@ const listItemsToEntries = (items, keyFn) => new Map(
15
15
  : null
16
16
  );
17
17
 
18
+ const lastNodes = new WeakMap();
18
19
  const createContainer = (content) => {
19
20
  let startNode;
20
21
 
@@ -41,8 +42,8 @@ const createContainer = (content) => {
41
42
  let lastNode = startNode = newStartNode;
42
43
  if (parentChanged) operatorsEffect.run();
43
44
  for (const node of nodes) {
44
- if (node !== lastNode.nextSibling) Element.appendAfter(lastNode, node);
45
- lastNode = node;
45
+ if (lastNode.nextSibling !== node) Element.appendAfter(lastNode, node);
46
+ lastNode = lastNodes.get(node) ?? node;
46
47
  }
47
48
  return lastNode;
48
49
  };
@@ -96,7 +97,9 @@ export const createList = (itemsFn, renderItem, keyFn = listItemKey) => {
96
97
  export const createSlot = (content) => {
97
98
  const root = document.createTextNode('');
98
99
  const container = createContainer(content);
99
- Element.registerHook(root, 'afterAppend', () => container.appendAfter(root));
100
+ Element.registerHook(root, 'afterAppend', () => {
101
+ lastNodes.set(root, container.appendAfter(root));
102
+ });
100
103
  Element.registerHook(root, 'beforeRemove', () => container.remove());
101
104
  return root;
102
105
  }