Bug Tracker

Modify

Ticket #7976 (closed bug: duplicate)

Opened 2 years ago

Last modified 2 years ago

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

 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

comment:1 Changed 2 years ago by rwaldron

  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to offset

Confirmed.

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

comment:2 Changed 2 years ago by rwaldron

  • Status changed from open to closed
  • Resolution set to duplicate

comment:3 Changed 2 years ago by rwaldron

Duplicate of #7602.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.