change event is dispatched when .files property is set at <input type="file"> element
Reported by
guest271...@gmail.com,
Dec 6 2017
|
||||||||
Issue descriptionUserAgent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/62.0.3202.94 Chrome/62.0.3202.94 Safari/537.36 Steps to reproduce the problem: 1. Progammatically set .files property of <input type="file"> element to a FileList object 2. 3. What is the expected behavior? change event should not be dispatched to the element What went wrong? change event is dispatched to the element Did this work before? N/A Does this work in other browsers? Yes Chrome version: 62.0.3202.94 Channel: stable OS Version: Flash Version: See https://github.com/whatwg/html/issues/3269
,
Dec 7 2017
"Thanks for filing the issue! @Reporter: Could you please provide a sample test file/URL to check the issue from TE end. Any further inputs from your end helps us to triage the issue in a better way."
,
Dec 7 2017
Here's a more minimal repro:
(1) go to about:blank
(2) run this on the console:
input = Object.assign(document.createElement('input'), {type: 'file'}); input.onchange = e => alert('change'); dt = new DataTransfer; dt.items.add(new File([], '')); input.files = dt.files
Expect: no alert
Actual: alert
,
Dec 7 2017
,
Dec 7 2017
A fix is simple - make SetFiles() delegate to a new SetFilesInternal(..., bool send_event_if_changed) or some such - but we need to understand the history of the current behavior.
,
Dec 10
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 12
IMO, this is an accidental behavior. We should fix.
,
Dec 12
,
Dec 13
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/316b593b45afa16f32bb72acb177700e9be2ee44 commit 316b593b45afa16f32bb72acb177700e9be2ee44 Author: Joshua Bell <jsbell@chromium.org> Date: Thu Dec 13 19:34:23 2018 File Inputs: Don't generate change events when 'files' is set The <input type=file> element generates "change" events when the user interacts with the control to select files, exposed as the 'files' property (a FileList). This property can be assigned to by script, and should not generate a "change" event in such a case. It was erroneously doing so, so fix it. Bug: 792336 Change-Id: Iaa4297332e9c048daf7142aef3797fb59b0d5bcf Reviewed-on: https://chromium-review.googlesource.com/c/1374791 Commit-Queue: Joshua Bell <jsbell@chromium.org> Reviewed-by: Kent Tamura <tkent@chromium.org> Cr-Commit-Position: refs/heads/master@{#616394} [modify] https://crrev.com/316b593b45afa16f32bb72acb177700e9be2ee44/third_party/blink/renderer/core/html/forms/file_input_type.cc [modify] https://crrev.com/316b593b45afa16f32bb72acb177700e9be2ee44/third_party/blink/renderer/core/html/forms/file_input_type.h [modify] https://crrev.com/316b593b45afa16f32bb72acb177700e9be2ee44/third_party/blink/renderer/core/html/forms/input_type.cc [modify] https://crrev.com/316b593b45afa16f32bb72acb177700e9be2ee44/third_party/blink/renderer/core/html/forms/input_type.h [add] https://crrev.com/316b593b45afa16f32bb72acb177700e9be2ee44/third_party/blink/web_tests/fast/files/file-list-change-events.html
,
Dec 13
|
||||||||
►
Sign in to add a comment |
||||||||
Comment 1 by bsittler@chromium.org
, Dec 6 2017