Summary: | When empty <input> is focused, getSelection() exposes shadow tree nodes | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Adam Roben (:aroben) <aroben> | ||||||||
Component: | Forms | Assignee: | Darin Adler <darin> | ||||||||
Status: | RESOLVED FIXED | ||||||||||
Severity: | Normal | CC: | adele, alexander.steitz, ap, darin, ojan | ||||||||
Priority: | P2 | Keywords: | InRadar | ||||||||
Version: | 528+ (Nightly build) | ||||||||||
Hardware: | All | ||||||||||
OS: | All | ||||||||||
Attachments: |
|
Description
Adam Roben (:aroben)
2007-11-08 14:19:42 PST
Created attachment 17125 [details]
testcase
What should we return if the INPUT is not empty? Firefox seems to behave differently - it returns last selection outside INPUT (such as (BODY, 0) - (BODY, 0)) or raises an exception because of not being able to execute getRange(), depending on some conditions that aren't clear to me. (In reply to comment #2) > What should we return if the INPUT is not empty? > > Firefox seems to behave differently - it returns last selection outside INPUT > (such as (BODY, 0) - (BODY, 0)) or raises an exception because of not being > able to execute getRange(), depending on some conditions that aren't clear to > me. I guess we'll have to test other browsers as well. I only mentioned the empty case here because it was clearly wrong. I found out that this problem affects any input/textarea element whether empty or not. I also encountered problems with the "anchorNode" and "focusNode" properties of the selection object. These properties as well as the "startContainer" and the "endContainer" are returning a DIV element as parentNode of the selected text node. I've attached a simple testcase to demonstrate this behaviour. Created attachment 22445 [details]
testcase for input/textarea elements with selection/range objects
Does it return the parent div, or the shadow node? If it's the shadow node, this will go away when Ojan's patch to remove shadow nodes on <input> elements is finished. > Does it return the parent div, or the shadow node? If it's the shadow node,
> this will go away when Ojan's patch to remove shadow nodes on <input> elements
> is finished.
No, the problem is (as you can see at attached test) that the result is a DIV element with the text node inside, but the INPUT/TEXTAREA element is gone.
The result should be
--snip--
<div>
<input id="a" value="test input"/>
</div>
--snip--
but it returns
--snip--
<div>
test input
</div>
--snip--
Same issue is also true for the TEXTAREA element.
*** Bug 28086 has been marked as a duplicate of this bug. *** Created attachment 34353 [details]
patch
|