Skip to content

Commit

Permalink
fix(b-form-file): make sure to catch all errors when resetting the in…
Browse files Browse the repository at this point in the history
…put (#4936)
  • Loading branch information
jacobmllr95 authored Mar 12, 2020
1 parent d86a579 commit 682bc46
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/components/form-file/form-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,16 @@ export const BFormFile = /*#__PURE__*/ Vue.extend({
}
},
reset() {
// IE 11 doesn't support setting `$input.value` to `''` or `null`
// So we use this little extra hack to reset the value, just in case
// This also appears to work on modern browsers as well
// Wrapped in try in case IE 11 or mobile Safari crap out
try {
// Wrapped in try in case IE 11 craps out
this.$refs.input.value = ''
const $input = this.$refs.input
$input.value = ''
$input.type = ''
$input.type = 'file'
} catch (e) {}
// IE 11 doesn't support setting `input.value` to '' or null
// So we use this little extra hack to reset the value, just in case.
// This also appears to work on modern browsers as well.
this.$refs.input.type = ''
this.$refs.input.type = 'file'
this.selectedFile = this.multiple ? [] : null
},
onFileChange(evt) {
Expand Down

0 comments on commit 682bc46

Please sign in to comment.