onchange event callback
Drupal.file.validateExtension() is called. This callback:
- removes error messages that were possible inserted into the DOM earlier,
- detects a wrong file extension,
- inserts a new error message into the DOM,
- sets the field's value to an empty string and
- stops propagating the event.
On Internet Explorer 11 programmatically resetting the value using
this.value = ''; fires the
onchange event again. This time:
- the previous error message is being removed (the user will never know what went wrong),
- the field has no value, so no wrong file extension is being detected and
- the event propagating is not being stopped (other
onchangecallbacks like D8's
Drupal.file.triggerUploadButtonwill get fired).
This can be tested using http://jsfiddle.net/lmeurs/2rEzF/ or with Drupal using http://simplytest.me/project/drupal: set permissions for anonymous users to create articles so you can add articles from different browsers (ie. using http://browserstack.com) and test with the image field.
Sidenote: On < IE11 it seems not possible to programmatically reset the field's value.
The best fix I can think of is to immediately exit
Drupal.file.validateExtension() when the field has no value. Use something like:
if (!this.value) return;
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 92,774 pass(es). View
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch core-js-file-extension-validate-2301527-12-D7.patch. Unable to apply patch. See the log in the details link for more information. View
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 90,090 pass(es). View