From 932caaf2ddf70c889003d5b42eee4f069d2dd296 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 15 Mar 2013 07:01:24 -0400 Subject: [PATCH] Core: Deprecated .zIndex(). Fixes #9061 - Core: Deprecate .zIndex(). --- build/tasks/testswarm.js | 1 + tests/unit/all.html | 1 + tests/unit/core/core.html | 11 --- tests/unit/core/core.js | 19 ---- tests/unit/core/core_deprecated.html | 136 +++++++++++++++++++++++++++ tests/unit/core/core_deprecated.js | 24 +++++ ui/jquery.ui.core.js | 58 ++++++------ 7 files changed, 191 insertions(+), 59 deletions(-) create mode 100644 tests/unit/core/core_deprecated.html create mode 100644 tests/unit/core/core_deprecated.js diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js index d747d16f9..01fb178f9 100644 --- a/build/tasks/testswarm.js +++ b/build/tasks/testswarm.js @@ -14,6 +14,7 @@ var versions = { "Autocomplete": "autocomplete/autocomplete.html", "Button": "button/button.html", "Core": "core/core.html", + "Core_deprecated": "core/core_deprecated.html", "Datepicker": "datepicker/datepicker.html", "Dialog": "dialog/dialog.html", "Draggable": "draggable/draggable.html", diff --git a/tests/unit/all.html b/tests/unit/all.html index 22b1802dc..8dfff2a4e 100644 --- a/tests/unit/all.html +++ b/tests/unit/all.html @@ -20,6 +20,7 @@ "autocomplete/autocomplete.html", "button/button.html", "core/core.html", + "core/core_deprecated.html", "datepicker/datepicker.html", "dialog/dialog.html", "draggable/draggable.html", diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index 41c8db827..fd472d64a 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -117,17 +117,6 @@ -
-
.
-
-
-
.
-
-
-
.
-
-
-
diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js index 78a225338..54d50d84e 100644 --- a/tests/unit/core/core.js +++ b/tests/unit/core/core.js @@ -26,25 +26,6 @@ asyncTest( "focus", function() { }); }); -test( "zIndex", function() { - expect( 7 ); - var el = $( "#zIndexAutoWithParent" ), - parent = el.parent(); - equal( el.zIndex(), 100, "zIndex traverses up to find value" ); - equal( parent.zIndex(200 ), parent, "zIndex setter is chainable" ); - equal( el.zIndex(), 200, "zIndex setter changed zIndex" ); - - el = $( "#zIndexAutoWithParentViaCSS" ); - equal( el.zIndex(), 0, "zIndex traverses up to find CSS value, not found because not positioned" ); - - el = $( "#zIndexAutoWithParentViaCSSPositioned" ); - equal( el.zIndex(), 100, "zIndex traverses up to find CSS value" ); - el.parent().zIndex( 200 ); - equal( el.zIndex(), 200, "zIndex setter changed zIndex, overriding CSS" ); - - equal( $( "#zIndexAutoNoParent" ).zIndex(), 0, "zIndex never explicitly set in hierarchy" ); -}); - test( "innerWidth - getter", function() { expect( 2 ); var el = $( "#dimensions" ); diff --git a/tests/unit/core/core_deprecated.html b/tests/unit/core/core_deprecated.html new file mode 100644 index 000000000..d9c41ca39 --- /dev/null +++ b/tests/unit/core/core_deprecated.html @@ -0,0 +1,136 @@ + + + + + jQuery UI Core Test Suite + + + + + + + + + + + + + + + + + +

jQuery UI Core Test Suite

+

+
+

+
    +
    + + + + + + + + + + +
    +
    + +
    + + + + + + + + + + xxx + anchor + anchor + x +
    x
    + x +
    x
    +
    + +
    + + + + + + + + + +
    + +
    + + + + + + + + + +
    + +
    + + + + + + . + . + . + . +
    + +
    + + +
    + +
    +
    .
    +
    +
    +
    .
    +
    +
    +
    .
    +
    +
    + +
    + +
    + + diff --git a/tests/unit/core/core_deprecated.js b/tests/unit/core/core_deprecated.js new file mode 100644 index 000000000..bb06f77b2 --- /dev/null +++ b/tests/unit/core/core_deprecated.js @@ -0,0 +1,24 @@ +(function( $ ) { + +module( "core - deprecated" ); + +test( "zIndex", function() { + expect( 7 ); + var el = $( "#zIndexAutoWithParent" ), + parent = el.parent(); + equal( el.zIndex(), 100, "zIndex traverses up to find value" ); + equal( parent.zIndex(200 ), parent, "zIndex setter is chainable" ); + equal( el.zIndex(), 200, "zIndex setter changed zIndex" ); + + el = $( "#zIndexAutoWithParentViaCSS" ); + equal( el.zIndex(), 0, "zIndex traverses up to find CSS value, not found because not positioned" ); + + el = $( "#zIndexAutoWithParentViaCSSPositioned" ); + equal( el.zIndex(), 100, "zIndex traverses up to find CSS value" ); + el.parent().zIndex( 200 ); + equal( el.zIndex(), 200, "zIndex setter changed zIndex, overriding CSS" ); + + equal( $( "#zIndexAutoNoParent" ).zIndex(), 0, "zIndex never explicitly set in hierarchy" ); +}); + +})( jQuery ); diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index 1a13da251..0d263fa5f 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -78,35 +78,6 @@ $.fn.extend({ return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent; }, - zIndex: function( zIndex ) { - if ( zIndex !== undefined ) { - return this.css( "zIndex", zIndex ); - } - - if ( this.length ) { - var elem = $( this[ 0 ] ), position, value; - while ( elem.length && elem[ 0 ] !== document ) { - // Ignore z-index if position is set to a value where z-index is ignored by the browser - // This makes behavior of this function consistent across browsers - // WebKit always returns auto if the element is positioned - position = elem.css( "position" ); - if ( position === "absolute" || position === "relative" || position === "fixed" ) { - // IE returns 0 when zIndex is not specified - // other browsers return a string - // we ignore the case of nested elements with an explicit value of 0 - //
    - value = parseInt( elem.css( "zIndex" ), 10 ); - if ( !isNaN( value ) && value !== 0 ) { - return value; - } - } - elem = elem.parent(); - } - } - - return 0; - }, - uniqueId: function() { return this.each(function() { if ( !this.id ) { @@ -263,6 +234,35 @@ $.fn.extend({ enableSelection: function() { return this.unbind( ".ui-disableSelection" ); + }, + + zIndex: function( zIndex ) { + if ( zIndex !== undefined ) { + return this.css( "zIndex", zIndex ); + } + + if ( this.length ) { + var elem = $( this[ 0 ] ), position, value; + while ( elem.length && elem[ 0 ] !== document ) { + // Ignore z-index if position is set to a value where z-index is ignored by the browser + // This makes behavior of this function consistent across browsers + // WebKit always returns auto if the element is positioned + position = elem.css( "position" ); + if ( position === "absolute" || position === "relative" || position === "fixed" ) { + // IE returns 0 when zIndex is not specified + // other browsers return a string + // we ignore the case of nested elements with an explicit value of 0 + //
    + value = parseInt( elem.css( "zIndex" ), 10 ); + if ( !isNaN( value ) && value !== 0 ) { + return value; + } + } + elem = elem.parent(); + } + } + + return 0; } }); -- 2.39.5