You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement "input" event for <input> elements #8613
A-content/domInteracting with the DOM from web contentC-assignedThere is someone working on resolving the issueE-less-complexStraightforward. Recommended for a new contributor.
We don't support them for text boxes because text boxes don't seem to have activation behavior (?). I can't find where in the spec we're supposed to catch changes to text boxes, will look deeper in a bit.
For input elements without a defined activation behaviour, but to which these events apply, and for which the user interface involves both interactive manipulation and an explicit commit action, then when the user changes the element's value, the user agent must queue a task to fire a simple event that bubbles named input at the input element, and any time the user commits the change, the user agent must queue a task to fire a simple event that bubbles named change at the input element.
Awkward! I was reading htmltextareaelement.rs somehow. We should do the exact same thing we do in HTMLTextAreaElement::handle_event - check for a trusted event and queue a runnable that causes the "input" event to be dispatched at the element.
Could I just get a run down of what parts of the source I'm most interested in for this and resources about how the input event should work? (That html spec link I assume is good to start with)
You'll need to add a similar value_changed field if we don't have one already, and in the key handler dispatch a change event.
Might be worthwhile to move ChangeEventRunnable into htmlinputelement.rs somewhere and make it take an EventTarget instead of an HTMLTextAreaElement (just do the upcast early)
@Manishearth you mention that ChangeEventRunnable could be changed to use an EventTarget, but the Runnable impl for ChangeEventRunnable calls a method defined on HTMLTextAreaElement.
dispatch_change_event doesn't seem to be doing anything special that's particular to the HTMLTextAreaElement aside from getting the element's window. Is it possible to get the window from an EventTarget? I just get compiler errors trying to do it the naive way.
A-content/domInteracting with the DOM from web contentC-assignedThere is someone working on resolving the issueE-less-complexStraightforward. Recommended for a new contributor.
Activity
jdm commentedon Nov 20, 2015
We actually have code that is supposed to do this already in HTMLInputElement::handle_event. Do you have a testcase showing that this doesn't work?
Manishearth commentedon Nov 20, 2015
So we already sort of support them, though
.onsubmitwon't work (attaching event handlers will work).https://github.com/servo/servo/blob/master/components/script/dom/htmlinputelement.rs#L797
We don't support them for text boxes because text boxes don't seem to have activation behavior (?). I can't find where in the spec we're supposed to catch changes to text boxes, will look deeper in a bit.
Manishearth commentedon Nov 20, 2015
It was right there 😖
paulrouget commentedon Nov 20, 2015
Oh, I might have done something wrong.
I'll investigate.
Here is the code I've been using:
paulrouget commentedon Nov 20, 2015
fwiw, in browser.html, we will use the
keyupevent as a workaround until this get resolved.jdm commentedon Nov 20, 2015
Awkward! I was reading htmltextareaelement.rs somehow. We should do the exact same thing we do in HTMLTextAreaElement::handle_event - check for a trusted event and queue a runnable that causes the "input" event to be dispatched at the element.
Code: components/script/dom/htmlinputelement.rs
wldcordeiro commentedon Nov 22, 2015
I'd like to try taking this issue.
Manishearth commentedon Nov 22, 2015
Sure! Let us know if you need help!
wldcordeiro commentedon Nov 22, 2015
Could I just get a run down of what parts of the source I'm most interested in for this and resources about how the input event should work? (That html spec link I assume is good to start with)
Manishearth commentedon Nov 22, 2015
@wldcordeiro htmltextareaelement.rs and htmlinputelement.rs, basically
https://github.com/servo/servo/blob/master/components/script/dom/htmltextareaelement.rs#L336
You'll need to add a similar
value_changedfield if we don't have one already, and in the key handler dispatch a change event.Might be worthwhile to move ChangeEventRunnable into htmlinputelement.rs somewhere and make it take an EventTarget instead of an HTMLTextAreaElement (just do the upcast early)
Manishearth commentedon Dec 15, 2015
@wldcordeiro any updates?
frewsxcv commentedon Dec 30, 2015
Unassigning since we haven't heard from @wldcordeiro
chkimes commentedon Jan 2, 2016
I'd like to try taking this issue.
@Manishearth you mention that ChangeEventRunnable could be changed to use an EventTarget, but the Runnable impl for ChangeEventRunnable calls a method defined on HTMLTextAreaElement.
https://github.com/servo/servo/blob/master/components/script/dom/htmltextareaelement.rs#L363
https://github.com/servo/servo/blob/master/components/script/dom/htmltextareaelement.rs#L237
dispatch_change_eventdoesn't seem to be doing anything special that's particular to the HTMLTextAreaElement aside from getting the element's window. Is it possible to get the window from an EventTarget? I just get compiler errors trying to do it the naive way.jdm commentedon Jan 2, 2016
The easiest way to get the window from an eventtarget would be to downcast it to a Node and call
window_from_node.Manishearth commentedon Jan 2, 2016
Actually,
dispatch_change_eventcould take aNodeinstead (all Nodes are EventTargets, not all EventTargets are Nodes)Auto merge of #9122 - ckimes89:inputevent, r=nox