Skip to main content

Bug Tracker

Side navigation

#9338 closed bug (cantfix)

Opened May 18, 2011 07:08PM UTC

Closed May 23, 2012 12:27PM UTC

jQuery .css() does not return properties for div elements not yet appended to DOM in Chrome

Reported by: Owned by: mikesherov
Priority: low Milestone:
Component: css Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

jQuery's .css() won't return the correct values for an element not yet appended to the DOM in Chrome, but it will in Firefox. See test case.

Attachments (0)
Change History (7)

Changed May 18, 2011 07:14PM UTC by addyosmani comment:1

component: unfiledcss
priority: undecidedlow
status: newopen

Confirmed in Chrome latest.

Changed May 18, 2011 07:23PM UTC by timmywil comment:2

I'm not sure that's possible to fix if the native treatment of disconnected nodes differs. I think we'd have to connect the node to retrieve consistent css, but that could have a drastic impact on the page depending on the css applied to that node.

Changed October 18, 2011 03:19AM UTC by mikesherov comment:3

this is important to note that this is only for styles that haven't been directly applied to elements (i.e. styles applied due to a stylesheet, not inline styling).

Otherwise, this would just be the same as #10254 or #8388

Changed December 19, 2011 03:39AM UTC by mikesherov comment:4

Also important to note that for disconnected nodes, the value should be 10px in the example, as per CSSOM spec which says that margin/padding/border/width for elements that have a display of none (including disconnected nodes) should return 0px.

However, in IE: 0px (incorrect)

in chrome: empty string (incorrect)

in FF: resolved value (correct)


Changed January 08, 2012 04:47AM UTC by mikesherov comment:5

owner: → mikesherov
status: openassigned

I'm taking this ticket as I'm advocating for it's fix in webkit proper. There will be no fix in jQuery though unless some miracle allows us to find a hack here.

Changed January 08, 2012 05:03AM UTC by mikesherov comment:6

Changed May 23, 2012 12:27PM UTC by mikesherov comment:7

resolution: → cantfix
status: assignedclosed

So, I'm going to close this ticket as CANTFIX because this behavior is consistent across chrome, safari, opera, IE9, and IE10. Only Firefox exhibits the behavior you'd like. I will continue to advocate for this as the W3C and browser vendor level, but I can't promise anything, and there is no hack I've found in any of the browsers.