Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#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:
Blocked by: Blocking:

Description

http://jsfiddle.net/p667T/1/

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)

  1. 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 (3)

comment:1 Changed 9 years ago by Rick Waldron

Component: unfiledoffset
Priority: undecidedlow
Status: newopen

Confirmed.

"offset.top -= parseFloat( jQuery.css(elem, "marginTop") )
0; "

comment:2 Changed 9 years ago by Rick Waldron

Resolution: duplicate
Status: openclosed

comment:3 Changed 9 years ago by Rick Waldron

Duplicate of #7602.

Note: See TracTickets for help on using tickets.