Skip to content

Commit dc6ddee

Browse files
committed
fix: the value should be judged as null or undefined when transform the defaultValue
1 parent aaa405e commit dc6ddee

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/nerv/src/create-element.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
Props,
88
VNode,
99
VirtualChildren,
10-
EMPTY_CHILDREN
10+
EMPTY_CHILDREN,
11+
isNullOrUndef
1112
} from 'nerv-shared'
1213
import SVGPropertyConfig from './vdom/svg-property-config'
1314
import Component from './component'
@@ -16,8 +17,8 @@ function transformPropsForRealTag (type: string, props: Props) {
1617
const newProps: Props = {}
1718
for (const propName in props) {
1819
const propValue = props[propName]
19-
if (propName === 'defaultValue') {
20-
newProps.value = props.value || props.defaultValue
20+
if (propName === 'defaultValue' || propName === 'value') {
21+
newProps.value = !isNullOrUndef(props.value) ? props.value : props.defaultValue
2122
continue
2223
}
2324
const svgPropName = SVGPropertyConfig.DOMAttributeNames[propName]

0 commit comments

Comments
 (0)