Ticket #7976 (closed bug: duplicate)
calling position() on dom elements in memory throws TypeError
| Reported by: | harman.elaine@… | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | offset | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
OS tested: win7, OS 10.5 Browsers tested: FF 3.6.13, IE7 & 8; broken on all. Broken in jQuery 1.4.4 and 1.4.3; 1.4.2 seems to work as expected.
Description: Calling .position() on dom elements that only exist in memory, i.e. that haven't been rendered yet, throws an exception. In <= 1.4.2, it returned a map with top,left = 0, which seems preferable.
Repro: (See jsfiddle case)
- Execute the following at any time:
var position = $("<div/>").position()
Expected: "position" variable is assigned a map with top/left properties set to 0
Actual: Exception is thrown: name: TypeError message: setting a property that has only a getter stack:
()@http: //code.jquery.com/jquery-1.4.4.min.js:164
((function (j, s) {return new (b.fn.init)(j, s);}))@http: // fiddle.jshell.net/p667T/1/show/:22
((function () {try {var position = $("<div/>").position();console.log(position);} catch (err)
{console.log(err);}}))@http: //code.jquery.com/jquery-1.4.4.min.js:26
([object Object])@http ://fiddle.jshell.net/p667T/1/show/:18
([object Object])@http ://code.jquery.com/jquery-1.4.4.min.js:63
([object Event])@http ://code.jquery.com/jquery-1.4.4.min.js:57
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Confirmed.