-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Text Selection API for Input and TextArea #804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@domenic What's going on with this? You need me to write tests or something? Or is there a more fundamental problem? |
|
I hadn't had time to review such a large contribution. But yes, doing a quick glance-through, there definitely need to be tests. Please read the CONTRIBUTING.md? |
|
Alright, will do |
|
Alright, I read
|
|
OK, great, happy to help. It's interesting that you've found a spec and/or test bug. Which do browsers implement? That determines whether we should fix the tests or the spec. To get the tests to run, the easiest thing to do is to retarget the PR against the 1.0 branch, and then just point at the URLs by adding them to test/w3c/index.js, like so. We are pretty close to merging 1.0 anyway. |
|
Chrome matches the spec, not the tests. Firefox and Safari matches the tests, not the spec (though their implementation of the API is riddled with problems). If I'm going to just point to the URL for the W3C test, doesn't that mean I kind of have to match up with the tests, rather than the spec? I could just submit a pull request to W3C's test of course (it's an extremely quick fix), but that might take some time to go through and we probably don't want the tests failing in the mean time. Also, I recently rebased against master. Will that be a problem w.r.t. merging into 1.0? Should I just rebase against 1.0? (Can you tell I'm bad at git?) |
Yeah, I was going to say, we could do a pull request on the tests if they are wrong. And great, now we don't know who is wrong. Will file a bug against the spec and see what happens. In the meantime matching the tests is probably the way to go, I think? Unless it's much more work.
Rebasing against 1.0 is great. You may need to either edit this PR to target 1.0, or close it and open a new one, through the GitHub UI. (I don't know if the edit option is possible.) It doesn't matter too much since I can always do the rebasing myself locally even if GitHub gets confused and thinks you're targeting master. And hey, if you know what "rebasing against 1.0" is, you're better at Git than a lot of people on GitHub, so yay :) |
|
It's not really any work to match the tests. Just have to add an extra case to a conditional. I literally learned what rebasing was today, specifically to keep this pull request up to date =P |
|
Hey, I did what you said, but I'm not really sure the W3C tests are actually running. Like, there's no console output along the lines of I checked |
|
Update: The tests are actually inconsistent with each other too. This test thinks |
|
Oh, wow, that is awesome. Regarding problems running the tests: ugh. I bet this is an instance of our recurring "some tests crash the runner so hard it exits with no output" bug. What I normally do in those situations is try to run the last line independently, with and see what happens. |
As far as I understood it from the times it happened to me it seems like this happens when a test is async and the test.done() method doesn't get called because some event doesn't fire correctly. @sjelin Since w3c-test.org is currently down you can rebase against #824 which allows local testing and doesn't rely on the website (for simple tests). |
|
Hey, I've gotten super busy but I'll deal with this next week ok? |
|
No problem!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this._selectionStart ?
|
Will you merge this? |
|
It's still missing tests :( |
|
Wow, totally forgot about it. I'll deal with it this weekend, sorry On Thu, Mar 12, 2015 at 9:33 PM, Domenic Denicola notifications@github.com
|
|
Looking forward to this! 👍 |
|
Also looking forward to this. :) |
Returns an empty object. If you need it to act more realistically, the spec states a Selection object should be returned. See https://developer.mozilla.org/en-US/docs/Web/API/Selection and http://www.quirksmode.org/dom/range_intro.html This should arguably be implemented in jsdom rather than zombie - some work has been done to implement selections in Inputs and TextAreas (jsdom/jsdom#804) but not merged at time of writing.
|
@sjelin Looks like this needs a rebase, when you get the chance. |
|
I can do the rebase if someone writes tests |
|
@domenic I'll take a crack at this - want me to submit as a new PR since I can't add onto this one? Cherry picked with his authorship of course |
|
That sounds great! Just be sure to read CONTRIBUTING.md about how to turn on web platform tests that exist already, and how new tests should be written in that style. Feel free to bug us in #jsdom on freenode IRC if you have any questions. |
|
It's a thanksgiving miracle! Also, sorry guys, I got very sick shortly after sending this PR and then switched jobs so it was very low priority. @yanovich let me know if you have any questions. I also give you permission to take full authorship if that makes your life easier. |
|
Superceded by #1305 :) |
See #799. Followed documentation at http://www.whatwg.org/specs/web-apps/current-work/#textFieldSelection
Pretty straight forward addition. A few concerns:
SometimesNever mind, the W3C tests seem to imply that this is the correct thing to throw.inputtags don't support the selection API (e.g.type=radio). In these cases I throwthrow new core.DOMException(core.INVALID_STATE_ERR), because chrome throws anInvalidStateErrorand this was the most similar thing I could find. No idea if that's the correct thing to throw though. Would appreciate someone who knows more taking a look.On my machine, the automated tests stall atThis stopped happening when I rebased against 1.0 (yay?)running jsdom/index.js jsdom/index. They did this before I made my changes, so I'm pretty sure it's not my fault, but at the same time I feel kind of queasy sending a pull request without having the tests finish.On that note, I haven't written any tests. I did some manual testing, so I know it everything works. I don't know if that's enough for you guys.See the discussion belowAlso, the last three commits are all just small bug fixes. The "merge" was just that I stupidly tried to amend my first bug fixing commit after pushing it to github.