Closed Bug 1078702 Opened 11 years ago Closed 11 years ago

hasOwnProperty selectionStart/selectionEnd is false

Categories

(Core :: DOM: Core & HTML, defect)

32 Branch
x86_64
Windows 8.1
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: wowmotty, Unassigned)

Details

Attachments

(1 file)

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.
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
The methods seem to be defined on input.__proto__. Probably something DOM related.
Component: JavaScript Engine → DOM
Flags: needinfo?(bzbarsky)
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
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: