Skip to content

Implement "input" event for <input> elements #8613

Closed

Activity

  1. added
    A-content/dom
    on Nov 20, 2015
  2. jdm commented on Nov 20, 2015

    @jdm
    Member

    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?

  3. Manishearth commented on Nov 20, 2015

    @Manishearth
    Member

    So we already sort of support them, though .onsubmit won'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.

  4. Manishearth commented on Nov 20, 2015

    @Manishearth
    Member

    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.

    It was right there 😖

  5. paulrouget commented on Nov 20, 2015

    @paulrouget
    ContributorAuthor

    Oh, I might have done something wrong.

    I'll investigate.

    Here is the code I've been using:

    <!DOCTYPE html>
    <html>
    <body>
      <input type="text">
      <pre></pre>
      <script>
        var i = document.querySelector("input");
        var pre = document.querySelector("pre")
        i.addEventListener("input", function(e) {
          pre.textContent += "> "  + e.target.value + "\n";
        });
      </script>  
    </body>
    </html>
  6. paulrouget commented on Nov 20, 2015

    @paulrouget
    ContributorAuthor

    fwiw, in browser.html, we will use the keyup event as a workaround until this get resolved.

  7. added
    E-less-complex
    on Nov 20, 2015
  8. jdm commented on Nov 20, 2015

    @jdm
    Member

    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

  9. wldcordeiro commented on Nov 22, 2015

    @wldcordeiro
    Contributor

    I'd like to try taking this issue.

  10. added
    C-assigned
    on Nov 22, 2015
  11. Manishearth commented on Nov 22, 2015

    @Manishearth
    Member

    Sure! Let us know if you need help!

  12. wldcordeiro commented on Nov 22, 2015

    @wldcordeiro
    Contributor

    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)

  13. Manishearth commented on Nov 22, 2015

    @Manishearth
    Member

    @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_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)

  14. Manishearth commented on Dec 15, 2015

    @Manishearth
    Member

    @wldcordeiro any updates?

  15. frewsxcv commented on Dec 30, 2015

    @frewsxcv
    Contributor

    Unassigning since we haven't heard from @wldcordeiro

  16. removed
    C-assigned
    on Dec 30, 2015
  17. chkimes commented on Jan 2, 2016

    @chkimes
    Contributor

    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_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.

  18. added
    C-assigned
    on Jan 2, 2016
  19. jdm commented on Jan 2, 2016

    @jdm
    Member

    The easiest way to get the window from an eventtarget would be to downcast it to a Node and call window_from_node.

  20. Manishearth commented on Jan 2, 2016

    @Manishearth
    Member

    Actually, dispatch_change_event could take a Node instead (all Nodes are EventTargets, not all EventTargets are Nodes)

  21. added a commit that references this issue on Jan 2, 2016
    c0835ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/domC-assignedE-less-complex

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions