Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Landing pull request 553. Fallback to elem.style for disconnected nod…
…es in width/height retrieval. Fixes #8388.

More Details:
 - #553
 - http://bugs.jquery.com/ticket/10254
 - http://bugs.jquery.com/ticket/8388
  • Loading branch information
mikesherov authored and timmywil committed Oct 22, 2011
1 parent e1a5d3e commit e502012
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/css.js
Expand Up @@ -290,6 +290,10 @@ if ( document.documentElement.currentStyle ) {
rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
style = elem.style;

if ( ret === null && style ) {
ret = style[ name ];
}

// From the awesome hack by Dean Edwards
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291

Expand Down
15 changes: 12 additions & 3 deletions test/unit/css.js
Expand Up @@ -435,7 +435,7 @@ test(":visible selector works properly on children with a hidden parent (bug #45
test("internal ref to elem.runtimeStyle (bug #7608)", function () {
expect(1);
var result = true;

try {
jQuery("#foo").css( { width: "0%" } ).css("width");
} catch (e) {
Expand Down Expand Up @@ -476,7 +476,7 @@ test("widows & orphans #8936", function () {
var $p = jQuery("<p>").appendTo("#qunit-fixture");

if ( "widows" in $p[0].style ) {
expect(4);
expect(4);
$p.css({
widows: 0,
orphans: 0
Expand All @@ -502,6 +502,15 @@ test("widows & orphans #8936", function () {
$p.remove();
});

test("can't get css for disconnected in IE<9, see #10254 and #8388", function() {
expect( 2 );
var span = jQuery( "<span/>" ).css( "background-image", "url(http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif)" );
equal( span.css( "background-image" ), "url(http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif)", "can't get background-image in IE<9, see #10254" );

var div = jQuery( "<div/>" ).css( "top", 10 );
equal( div.css( "top" ), "10px", "can't get top in IE<9, see #8388" );
});

test("Do not append px to 'fill-opacity' #9548", 1, function() {

var $div = jQuery("<div>").appendTo("#qunit-fixture");
Expand All @@ -510,4 +519,4 @@ test("Do not append px to 'fill-opacity' #9548", 1, function() {
equal( jQuery(this).css("fill-opacity"), 1, "Do not append px to 'fill-opacity'");
});

});
});

0 comments on commit e502012

Please sign in to comment.