Skip to content

Commit

Permalink
refactor(omi): props.children have lower priority and coverage mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dntzhang committed Jan 12, 2024
1 parent a3143a0 commit d2580cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/omi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omi",
"version": "7.5.5",
"version": "7.5.6",
"scripts": {
"start": "vite",
"dev-vite": "vite",
Expand Down
2 changes: 1 addition & 1 deletion packages/omi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export { Signal } from './signal'
export { css } from './css-tag'
export { mixin } from './options'
export { registerDirective } from './directive'
export const version = '7.5.5'
export const version = '7.5.6'
13 changes: 4 additions & 9 deletions packages/omi/src/vdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ export function createElement(
...restChildren: VNode[] | unknown[]
): VNode | VNode[] {
let children: VNode[] | undefined
if (arguments.length > 2) {
children = restChildren.flat() as VNode[]
}

// jsx 嵌套的元素自动忽略 attrs
if (attributes) {
Expand All @@ -54,12 +51,10 @@ export function createElement(
attributes = { ignoreAttrs: true }
}

if (attributes.children != null) {
if (children) {
children.push(...(attributes.children as VNode[]))
} else {
children = attributes.children as VNode[]
}
if (arguments.length > 2) {
children = restChildren.flat() as VNode[]
} else if (attributes.children != null) {
children = attributes.children as VNode[]
delete attributes.children
}

Expand Down

0 comments on commit d2580cc

Please sign in to comment.