Skip to content

Commit f2fff2b

Browse files
committed
feat: 过滤掉不应该作为attribute传递的props
1 parent ad6f58c commit f2fff2b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/omi-reactify/src/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,16 @@ const reactify = <T extends AnyProps = AnyProps>(
515515

516516
render() {
517517
const { children, className, ...rest } = this.props
518-
519-
return createElement(WC, { class: className, ...rest, ref: this.ref }, children)
518+
// 过滤掉不应该作为attribute传递的props,它们会在update()中处理
519+
const filteredProps: Record<string, any> = {}
520+
Object.keys(rest).forEach((key) => {
521+
const val = rest[key]
522+
// 仅允许基本类型作为 attribute 传递
523+
if (typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean') {
524+
filteredProps[key] = val
525+
}
526+
})
527+
return createElement(WC, { class: className, ...filteredProps, ref: this.ref }, children)
520528
}
521529
}
522530

0 commit comments

Comments
 (0)