From aae0617c834a030902cd8da2714f852d6a1431be Mon Sep 17 00:00:00 2001 From: jeresig Date: Sat, 5 Dec 2009 15:12:02 -0500 Subject: [PATCH] Made sure that css() in IE handles negative non-px values correctly. Fixes #3331. --- src/css.js | 4 ++-- test/unit/css.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) 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'); -- 2.39.5