@unsetsoft/ryunixjs 1.2.4-canary.14 → 1.2.4-canary.15

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.
@@ -592,7 +592,7 @@ const commitWork = (fiber) => {
592
592
  runEffects(fiber);
593
593
  } else if (fiber.effectTag === EFFECT_TAGS.DELETION) {
594
594
  cancelEffectsDeep(fiber);
595
- commitDeletion(fiber, domParent);
595
+ commitDeletion(fiber);
596
596
  return
597
597
  }
598
598
 
@@ -602,11 +602,13 @@ const commitWork = (fiber) => {
602
602
 
603
603
  const commitDeletion = (fiber, domParent) => {
604
604
  if (fiber.dom) {
605
- domParent.removeChild(fiber.dom);
605
+ if (fiber.dom.parentNode) {
606
+ fiber.dom.parentNode.removeChild(fiber.dom);
607
+ }
606
608
  } else {
607
609
  let child = fiber.child;
608
610
  while (child) {
609
- commitDeletion(child, domParent);
611
+ commitDeletion(child);
610
612
  child = child.sibling;
611
613
  }
612
614
  }
@@ -619,6 +621,7 @@ const reconcileChildren = (wipFiber, elements) => {
619
621
  const state = getState();
620
622
  let index = 0;
621
623
  let prevSibling;
624
+ let isFirstChild = true;
622
625
 
623
626
  // Build map of old fibers by key/index
624
627
  const oldFiberMap = new Map();
@@ -626,7 +629,7 @@ const reconcileChildren = (wipFiber, elements) => {
626
629
  let position = 0;
627
630
 
628
631
  while (oldFiber) {
629
- const key = oldFiber.key ?? `__index_${position}__`;
632
+ const key = oldFiber.key ?? `__index_${oldFiber.index ?? position}__`;
630
633
  oldFiberMap.set(key, oldFiber);
631
634
  oldFiber = oldFiber.sibling;
632
635
  position++;
@@ -657,6 +660,7 @@ const reconcileChildren = (wipFiber, elements) => {
657
660
  effectTag: EFFECT_TAGS.UPDATE,
658
661
  hooks: matchedFiber.hooks,
659
662
  key: element.key,
663
+ index,
660
664
  };
661
665
  oldFiberMap.delete(key);
662
666
  } else {
@@ -669,6 +673,7 @@ const reconcileChildren = (wipFiber, elements) => {
669
673
  alternate: null,
670
674
  effectTag: EFFECT_TAGS.PLACEMENT,
671
675
  key: element.key,
676
+ index,
672
677
  };
673
678
 
674
679
  // Mark matched fiber for deletion if exists
@@ -680,8 +685,9 @@ const reconcileChildren = (wipFiber, elements) => {
680
685
  }
681
686
 
682
687
  // Link fibers
683
- if (index === 0) {
688
+ if (isFirstChild) {
684
689
  wipFiber.child = newFiber;
690
+ isFirstChild = false;
685
691
  } else if (newFiber) {
686
692
  prevSibling.sibling = newFiber;
687
693
  }
@@ -803,14 +809,10 @@ const useReducer = (reducer, initialState, init) => {
803
809
  hook.queue.push(action);
804
810
 
805
811
  const currentState = getState();
806
- currentState.wipRoot = currentState.currentRoot ? {
812
+ currentState.wipRoot = {
807
813
  dom: currentState.currentRoot.dom,
808
814
  props: currentState.currentRoot.props,
809
815
  alternate: currentState.currentRoot,
810
- } : {
811
- dom: currentState.wipRoot ? currentState.wipRoot.dom : currentState.containerRoot,
812
- props: currentState.wipRoot ? currentState.wipRoot.props : { children: [] },
813
- alternate: null,
814
816
  };
815
817
  currentState.deletions = [];
816
818
  currentState.hookIndex = 0;