Skip to content

Commit 05811bd

Browse files
author
Zhi
committed
add getInput method to el-input
1 parent fe8adae commit 05811bd

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

packages/autocomplete/src/autocomplete.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
$input.setAttribute('aria-activedescendant', `${this.id}-item-${this.highlightedIndex}`);
256256
},
257257
getInput() {
258-
return this.$refs.input.$refs.input || this.$refs.input.$refs.textarea;
258+
return this.$refs.input.getInput();
259259
}
260260
},
261261
mounted() {

packages/input/src/input.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@
221221
222222
methods: {
223223
focus() {
224-
(this.$refs.input || this.$refs.textarea).focus();
224+
this.getInput().focus();
225225
},
226226
blur() {
227-
(this.$refs.input || this.$refs.textarea).blur();
227+
this.getInput().blur();
228228
},
229229
getMigratingConfig() {
230230
return {
@@ -245,7 +245,7 @@
245245
}
246246
},
247247
select() {
248-
(this.$refs.input || this.$refs.textarea).select();
248+
this.getInput().select();
249249
},
250250
resizeTextarea() {
251251
if (this.$isServer) return;
@@ -287,7 +287,7 @@
287287
// set input's value, in case parent refuses the change
288288
// see: https://github.com/ElemeFE/element/issues/12850
289289
this.$nextTick(() => {
290-
let input = this.$refs.input || this.$refs.textarea;
290+
let input = this.getInput();
291291
input.value = this.value;
292292
});
293293
},
@@ -325,6 +325,9 @@
325325
this.$emit('input', '');
326326
this.$emit('change', '');
327327
this.$emit('clear');
328+
},
329+
getInput() {
330+
return this.$refs.input || this.$refs.textarea;
328331
}
329332
},
330333

0 commit comments

Comments
 (0)