ks-fwork 2.0.0 → 2.0.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/patch-dom.js +7 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ks-fwork",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Demo Frontend Framework",
5
5
  "license": "ISC",
6
6
  "author": "",
package/src/patch-dom.js CHANGED
@@ -11,7 +11,7 @@ import { addEventListener } from "./events.js";
11
11
  export function patchDOM(oldVNode, newVNode, parentEl) {
12
12
  if (!areNodesEqual(oldVNode, newVNode)) {
13
13
  const index = findIndexInParent(parentEl, oldVNode.el);
14
- destroyDOM();
14
+ destroyDOM(oldVNode);
15
15
  mountDOM(newVNode, parentEl, index);
16
16
 
17
17
  return newVNode;
@@ -61,14 +61,14 @@ function patchElement(oldVNode, newVNode) {
61
61
  style: oldStyle,
62
62
  on: oldEvents,
63
63
  ...oldAttrs
64
- } = oldVNode.props
64
+ } = oldVNode.props;
65
65
 
66
66
  const {
67
67
  class: newClass,
68
68
  style: newStyle,
69
69
  on: newEvents,
70
70
  ...newAttrs
71
- } = newVNode.props
71
+ } = newVNode.props;
72
72
 
73
73
  const { listeners: oldListeners } = oldVNode;
74
74
 
@@ -148,7 +148,7 @@ function patchChildren(oldVNode, newVNode) {
148
148
  const diffSeq = arraysDiffSequence(oldChildren, newChildren, areNodesEqual);
149
149
 
150
150
  for (const operation of diffSeq) {
151
- const { from, index, item } = operation;
151
+ const { originalIndex, from, index, item } = operation;
152
152
 
153
153
  switch (operation.op) {
154
154
  case ARRAY_DIFF_OP.ADD: {
@@ -166,12 +166,13 @@ function patchChildren(oldVNode, newVNode) {
166
166
  const elAtTargetIndex = parentEl.childNodes[index];
167
167
 
168
168
  parentEl.insertBefore(el, elAtTargetIndex);
169
- patchDOM(oldChildren[from], newChildren[index], parentEl)
169
+ patchDOM(oldChildren[from], newChildren[index], parentEl);
170
170
  break;
171
171
  }
172
172
 
173
173
  case ARRAY_DIFF_OP.NOOP: {
174
- patchDOM(oldChildren[from], newChildren[index], parentEl)
174
+ patchDOM(oldChildren[originalIndex], newChildren[index], parentEl)
175
+ break;
175
176
  }
176
177
  }
177
178
  }