Skip to content

Commit

Permalink
Merge pull request #1722 from pacoyang/fix-textarea-input
Browse files Browse the repository at this point in the history
fix(taro-components): 修复 Textarea 组件无法传递 detail 问题
  • Loading branch information
jinjinjin0731 authored Jan 7, 2019
2 parents d512b3e + 0eb64cf commit e542bdf
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/taro-components/src/components/textarea/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ import omit from 'omit.js'
class Textarea extends Nerv.Component {
constructor () {
super(...arguments)
this.onChange = this.onChange.bind(this)
}

onChange (e) {
const { onChange, onInput } = this.props
const { onChange = '', onInput = '' } = this.props
Object.defineProperty(e, 'detail', {
enumerable: true,
value: {
value: e.target.value
}
})
if (onChange) {
onChange && onChange(e)
} else {
onInput && onInput(e)
}
if (onChange) return onChange && onChange(e)
if (onInput) return onInput && onInput(e)
}

render () {
Expand All @@ -26,7 +24,6 @@ class Textarea extends Nerv.Component {
placeholder = '',
disabled,
maxlength = 140,
onChange,
onFocus,
onBlur,
autoFocus = false
Expand All @@ -39,6 +36,7 @@ class Textarea extends Nerv.Component {
'disabled',
'maxlength',
'onChange',
'onInput',
'onFocus',
'onBlur',
'autofocus'
Expand All @@ -48,7 +46,7 @@ class Textarea extends Nerv.Component {
disabled={disabled}
maxlength={maxlength}
autofocus={autoFocus}
onChange={onChange}
onChange={this.onChange}
onFocus={onFocus}
onBlur={onBlur}
/>
Expand Down

0 comments on commit e542bdf

Please sign in to comment.