Skip to content

Text control selections API conformance #19171

Closed

Description

@KiChjang

We currently have WebIDL bindings to the selectionStart, selectionEnd and selectionRange setter functions on the HTMLInputElement, but these setters do not follow the spec completely since they do not fire select events on the input element when they are called.

In addition, we should also check that the code for these setters are matching the steps as outlined in the spec.

Code: components/script/dom/htmlinputelement.rs
Spec: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea%2Finput-selectionstart
Test: tests/wpt/web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end.html

EDIT: Since @jonleighton has taken this up and focused their efforts on ensuring conformance of both HTMLInputElement and HTMLTextAreaElement selections API, the scope of this issue has been expanded accordingly.

Activity

  1. added
    A-content/dom
    E-less-complex
    I-wrong
    on Nov 10, 2017
  2. highfive commented on Nov 10, 2017

    @highfive

    Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the #servo channel in IRC.

    If you intend to work on this issue, then add @highfive: assign me to your comment, and I'll assign this to you. 😄

  3. deleted a comment from 3442853561 on Nov 10, 2017
  4. tigercosmos commented on Nov 10, 2017

    @tigercosmos
    Contributor

    Did the previous PR solve part of this?

  5. KiChjang commented on Nov 10, 2017

    @KiChjang
    ContributorAuthor

    No, it did not.

  6. added
    I-enhancement
    and removed
    I-wrong
    on Nov 10, 2017
  7. jonleighton commented on Nov 13, 2017

    @jonleighton
    Contributor

    Hi, I'd like to have a go at working on this. I've not contributed to servo before so please bear with me...

    I've established that the select event is already being fired by setSelectionRange, since that was implemented in f60de52aae6. However it is not fired by the selectionStart or selectionEnd setters.

  8. jonleighton commented on Nov 13, 2017

    @jonleighton
    Contributor

    PR submitted for firing the event. Once it is approved I could look into other related issues (e.g. the remaining failing tests, also the spec says that the event should only fire if the selection has actually changed).

  9. added a commit that references this issue on Nov 15, 2017
  10. jonleighton commented on Nov 17, 2017

    @jonleighton
    Contributor

    I think this assertion (and the other related assertions in other tests) is not correct per the spec.

    The spec says:

    If there is no selection, return the offset (in logical order) to the character that immediately follows the text entry cursor.

    Further down, it then says:

    All elements to which this API applies have either a selection or a text entry cursor position at all times (even for elements that are not being rendered). The initial state must consist of a text entry cursor at the beginning of the control.

    The assertion in the test is checking that the text entry cursor is at the end of the control, however.

    I made a quick test to check the behaviour in other browsers. Both Firefox and Chromium print 0 for all values in that test page.

    So I think the test needs to change, but I'm just checking to see if I have missed something?

  11. jonleighton commented on Nov 17, 2017

    @jonleighton
    Contributor

    Sorry, I'm incorrect because the value is set via JS, therefore step 5 from here applies:

    If the element's value (after applying the value sanitization algorithm) is different from oldValue, and the element has a text entry cursor position, move the text entry cursor position to the end of the text control, unselecting any selected text and resetting the selection direction to "none".

  12. 7 remaining items

  13. removed
    E-less-complex
    on Nov 27, 2017
  14. jonleighton commented on Dec 3, 2017

    @jonleighton
    Contributor

    Latest PR: #19461 (I forgot to ref this issue there)

  15. jonleighton commented on Dec 5, 2017

    @jonleighton
    Contributor

    @highfive: assign me

  16. highfive commented on Dec 5, 2017

    @highfive

    It looks like this has already been assigned to someone. I'll leave the decision to a core contributor.

  17. jonleighton commented on Dec 11, 2017

    @jonleighton
    Contributor

    Once #19544 is merged, the only remaining thing that I'm aware of is steps 7-9 of the input type change algorithm. I can't see any existing WPT tests for that so will need to add some I think.

  18. jonleighton commented on Dec 11, 2017

    @jonleighton
    Contributor

    Actually, I have just added another commit on that PR which deals with the above, so I think we can close this issue once the PR is merged.

  19. added a commit that references this issue on Jan 26, 2018
  20. added a commit that references this issue on Jan 26, 2018
  21. jonleighton commented on Jan 28, 2018

    @jonleighton
    Contributor

    @KiChjang this can be closed now!

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-assignedI-enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions