Skip to main content

Bug Tracker

Side navigation

#8388 closed bug (fixed)

Opened February 25, 2011 11:15PM UTC

Closed October 22, 2011 08:12PM UTC

.css(prop) fails in IE for detached elements

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

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"
Attachments (0)
Change History (8)

Changed February 25, 2011 11:25PM UTC by anonymous comment:1

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/

Changed March 07, 2011 12:19AM UTC by rwaldron comment:2

component: unfiledmanipulation
priority: undecidedhigh
status: newopen

Changed March 07, 2011 12:42AM UTC by rwaldron comment:3

keywords: → needsreview

Changed April 22, 2011 01:50AM UTC by dmethvin comment:4

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.

Changed July 12, 2011 07:30PM UTC by john comment:5

component: manipulationcss

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

Changed October 18, 2011 02:50AM UTC by mikesherov comment:6

Changed October 18, 2011 01:58PM UTC by timmywil comment:7

#10254 is a duplicate of this ticket.

Changed October 22, 2011 08:12PM UTC by Mike Sherov comment:8

resolution: → fixed
status: openclosed

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

More Details:

Changeset: e502012c0f8e7604eaabe4065ba769af04eec180