};
curCSS = function( elem, name, computed ) {
- var left, ret,
+ var left, rs, rsLeft, ret,
style = elem.style;
computed = computed || getStyles( elem );
ret = style[ name ];
}
- // Simplified hack by Dean Edwards
+ // From the awesome hack by Dean Edwards
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
// If we're not dealing with a regular pixel number
// Remember the original values
left = style.left;
+ rs = elem.runtimeStyle;
+ rsLeft = rs && rs.left;
// Put in the new values to get a computed value out
+ if ( rsLeft ) {
+ rs.left = elem.currentStyle.left;
+ }
style.left = name === "fontSize" ? "1em" : ret;
ret = style.pixelLeft + "px";
// Revert the changed values
style.left = left;
+ if ( rsLeft ) {
+ rs.left = rsLeft;
+ }
}
// Support: IE<9
QUnit.test( "css(String) computed values", function( assert ) {
assert.expect( 3 );
- var div = jQuery( "<div/>" ).addClass( "get-computed-value" ),
- fixture = document.getElementById( "qunit-fixture" );
-
- div.appendTo( fixture );
- assert.strictEqual( div.css( "padding-left" ), "500px", "should get computed value for padding-left property" );
- assert.strictEqual( div.css( "width" ), "200px", "should get computed value for width property" );
- assert.strictEqual( div.css( "font-size" ), "32px", "should get computed value for font-size property" );
-} );
-
-QUnit.test( "css() explicit and relative values", function( assert ) {
- assert.expect( 29 );
-
- var $elem = jQuery( "#nothiddendiv" );
+test( "css() explicit and relative values", 29, function() {
+ var $elem = jQuery("#nothiddendiv");
$elem.css( { "width": 1, "height": 1, "paddingLeft": "1px", "opacity": 1 } );
assert.equal( $elem.css( "width" ), "1px", "Initial css set or width/height works (hash)" );