@unsetsoft/ryunixjs 1.0.3-nightly.7 → 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 CHANGED
@@ -165,16 +165,15 @@
165
165
  * @returns A newly created DOM element based on the fiber object.
166
166
  */
167
167
  const createDom = (fiber) => {
168
- // Log to verify fiber type before creating DOM
169
168
  console.log('Creating DOM for fiber:', fiber);
170
169
 
171
- // Check if the fiber is a text element or a regular element
170
+ // Ensure that the fiber type is a valid HTML element or a text element
172
171
  const dom =
173
172
  fiber.type === RYUNIX_TYPES.TEXT_ELEMENT
174
173
  ? document.createTextNode(fiber.props.nodeValue || '')
175
174
  : document.createElement(fiber.type);
176
175
 
177
- // Update the newly created DOM element with its initial props
176
+ // Update the newly created DOM element with initial props
178
177
  updateDom(dom, {}, fiber.props);
179
178
 
180
179
  return dom
@@ -492,13 +491,11 @@
492
491
  * @param fiber - A fiber node representing the host component (e.g., a DOM node like div, span, etc.).
493
492
  */
494
493
  const updateHostComponent = (fiber) => {
495
- // If the fiber doesn't already have a DOM node, create one
496
494
  if (!fiber.dom) {
497
495
  fiber.dom = createDom(fiber);
498
- console.log('DOM node created:', fiber.dom);
496
+ console.log('DOM node created for host component:', fiber.dom);
499
497
  }
500
498
 
501
- // Reconcile the fiber's children with its new or updated props
502
499
  reconcileChildren(fiber, fiber.props.children);
503
500
  };
504
501
 
@@ -539,10 +536,13 @@
539
536
  */
540
537
  const performUnitOfWork = (fiber) => {
541
538
  console.log('Performing unit of work for fiber:', fiber);
539
+
542
540
  const isFunctionComponent = fiber.type instanceof Function;
543
- isFunctionComponent
544
- ? updateFunctionComponent(fiber)
545
- : updateHostComponent(fiber);
541
+ if (isFunctionComponent) {
542
+ updateFunctionComponent(fiber);
543
+ } else {
544
+ updateHostComponent(fiber);
545
+ }
546
546
 
547
547
  if (fiber.child) return fiber.child
548
548
  let nextFiber = fiber;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unsetsoft/ryunixjs",
3
- "version": "1.0.3-nightly.7",
3
+ "version": "1.0.3-nightly.8",
4
4
  "license": "MIT",
5
5
  "main": "./dist/Ryunix.js",
6
6
  "types": "./dist/Ryunix.d.ts",
@@ -26,13 +26,11 @@ const updateFunctionComponent = (fiber) => {
26
26
  * @param fiber - A fiber node representing the host component (e.g., a DOM node like div, span, etc.).
27
27
  */
28
28
  const updateHostComponent = (fiber) => {
29
- // If the fiber doesn't already have a DOM node, create one
30
29
  if (!fiber.dom) {
31
30
  fiber.dom = createDom(fiber)
32
- console.log('DOM node created:', fiber.dom)
31
+ console.log('DOM node created for host component:', fiber.dom)
33
32
  }
34
33
 
35
- // Reconcile the fiber's children with its new or updated props
36
34
  reconcileChildren(fiber, fiber.props.children)
37
35
  }
38
36
 
package/src/lib/dom.js CHANGED
@@ -14,16 +14,15 @@ import {
14
14
  * @returns A newly created DOM element based on the fiber object.
15
15
  */
16
16
  const createDom = (fiber) => {
17
- // Log to verify fiber type before creating DOM
18
17
  console.log('Creating DOM for fiber:', fiber)
19
18
 
20
- // Check if the fiber is a text element or a regular element
19
+ // Ensure that the fiber type is a valid HTML element or a text element
21
20
  const dom =
22
21
  fiber.type === RYUNIX_TYPES.TEXT_ELEMENT
23
22
  ? document.createTextNode(fiber.props.nodeValue || '')
24
23
  : document.createElement(fiber.type)
25
24
 
26
- // Update the newly created DOM element with its initial props
25
+ // Update the newly created DOM element with initial props
27
26
  updateDom(dom, {}, fiber.props)
28
27
 
29
28
  return dom
@@ -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
- ? updateFunctionComponent(fiber)
39
- : updateHostComponent(fiber)
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