Bug 117526 - “input” event is not fired when changing a <select> element’s value
Summary: “input” event is not fired when changing a <select> element’s value
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-11 16:10 PDT by felipe
Modified: 2014-03-20 08:51 PDT (History)
7 users (show)

See Also:


Attachments
Patch (6.49 KB, patch)
2014-03-18 04:32 PDT, Lorenzo Tilve
no flags Details | Formatted Diff | Diff
Patch (6.49 KB, patch)
2014-03-18 05:11 PDT, Lorenzo Tilve
koivisto: review+
Details | Formatted Diff | Diff
"input" event is not fired when changing a select element's value (6.70 KB, patch)
2014-03-20 05:24 PDT, Lorenzo Tilve
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description felipe 2013-06-11 16:10:37 PDT
http://www.w3.org/TR/html5/index.html#events-0

Per the above, changes to a <select> element should be firing “oninput”; however, WebKit seems simply to ignore these changes.

No other browser appears to implement this as I’m describing, but per the spec, this still appears to be a bug that DEFINITELY should be fixed.

I can’t check this on a WebKit nightly because I have Snow Leopard.
Comment 1 Alexey Proskuryakov 2013-06-12 16:22:16 PDT
Could you please attach a test case?
Comment 2 felipe 2013-06-15 17:19:18 PDT
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
    <form action="javascript:void(0)" oninput="console.log(this)">
        <label>Changing this doesn’t fire “oninput”:
            <select name="foo"><option>1</option><option>2</option></select>
        </label>
        <br>
        <br>
        <label>… but changing this does:
            <input type="text" name="bar">
        </label>
    </form>
</body>
</html>
Comment 3 felipe 2013-06-15 17:24:21 PDT
I also was able to confirm the bug in the latest nightly.
Comment 4 Lorenzo Tilve 2014-03-18 04:32:43 PDT
Created attachment 227032 [details]
Patch

Add a call to dispatch input event when listbox or menulist values are modified.

These changes have been already applied for the same bug on Blink here http://crbug.com/349472
Comment 5 Xabier Rodríguez Calvar 2014-03-18 04:39:38 PDT
Comment on attachment 227032 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=227032&action=review

My informal review.

> LayoutTests/ChangeLog:3
> +        "oninput" doesnât fire when changing a select elementâs value

Encoding problem?

> Source/WebCore/ChangeLog:3
> +        "oninput" doesnât fire when changing a select elementâs value

Ditto.
Comment 6 Lorenzo Tilve 2014-03-18 05:11:23 PDT
Created attachment 227038 [details]
Patch

Fixed encoding issue.
Comment 7 Antti Koivisto 2014-03-20 02:58:05 PDT
Comment on attachment 227038 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=227038&action=review

Reading the spec it sounds like the intention is that input event only fires for <input> elements.

"When the input and change events apply (which is the case for all input controls other than buttons and those with the type attribute in the Hidden state), the events are fired to indicate that the user has interacted with the control. The input event fires whenever the user has modified the data of the control. The change event fires when the value is committed, if that makes sense for the control, or else when the control loses focus. In all cases, the input event comes before the corresponding change event (if any)."

> Source/WebCore/html/HTMLSelectElement.cpp:700
> +        RefPtr<HTMLSelectElement> protector(this);

This seems like a separate bug fix. Could you make a test case for it and land separately?
Comment 8 Antti Koivisto 2014-03-20 03:08:51 PDT
No I'm wrong. There is specific text for firing these:

"When the user agent is to send select update notifications, queue a task to first fire a simple event that bubbles named input at the select element, and then fire a simple event that bubbles named change at the select element, using the user interaction task source as the task source."

http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-select-element
Comment 9 Antti Koivisto 2014-03-20 03:11:59 PDT
Comment on attachment 227038 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=227038&action=review

Ok.

> LayoutTests/ChangeLog:3
> +        "oninput" doesn't fire when changing a select element's value

The event is called "input" no "oninput"
Comment 10 Antti Koivisto 2014-03-20 03:12:41 PDT
Please also point to the spec test in the ChangeLog
Comment 11 Antti Koivisto 2014-03-20 03:12:58 PDT
*text
Comment 12 Lorenzo Tilve 2014-03-20 05:24:33 PDT
Created attachment 227283 [details]
"input" event is not fired when changing a select element's value

Applied suggested corrections.
Comment 13 WebKit Commit Bot 2014-03-20 08:10:05 PDT
Comment on attachment 227283 [details]
"input" event is not fired when changing a select element's value

Clearing flags on attachment: 227283

Committed r165965: <http://trac.webkit.org/changeset/165965>