From 32d61d75e575465bca2b4aa721ed39dd147e21c7 Mon Sep 17 00:00:00 2001 From: George Kats Date: Sun, 6 Oct 2013 19:53:26 +0300 Subject: [PATCH] Fix #14432: Always return string from .css("z-index"). Close gh-1395. (cherry picked from commit 5ce4b06c285bd8cf52eaff0f39e0b9192a927873) Conflicts: src/css/curCSS.js --- src/css/curCSS.js | 10 ++++++++-- test/unit/css.js | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/css/curCSS.js b/src/css/curCSS.js index e09574530..1af1812cd 100644 --- a/src/css/curCSS.js +++ b/src/css/curCSS.js @@ -51,7 +51,9 @@ if ( window.getComputedStyle ) { } } - return ret; + // Support: IE + // IE returns zIndex value as an integer. + return ret === undefined ? ret : ret + ""; }; } else if ( document.documentElement.currentStyle ) { getStyles = function( elem ) { @@ -99,7 +101,11 @@ if ( window.getComputedStyle ) { } } - return ret === "" ? "auto" : ret; + return ret === "" ? "auto" : + // Support: IE + // IE returns zIndex value as an integer. + ret === undefined ? ret : + ret + ""; }; } diff --git a/test/unit/css.js b/test/unit/css.js index e6f9c91df..56d22bdf2 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -200,6 +200,16 @@ test( "css() explicit and relative values", 29, function() { equal( $elem.css("opacity"), "1", "'+=0.5' on opacity (params)" ); }); +test("css(String) where values are z-index", function() { + expect(1); + + var $elem = jQuery( "
" ).appendTo( "#qunit-fixture" ); + + $elem.css({ "position": "absolute", "z-index": "1000" }); + strictEqual( $elem.css( "z-index" ), "1000" ); +}); + + test("css(String, Object)", function() { expect( 19 ); var j, div, display, ret, success; @@ -393,6 +403,14 @@ test("css(Object) where values are Functions", function() { jQuery("#cssFunctionTest").remove(); }); +test("css(String) where values are undefined", function() { + expect(1); + + var $elem = jQuery( "#nothiddendiv" ); + + strictEqual( $elem.css( "test" ), undefined ); +}); + test("css(Object) where values are Functions with incoming values", function() { expect(3);