Closed
Bug 642753
Opened 14 years ago
Closed 14 years ago
Allow `oninput` feature detection
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 414853
People
(Reporter: mathias, Unassigned)
References
()
Details
(Keywords: html5)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_6) AppleWebKit/534.25 (KHTML, like Gecko) Chrome/12.0.706.0 Safari/534.25
Build Identifier:
Firefox has supported the `oninput` event at least since version 2. However, for some reason the following evaluates as `false`:
'oninput' in document.createElement('input'); // false
I would expect 'oninput' in document.createElement('input') to return true, since the oninput event and the attribute are supported.
There is still a way to feature test for oninput support in Firefox, but it involves using the event API to create an input and fake a keypress to see if oninput fires, which is more complicated than it should be. (See http://blog.danielfriesen.name/2010/02/16/html5-browser-maze-oninput-support/ for more details.)
Reproducible: Always
Steps to Reproduce:
1. Open data:text/html,<script>alert('oninput' in document.createElement('input')?'PASS':'FAIL')</script>
Actual Results:
FAIL
Expected Results:
Firefox should alert “PASS” because it supports `oninput`. Seems like Firefox is being modest.
| Reporter | ||
Updated•14 years ago
|
Version: unspecified → Trunk
Comment 1•14 years ago
|
||
This is bug 414853. Maybe we want to special case?
Comment 2•14 years ago
|
||
I don't understand why you need a fake keypress.
javascript:document.documentElement.oninput = function() {alert("input");}; var e = document.createEvent("Event");e.initEvent("input", false, false); document.documentElement.dispatchEvent(e); void(0)
Comment 3•14 years ago
|
||
Isn't that bug a dup of bug 414853?
Updated•14 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
Comment 5•14 years ago
|
||
(In reply to comment #2)
> I don't understand why you need a fake keypress.
>
> javascript:document.documentElement.oninput = function() {alert("input");}; var
> e = document.createEvent("Event");e.initEvent("input", false, false);
> document.documentElement.dispatchEvent(e); void(0)
I cannot make that test work (FF3.6.15 Mac).
Should DOM2 dispatchEvent fire DOM0 events ?
Are "input" events valid for any element or just focusable elements ?
Comment 6•14 years ago
|
||
element.oninput was added for FF4, Bug 618948
If you want to test oninput as attribute you could do
javascript: var el = document.createElement("div"); el.setAttribute("oninput", "alert('input')"); var e = document.createEvent("Events"); e.initEvent("input", false, false); el.dispatchEvent(e); void(0);
And yes, oninput should work in all HTMLElements.
http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#handler-oninput
Comment 7•14 years ago
|
||
(In reply to comment #6)
> element.oninput was added for FF4, Bug 618948
>
> If you want to test oninput as attribute you could do
> javascript: var el = document.createElement("div"); el.setAttribute("oninput",
> "alert('input')"); var e = document.createEvent("Events"); e.initEvent("input",
> false, false); el.dispatchEvent(e); void(0);
>
> And yes, oninput should work in all HTMLElements.
> http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#handler-oninput
Thank you for the tips and the updates.
Still looking at this description:
http://dev.w3.org/html5/spec/Overview.html#event-input-input
"When the input event applies, any time the user causes the element's [value] to change, ..."
I don't see how "element's value" can change for elements which are not form controls.
Is it just a discrepancy or did I get that wrong ?
Comment 8•14 years ago
|
||
input event bubbles, so any parent node of <input> or <textarea> element
may get it.
You need to log in
before you can comment on or make changes to this bug.
Description
•