Skip to content

Commit 682bc46

Browse files
authored
fix(b-form-file): make sure to catch all errors when resetting the input (#4936)
1 parent d86a579 commit 682bc46

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/components/form-file/form-file.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,16 @@ export const BFormFile = /*#__PURE__*/ Vue.extend({
169169
}
170170
},
171171
reset() {
172+
// IE 11 doesn't support setting `$input.value` to `''` or `null`
173+
// So we use this little extra hack to reset the value, just in case
174+
// This also appears to work on modern browsers as well
175+
// Wrapped in try in case IE 11 or mobile Safari crap out
172176
try {
173-
// Wrapped in try in case IE 11 craps out
174-
this.$refs.input.value = ''
177+
const $input = this.$refs.input
178+
$input.value = ''
179+
$input.type = ''
180+
$input.type = 'file'
175181
} catch (e) {}
176-
// IE 11 doesn't support setting `input.value` to '' or null
177-
// So we use this little extra hack to reset the value, just in case.
178-
// This also appears to work on modern browsers as well.
179-
this.$refs.input.type = ''
180-
this.$refs.input.type = 'file'
181182
this.selectedFile = this.multiple ? [] : null
182183
},
183184
onFileChange(evt) {

0 commit comments

Comments
 (0)