@@ -79,7 +79,6 @@ export default function createTree(
79
79
currentFiberNode : Fiber ,
80
80
circularComponentTable : Set < Fiber > = new Set ( ) ,
81
81
tree : Tree = new Tree ( 'root' , 'root' ) ,
82
- fromSibling = false ,
83
82
) : Tree {
84
83
// Base Case: if has visited the component, return
85
84
if ( circularComponentTable . has ( currentFiberNode ) ) {
@@ -109,6 +108,7 @@ export default function createTree(
109
108
elementType ?. render ?. name ||
110
109
elementType ?. name ||
111
110
'nameless' ;
111
+ console . log ( 'createTree' , { tree } ) ;
112
112
// console.log('LinkFiber', {
113
113
// currentFiberNode,
114
114
// // tag,
@@ -148,10 +148,6 @@ export default function createTree(
148
148
context : { } ,
149
149
} ;
150
150
let isStatefulComponent = false ;
151
- /**
152
- * The updated tree after adding the `componentData` obtained from `currentFiberNode`
153
- */
154
- let newNode : Tree ;
155
151
156
152
// ----------------APPEND PROP DATA FROM REACT DEV TOOL-----------------------
157
153
// check to see if the parent component has any state/props
@@ -295,6 +291,11 @@ export default function createTree(
295
291
* `rtid` - The `Root ID` is a unique identifier that is assigned to each React root instance in a React application.
296
292
*/
297
293
let rtid : string | null = null ;
294
+ /**
295
+ * The updated tree after adding the `componentData` obtained from `currentFiberNode`
296
+ */
297
+ let newNode : Tree = tree ;
298
+ let parentNode : Tree ;
298
299
// We want to add this fiber node to the snapshot
299
300
if (
300
301
( isStatefulComponent || newState === 'stateless' ) &&
@@ -305,7 +306,7 @@ export default function createTree(
305
306
rtid = `fromLinkFiber${ rtidCounter } ` ;
306
307
// rtid = rtidCounter;
307
308
// check if rtid is already present
308
- // remove existing rtid before adding a new one
309
+ // remove existing rtid before adding a new one
309
310
if ( currentFiberNode . child . stateNode . classList . length > 0 ) {
310
311
const lastClass =
311
312
currentFiberNode . child . stateNode . classList [
@@ -318,14 +319,9 @@ export default function createTree(
318
319
currentFiberNode . child . stateNode . classList . add ( rtid ) ;
319
320
}
320
321
rtidCounter += 1 ; // I THINK THIS SHOULD BE UP IN THE IF STATEMENT. Still unsure the use of rtid
321
- // checking if tree fromSibling is true
322
- if ( fromSibling ) {
323
- newNode = tree . addSibling ( newState , componentName , componentData , rtid ) ;
324
- } else {
325
- newNode = tree . addChild ( newState , componentName , componentData , rtid ) ;
326
- }
327
- } else {
328
- newNode = tree ;
322
+
323
+ // Append the childNode to the tree
324
+ [ parentNode , newNode ] = tree . addChild ( newState , componentName , componentData , rtid ) ;
329
325
}
330
326
331
327
// ----------------------TRAVERSE TO NEXT FIBERNODE---------------------------
@@ -334,12 +330,14 @@ export default function createTree(
334
330
335
331
// If currentFiberNode has siblings, recurse on siblings
336
332
if ( sibling ) {
333
+ // If the component was not filtered, add the sibling to the parentNode
337
334
if (
338
335
( isStatefulComponent || newState === 'stateless' ) &&
339
336
! nextJSDefaultComponent . has ( componentName )
340
337
)
341
- createTree ( sibling , circularComponentTable , newNode , true ) ;
342
- else createTree ( sibling , circularComponentTable , newNode , fromSibling ) ;
338
+ createTree ( sibling , circularComponentTable , parentNode ) ;
339
+
340
+ else createTree ( sibling , circularComponentTable , newNode ) ;
343
341
}
344
342
345
343
// -------------RETURN THE TREE OUTPUT & PASS TO FRONTEND FOR RENDERING-------
0 commit comments