From 93229d3480fb6f8994cb2239bc6764bae5b16055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20M=C3=BCller?= Date: Thu, 12 Mar 2020 09:26:31 +0100 Subject: [PATCH] fix(b-form-file): make sure to catch all errors when resetting the input --- src/components/form-file/form-file.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/form-file/form-file.js b/src/components/form-file/form-file.js index 08384bede71..0af40f22b2e 100644 --- a/src/components/form-file/form-file.js +++ b/src/components/form-file/form-file.js @@ -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) {