Closed
Bug 1078702
Opened 11 years ago
Closed 11 years ago
hasOwnProperty selectionStart/selectionEnd is false
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: wowmotty, Unassigned)
Details
Attachments
(1 file)
|
23.58 KB,
image/png
|
Details |
User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36
Steps to reproduce:
When attempting to detect if an input element has a selectionStart or selectionEnd property, the "hasOwnProperty" function always returns false.
I created this demo (http://jsfiddle.net/Mottie/2vwcef5x/) to show the issue. The results are the same in IE11, but in Chrome v37, all console logs return true. I don't have Safari to test the fiddle.
Actual results:
input.hasOwnProperty('selectionStart') returns false, when it should return true.
Expected results:
input.hasOwnProperty('selectionStart') should return true, just as 'selectionStart' in input returns true.
Comment 1•11 years ago
|
||
The methods seem to be defined on input.__proto__. Probably something DOM related.
Component: JavaScript Engine → DOM
Flags: needinfo?(bzbarsky)
Comment 2•11 years ago
|
||
Yep. Per spec, these are accessors on the prototype. We and IE are following the spec. Chrome has a well-known bug where it puts some (but not all! Try looking for "onclick" on the window and compare to looking for "onclick" on an input) properties on the wrong object.
If you're trying to do detection, you either need to check both places or use "in", which will walk the proto chain for you.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Flags: needinfo?(bzbarsky)
Resolution: --- → INVALID
| Assignee | ||
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•