Skip to content

Commit

Permalink
fix: #202 📌 omission normalizeChildren
Browse files Browse the repository at this point in the history
  • Loading branch information
ubugeeei committed Jan 1, 2024
1 parent 91676d0 commit e06483f
Show file tree
Hide file tree
Showing 25 changed files with 364 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function createVNode(
component: null,
shapeFlag,
};
normalizeChildren(vnode, children);
return vnode;
}

Expand All @@ -59,6 +60,20 @@ export function normalizeVNode(child: VNodeChild): VNode {
}
}

export function normalizeChildren(vnode: VNode, children: unknown) {
let type = 0;
if (children == null) {
children = null;
} else if (Array.isArray(children)) {
type = ShapeFlags.ARRAY_CHILDREN;
} else {
children = String(children);
type = ShapeFlags.TEXT_CHILDREN;
}
vnode.children = children as VNodeNormalizedChildren;
vnode.shapeFlag |= type;
}

export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
return n1.type === n2.type && n1.key === n2.key;
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function createVNode(
component: null,
shapeFlag,
};
normalizeChildren(vnode, children);
return vnode;
}

Expand All @@ -59,6 +60,20 @@ export function normalizeVNode(child: VNodeChild): VNode {
}
}

export function normalizeChildren(vnode: VNode, children: unknown) {
let type = 0;
if (children == null) {
children = null;
} else if (Array.isArray(children)) {
type = ShapeFlags.ARRAY_CHILDREN;
} else {
children = String(children);
type = ShapeFlags.TEXT_CHILDREN;
}
vnode.children = children as VNodeNormalizedChildren;
vnode.shapeFlag |= type;
}

export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
return n1.type === n2.type && n1.key === n2.key;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function createVNode(
component: null,
shapeFlag,
};
normalizeChildren(vnode, children);
return vnode;
}

Expand All @@ -59,6 +60,19 @@ export function normalizeVNode(child: VNodeChild): VNode {
}
}

export function normalizeChildren(vnode: VNode, children: unknown) {
let type = 0;
if (children == null) {
children = null;
} else if (Array.isArray(children)) {
type = ShapeFlags.ARRAY_CHILDREN;
} else {
children = String(children);
type = ShapeFlags.TEXT_CHILDREN;
}
vnode.children = children as VNodeNormalizedChildren;
vnode.shapeFlag |= type;
}
export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
return n1.type === n2.type && n1.key === n2.key;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObject, isString } from "../shared";
import { isArray, isObject, isString } from "../shared";
import { ShapeFlags } from "../shared/shapeFlags";
import { ComponentInternalInstance } from "./component";

Expand Down Expand Up @@ -48,6 +48,7 @@ export function createVNode(
component: null,
shapeFlag,
};
normalizeChildren(vnode, children);
return vnode;
}

Expand All @@ -59,6 +60,20 @@ export function normalizeVNode(child: VNodeChild): VNode {
}
}

export function normalizeChildren(vnode: VNode, children: unknown) {
let type = 0;
if (children == null) {
children = null;
} else if (isArray(children)) {
type = ShapeFlags.ARRAY_CHILDREN;
} else {
children = String(children);
type = ShapeFlags.TEXT_CHILDREN;
}
vnode.children = children as VNodeNormalizedChildren;
vnode.shapeFlag |= type;
}

export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
return n1.type === n2.type && n1.key === n2.key;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObject, isString } from "../shared";
import { isArray, isObject, isString } from "../shared";
import { ShapeFlags } from "../shared/shapeFlags";
import { ComponentInternalInstance } from "./component";

Expand Down Expand Up @@ -48,6 +48,7 @@ export function createVNode(
component: null,
shapeFlag,
};
normalizeChildren(vnode, children);
return vnode;
}

Expand All @@ -59,6 +60,20 @@ export function normalizeVNode(child: VNodeChild): VNode {
}
}

export function normalizeChildren(vnode: VNode, children: unknown) {
let type = 0;
if (children == null) {
children = null;
} else if (isArray(children)) {
type = ShapeFlags.ARRAY_CHILDREN;
} else {
children = String(children);
type = ShapeFlags.TEXT_CHILDREN;
}
vnode.children = children as VNodeNormalizedChildren;
vnode.shapeFlag |= type;
}

export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
return n1.type === n2.type && n1.key === n2.key;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObject, isString } from "../shared";
import { isArray, isObject, isString } from "../shared";
import { ShapeFlags } from "../shared/shapeFlags";
import { ComponentInternalInstance } from "./component";

Expand Down Expand Up @@ -48,6 +48,7 @@ export function createVNode(
component: null,
shapeFlag,
};
normalizeChildren(vnode, children);
return vnode;
}

Expand All @@ -59,6 +60,20 @@ export function normalizeVNode(child: VNodeChild): VNode {
}
}

export function normalizeChildren(vnode: VNode, children: unknown) {
let type = 0;
if (children == null) {
children = null;
} else if (isArray(children)) {
type = ShapeFlags.ARRAY_CHILDREN;
} else {
children = String(children);
type = ShapeFlags.TEXT_CHILDREN;
}
vnode.children = children as VNodeNormalizedChildren;
vnode.shapeFlag |= type;
}

export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
return n1.type === n2.type && n1.key === n2.key;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObject, isString } from "../shared";
import { isArray, isObject, isString } from "../shared";
import { ShapeFlags } from "../shared/shapeFlags";
import { ComponentInternalInstance } from "./component";

Expand Down Expand Up @@ -48,6 +48,7 @@ export function createVNode(
component: null,
shapeFlag,
};
normalizeChildren(vnode, children);
return vnode;
}

Expand All @@ -59,6 +60,20 @@ export function normalizeVNode(child: VNodeChild): VNode {
}
}

export function normalizeChildren(vnode: VNode, children: unknown) {
let type = 0;
if (children == null) {
children = null;
} else if (isArray(children)) {
type = ShapeFlags.ARRAY_CHILDREN;
} else {
children = String(children);
type = ShapeFlags.TEXT_CHILDREN;
}
vnode.children = children as VNodeNormalizedChildren;
vnode.shapeFlag |= type;
}

export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
return n1.type === n2.type && n1.key === n2.key;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObject, isString } from "../shared";
import { isArray, isObject, isString } from "../shared";
import { ShapeFlags } from "../shared/shapeFlags";
import { ComponentInternalInstance } from "./component";

Expand Down Expand Up @@ -48,6 +48,7 @@ export function createVNode(
component: null,
shapeFlag,
};
normalizeChildren(vnode, children);
return vnode;
}

Expand All @@ -59,6 +60,20 @@ export function normalizeVNode(child: VNodeChild): VNode {
}
}

export function normalizeChildren(vnode: VNode, children: unknown) {
let type = 0;
if (children == null) {
children = null;
} else if (isArray(children)) {
type = ShapeFlags.ARRAY_CHILDREN;
} else {
children = String(children);
type = ShapeFlags.TEXT_CHILDREN;
}
vnode.children = children as VNodeNormalizedChildren;
vnode.shapeFlag |= type;
}

export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
return n1.type === n2.type && n1.key === n2.key;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObject, isString } from "../shared";
import { isArray, isObject, isString } from "../shared";
import { ShapeFlags } from "../shared/shapeFlags";
import { ComponentInternalInstance } from "./component";

Expand Down Expand Up @@ -48,6 +48,7 @@ export function createVNode(
component: null,
shapeFlag,
};
normalizeChildren(vnode, children);
return vnode;
}

Expand All @@ -59,6 +60,20 @@ export function normalizeVNode(child: VNodeChild): VNode {
}
}

export function normalizeChildren(vnode: VNode, children: unknown) {
let type = 0;
if (children == null) {
children = null;
} else if (isArray(children)) {
type = ShapeFlags.ARRAY_CHILDREN;
} else {
children = String(children);
type = ShapeFlags.TEXT_CHILDREN;
}
vnode.children = children as VNodeNormalizedChildren;
vnode.shapeFlag |= type;
}

export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
return n1.type === n2.type && n1.key === n2.key;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObject, isString } from "../shared";
import { isArray, isObject, isString } from "../shared";
import { ShapeFlags } from "../shared/shapeFlags";
import { ComponentInternalInstance } from "./component";

Expand Down Expand Up @@ -48,6 +48,7 @@ export function createVNode(
component: null,
shapeFlag,
};
normalizeChildren(vnode, children);
return vnode;
}

Expand All @@ -59,6 +60,20 @@ export function normalizeVNode(child: VNodeChild): VNode {
}
}

export function normalizeChildren(vnode: VNode, children: unknown) {
let type = 0;
if (children == null) {
children = null;
} else if (isArray(children)) {
type = ShapeFlags.ARRAY_CHILDREN;
} else {
children = String(children);
type = ShapeFlags.TEXT_CHILDREN;
}
vnode.children = children as VNodeNormalizedChildren;
vnode.shapeFlag |= type;
}

export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
return n1.type === n2.type && n1.key === n2.key;
}
Loading

0 comments on commit e06483f

Please sign in to comment.