Commit d38ab315 authored by Jiewei Qian's avatar Jiewei Qian Committed by hetech

Input: update DOM dependent values on type change (#14889)

fix #14857
parent 6298958c
......@@ -233,6 +233,16 @@
// see: https://github.com/ElemeFE/element/issues/14521
nativeInputValue() {
this.setNativeInputValue();
},
// when change between <input> and <textarea>,
// update DOM dependent value and styles
// https://github.com/ElemeFE/element/issues/14857
type() {
this.$nextTick(() => {
this.setNativeInputValue();
this.resizeTextarea();
this.updateIconOffset();
});
}
},
......
......@@ -394,4 +394,26 @@ describe('Input', () => {
expect(vm.$refs.inputComp.$refs.input.selectionEnd).to.equal(testContent.length);
});
});
it('sets value on textarea / input type change', async() => {
vm = createVue({
template: `
<el-input :type="type" v-model="val" />
`,
data() {
return {
type: 'text',
val: '123'
};
}
}, true);
expect(vm.$el.querySelector('input').value).to.equal('123');
vm.type = 'textarea';
await waitImmediate();
expect(vm.$el.querySelector('textarea').value).to.equal('123');
vm.type = 'password';
await waitImmediate();
expect(vm.$el.querySelector('input').value).to.equal('123');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment