From 22ccbf82c8badd1d46f5ea52a0a7d5f3935a9fca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 11 Oct 2010 15:11:03 -0400 Subject: [PATCH] Fixed getting styles from disconnected nodes. Fixes #7148. --- src/css.js | 3 +++ test/unit/css.js | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/css.js b/src/css.js index d0e55db0f..933d2b45e 100644 --- a/src/css.js +++ b/src/css.js @@ -230,6 +230,9 @@ if ( getComputedStyle ) { if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) { ret = computedStyle.getPropertyValue( name ); + if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) { + ret = jQuery.style( elem, name ); + } } return ret; diff --git a/test/unit/css.js b/test/unit/css.js index 8a4909689..632464bcd 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -1,7 +1,7 @@ module("css"); test("css(String|Hash)", function() { - expect(33); + expect(34); equals( jQuery('#main').css("display"), 'block', 'Check for css property "display"'); @@ -19,6 +19,8 @@ test("css(String|Hash)", function() { equals( parseFloat(jQuery('#nothiddendiv').css('width')), width, 'Test negative width ignored') equals( parseFloat(jQuery('#nothiddendiv').css('height')), height, 'Test negative height ignored') + equals( jQuery('
').css('display'), 'none', 'Styles on disconnected nodes'); + jQuery('#floatTest').css({'float': 'right'}); equals( jQuery('#floatTest').css('float'), 'right', 'Modified CSS float using "float": Assert float is right'); jQuery('#floatTest').css({'font-size': '30px'}); -- 2.39.5