@unsetsoft/ryunixjs 1.0.3-nightly.6 → 1.0.3-nightly.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.
- package/dist/Ryunix.js +16 -5
- package/package.json +1 -1
- package/src/lib/commits.js +3 -0
- package/src/lib/components.js +1 -0
- package/src/lib/dom.js +6 -2
- package/src/lib/workers.js +6 -3
package/dist/Ryunix.js
CHANGED
|
@@ -165,13 +165,17 @@
|
|
|
165
165
|
* @returns A newly created DOM element based on the fiber object.
|
|
166
166
|
*/
|
|
167
167
|
const createDom = (fiber) => {
|
|
168
|
-
console.log('Creating DOM
|
|
168
|
+
console.log('Creating DOM for fiber:', fiber);
|
|
169
|
+
|
|
170
|
+
// Ensure that the fiber type is a valid HTML element or a text element
|
|
169
171
|
const dom =
|
|
170
172
|
fiber.type === RYUNIX_TYPES.TEXT_ELEMENT
|
|
171
|
-
? document.createTextNode('')
|
|
173
|
+
? document.createTextNode(fiber.props.nodeValue || '')
|
|
172
174
|
: document.createElement(fiber.type);
|
|
173
175
|
|
|
176
|
+
// Update the newly created DOM element with initial props
|
|
174
177
|
updateDom(dom, {}, fiber.props);
|
|
178
|
+
|
|
175
179
|
return dom
|
|
176
180
|
};
|
|
177
181
|
|
|
@@ -351,6 +355,9 @@
|
|
|
351
355
|
[EFFECT_TAGS.PLACEMENT]: (fiber, domParent) => {
|
|
352
356
|
if (fiber.dom != undefined) {
|
|
353
357
|
domParent.appendChild(fiber.dom);
|
|
358
|
+
console.log('Appending child DOM node:', fiber.dom);
|
|
359
|
+
} else {
|
|
360
|
+
console.error('Failed to append DOM. Fiber has no DOM:', fiber);
|
|
354
361
|
}
|
|
355
362
|
runEffects(fiber);
|
|
356
363
|
},
|
|
@@ -486,6 +493,7 @@
|
|
|
486
493
|
const updateHostComponent = (fiber) => {
|
|
487
494
|
if (!fiber.dom) {
|
|
488
495
|
fiber.dom = createDom(fiber);
|
|
496
|
+
console.log('DOM node created for host component:', fiber.dom);
|
|
489
497
|
}
|
|
490
498
|
|
|
491
499
|
reconcileChildren(fiber, fiber.props.children);
|
|
@@ -528,10 +536,13 @@
|
|
|
528
536
|
*/
|
|
529
537
|
const performUnitOfWork = (fiber) => {
|
|
530
538
|
console.log('Performing unit of work for fiber:', fiber);
|
|
539
|
+
|
|
531
540
|
const isFunctionComponent = fiber.type instanceof Function;
|
|
532
|
-
isFunctionComponent
|
|
533
|
-
|
|
534
|
-
|
|
541
|
+
if (isFunctionComponent) {
|
|
542
|
+
updateFunctionComponent(fiber);
|
|
543
|
+
} else {
|
|
544
|
+
updateHostComponent(fiber);
|
|
545
|
+
}
|
|
535
546
|
|
|
536
547
|
if (fiber.child) return fiber.child
|
|
537
548
|
let nextFiber = fiber;
|
package/package.json
CHANGED
package/src/lib/commits.js
CHANGED
|
@@ -80,6 +80,9 @@ const effectHandlers = {
|
|
|
80
80
|
[EFFECT_TAGS.PLACEMENT]: (fiber, domParent) => {
|
|
81
81
|
if (fiber.dom != undefined) {
|
|
82
82
|
domParent.appendChild(fiber.dom)
|
|
83
|
+
console.log('Appending child DOM node:', fiber.dom)
|
|
84
|
+
} else {
|
|
85
|
+
console.error('Failed to append DOM. Fiber has no DOM:', fiber)
|
|
83
86
|
}
|
|
84
87
|
runEffects(fiber)
|
|
85
88
|
},
|
package/src/lib/components.js
CHANGED
|
@@ -28,6 +28,7 @@ const updateFunctionComponent = (fiber) => {
|
|
|
28
28
|
const updateHostComponent = (fiber) => {
|
|
29
29
|
if (!fiber.dom) {
|
|
30
30
|
fiber.dom = createDom(fiber)
|
|
31
|
+
console.log('DOM node created for host component:', fiber.dom)
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
reconcileChildren(fiber, fiber.props.children)
|
package/src/lib/dom.js
CHANGED
|
@@ -14,13 +14,17 @@ import {
|
|
|
14
14
|
* @returns A newly created DOM element based on the fiber object.
|
|
15
15
|
*/
|
|
16
16
|
const createDom = (fiber) => {
|
|
17
|
-
console.log('Creating DOM
|
|
17
|
+
console.log('Creating DOM for fiber:', fiber)
|
|
18
|
+
|
|
19
|
+
// Ensure that the fiber type is a valid HTML element or a text element
|
|
18
20
|
const dom =
|
|
19
21
|
fiber.type === RYUNIX_TYPES.TEXT_ELEMENT
|
|
20
|
-
? document.createTextNode('')
|
|
22
|
+
? document.createTextNode(fiber.props.nodeValue || '')
|
|
21
23
|
: document.createElement(fiber.type)
|
|
22
24
|
|
|
25
|
+
// Update the newly created DOM element with initial props
|
|
23
26
|
updateDom(dom, {}, fiber.props)
|
|
27
|
+
|
|
24
28
|
return dom
|
|
25
29
|
}
|
|
26
30
|
|
package/src/lib/workers.js
CHANGED
|
@@ -33,10 +33,13 @@ requestIdleCallback(workLoop)
|
|
|
33
33
|
*/
|
|
34
34
|
const performUnitOfWork = (fiber) => {
|
|
35
35
|
console.log('Performing unit of work for fiber:', fiber)
|
|
36
|
+
|
|
36
37
|
const isFunctionComponent = fiber.type instanceof Function
|
|
37
|
-
isFunctionComponent
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (isFunctionComponent) {
|
|
39
|
+
updateFunctionComponent(fiber)
|
|
40
|
+
} else {
|
|
41
|
+
updateHostComponent(fiber)
|
|
42
|
+
}
|
|
40
43
|
|
|
41
44
|
if (fiber.child) return fiber.child
|
|
42
45
|
let nextFiber = fiber
|