aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.core.js
diff options
context:
space:
mode:
authorBrant Burnett <btburnett3@gmail.com>2010-01-29 18:38:21 +0000
committerBrant Burnett <btburnett3@gmail.com>2010-01-29 18:38:21 +0000
commitb91ecde0a7d60185d47493c455e9fec3666d483a (patch)
treea43f28e80e20a214b21ae62aa6af79fbb73cb07c /ui/jquery.ui.core.js
parentf214b708894ef2a1607050977f9698cf0d916d43 (diff)
downloadjquery-ui-b91ecde0a7d60185d47493c455e9fec3666d483a.tar.gz
jquery-ui-b91ecde0a7d60185d47493c455e9fec3666d483a.zip
'Changed
Diffstat (limited to 'ui/jquery.ui.core.js')
-rw-r--r--ui/jquery.ui.core.js30
1 files changed, 20 insertions, 10 deletions
diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js
index 934210348..2f238a01c 100644
--- a/ui/jquery.ui.core.js
+++ b/ui/jquery.ui.core.js
@@ -149,17 +149,27 @@ $.fn.extend({
if (zIndex !== undefined) {
return this.css('zIndex', zIndex);
}
-
- var elem = this[0];
- while (elem && elem.style) {
- // IE returns 0 when zIndex is not specified
- // other browsers return an empty string
- // we ignore the case of nested elements with an explicit value of 0
- // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
- if (elem.style.zIndex !== '' && elem.style.zIndex !== 0) {
- return +elem.style.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
+ // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
+ value = parseInt(elem.css('zIndex'));
+ if (!isNaN(value) && value != 0) {
+ return value;
+ }
+ }
+ elem = elem.parent();
}
- elem = elem.parentNode;
}
return 0;