From: jeresig Date: Sat, 5 Dec 2009 20:12:02 +0000 (-0500) Subject: Made sure that css() in IE handles negative non-px values correctly. Fixes #3331. X-Git-Tag: 1.4a2~103 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aae0617c834a030902cd8da2714f852d6a1431be;p=jquery.git Made sure that css() in IE handles negative non-px values correctly. Fixes #3331. --- diff --git a/src/css.js b/src/css.js index a16298d6c..c36b6dcc2 100644 --- a/src/css.js +++ b/src/css.js @@ -5,8 +5,8 @@ var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, rfloat = /float/i, rdashAlpha = /-([a-z])/ig, rupper = /([A-Z])/g, - rnumpx = /^\d+(?:px)?$/i, - rnum = /^\d/, + rnumpx = /^-?\d+(?:px)?$/i, + rnum = /^-?\d/, // cache check for defaultView.getComputedStyle getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, diff --git a/test/unit/css.js b/test/unit/css.js index c199ca1eb..76274752e 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -59,13 +59,16 @@ test("css(String|Hash)", function() { }); test("css(String, Object)", function() { - expect(20); + expect(21); ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible'); jQuery('#nothiddendiv').css("display", 'none'); ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden'); jQuery('#nothiddendiv').css("display", 'block'); ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible'); + jQuery("#nothiddendiv").css("top", "-1em"); + ok( jQuery("#nothiddendiv").css("top"), -16, "Check negative number in EMs." ); + jQuery('#floatTest').css('styleFloat', 'left'); equals( jQuery('#floatTest').css('styleFloat'), 'left', 'Modified CSS float using "styleFloat": Assert float is left'); jQuery('#floatTest').css('cssFloat', 'right');