-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Setting selectionStart on an element appears to do nothing. #12493
Comments
I am also encountering this exact problem: PhantomJS 1.9.8 (Linux) |
👍 PhantomJS 1.9.8 (Mac OS X) |
Also seeing it on PhantomJS 1.9.8 (Mac OS X) |
I have a similar but not identical problem. From what I can tell, WebKit - at least the version embedded in PhantomJS - does not update the selection unless the control is added to the page and can be rendered. For my needs, all I need to do is add the control to the page. var textbox = document.createElement('input');
document.body.appendChild(textbox); // This is critical for selectionStart/end to be updated.
textbox.value = 'test';
textbox.setSelectionRange(0, 4);
expect(textbox.selectionStart).toBe(0);
expect(textbox.selectionEnd).toBe(4); As Op's control is already added to the page I'm not sure why it's not getting updated. It may be hidden by CSS. |
This is still a problem in PhantomJS 2.0. |
I'm seeing the same behaviour in both PhantomJS 1.9.8 and 2.0.2 |
Phantom 2.1.2 still has the issue. |
Not seeing the issue on 2.1.1 (Mac OS X), but issue occurs on 2.1.1 (Linux). |
Having the same issue on 2.1.1 (Windows). |
It appears to work when I create an input but don't add it to the dom. When I add it to the DOM it stops working.. (sometimes!) These tests that rely on this are also failing on the linux build node, but succeeding on my linux desktop. Both are running |
Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution! |
Hey,
I have an element:
When I set the selectionStart attribute on
$el
it appears to do nothing--or remain whatever the length of text inside the input is.That outputs
3
for me.I've tried this in a bunch of different contexts, and in every way it seems that the selectionStart is always the length of the element's value.
4
Thanks,
The text was updated successfully, but these errors were encountered: