Bug Tracker

Opened 12 years ago

Closed 12 years ago

#8388 closed bug (fixed)

.css(prop) fails in IE for detached elements

Reported by: jaredjacobs@… Owned by:
Priority: high Milestone: 1.next
Component: css Version: 1.5.1
Keywords: needsreview Cc:
Blocked by: Blocking:


This seems to be a regression introduced in 1.4.3 and still broken in 1.5.1. (1.4.2 does not have the bug.)

In most browsers:

  $("<div/>").css("top", 10).css("top")
  > "10px"

However, in IE (I tried IE 8):

  $("<div/>").css("top", 10).css("top")
  > null

even though:

  $("<div/>").css("top", 10)[0].style.top
  > "10px"

Change History (8)

comment:1 Changed 12 years ago by anonymous

A workaround is attaching the element to the document:

$("<div/>").css("top", 10).appendTo("body").css("top")
> "10px"

P.S. Here's a jsfiddle demonstrating the problem (in IE): http://jsfiddle.net/qrXen/1/

comment:2 Changed 12 years ago by Rick Waldron

Component: unfiledmanipulation
Priority: undecidedhigh
Status: newopen

comment:3 Changed 12 years ago by Rick Waldron

Keywords: needsreview added

comment:4 Changed 12 years ago by dmethvin

Most likely because it's getting the computed style and not the literal css string. I don't know if this is a reasonable request of the browser since top doesn't make a lot of sense on a disconnected element.

comment:5 Changed 12 years ago by john

Component: manipulationcss

We should be checking to see if the node is disconnected and just using .style.top instead. Confirmed in bug triage.

comment:7 Changed 12 years ago by Timmy Willison

#10254 is a duplicate of this ticket.

comment:8 Changed 12 years ago by Mike Sherov

Resolution: fixed
Status: openclosed

Landing pull request 553. Fallback to elem.style for disconnected nodes in width/height retrieval. Fixes #8388.

More Details:

Note: See TracTickets for help on using tickets.