mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 17:42:15 +08:00
fix(input): value might be null/undefined
This commit is contained in:
@ -181,7 +181,7 @@ export class Input {
|
|||||||
@Watch('value')
|
@Watch('value')
|
||||||
protected valueChanged() {
|
protected valueChanged() {
|
||||||
const inputEl = this.nativeInput;
|
const inputEl = this.nativeInput;
|
||||||
const value = this.value;
|
const value = this.getValue();
|
||||||
if (inputEl && inputEl.value !== value) {
|
if (inputEl && inputEl.value !== value) {
|
||||||
inputEl.value = value;
|
inputEl.value = value;
|
||||||
}
|
}
|
||||||
@ -251,6 +251,10 @@ export class Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getValue(): string {
|
||||||
|
return this.value || '';
|
||||||
|
}
|
||||||
|
|
||||||
private emitStyle() {
|
private emitStyle() {
|
||||||
this.ionStyle.emit({
|
this.ionStyle.emit({
|
||||||
'interactive': true,
|
'interactive': true,
|
||||||
@ -313,7 +317,7 @@ export class Input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private hasValue(): boolean {
|
private hasValue(): boolean {
|
||||||
return this.value.length > 0;
|
return this.getValue().length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hostData() {
|
hostData() {
|
||||||
@ -329,7 +333,7 @@ export class Input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
renderHiddenInput(this.el, this.name, this.value, this.disabled);
|
renderHiddenInput(this.el, this.name, this.getValue(), this.disabled);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
<input
|
<input
|
||||||
@ -358,7 +362,7 @@ export class Input {
|
|||||||
step={this.step}
|
step={this.step}
|
||||||
size={this.size}
|
size={this.size}
|
||||||
type={this.type}
|
type={this.type}
|
||||||
value={this.value}
|
value={this.getValue()}
|
||||||
onInput={this.onInput.bind(this)}
|
onInput={this.onInput.bind(this)}
|
||||||
onBlur={this.onBlur.bind(this)}
|
onBlur={this.onBlur.bind(this)}
|
||||||
onFocus={this.onFocus.bind(this)}
|
onFocus={this.onFocus.bind(this)}
|
||||||
|
Reference in New Issue
Block a user