diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2012-06-15 21:20:41 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-06-15 21:25:25 -0400 |
commit | 0b352f6cb58a1ece3f5d1fb978cdb40bd5b0e854 (patch) | |
tree | e1b5fc8164ce147cdba540724b0c2c2c529a4ad2 /src/css.js | |
parent | a101e81bde71e94170f1fa899432cbe8150910f9 (diff) | |
download | jquery-0b352f6cb58a1ece3f5d1fb978cdb40bd5b0e854.tar.gz jquery-0b352f6cb58a1ece3f5d1fb978cdb40bd5b0e854.zip |
Fix #9505, percentage position values in Webkit, closes gh-825.
Diffstat (limited to 'src/css.js')
-rw-r--r-- | src/css.js | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/src/css.js b/src/css.js index e3390793a..d23284a1c 100644 --- a/src/css.js +++ b/src/css.js @@ -135,8 +135,6 @@ jQuery.extend({ var ret = curCSS( elem, "opacity" ); return ret === "" ? "1" : ret; - } else { - return elem.style.opacity; } } } @@ -288,16 +286,16 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) { if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) { ret = jQuery.style( elem, name ); } - } - // A tribute to the "awesome hack by Dean Edwards" - // WebKit uses "computed value (percentage if specified)" instead of "used value" for margins - // which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values - if ( !jQuery.support.pixelMargin && computedStyle && rmargin.test( name ) && rnumnonpx.test( ret ) ) { - width = style.width; - style.width = ret; - ret = computedStyle.width; - style.width = width; + // A tribute to the "awesome hack by Dean Edwards" + // WebKit uses "computed value (percentage if specified)" instead of "used value" for margins + // which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values + if ( !jQuery.support.pixelMargin && rmargin.test( name ) && rnumnonpx.test( ret ) ) { + width = style.width; + style.width = ret; + ret = computedStyle.width; + style.width = width; + } } return ret; @@ -544,9 +542,9 @@ if ( !jQuery.support.opacity ) { }; } +// These hooks cannot be added until DOM ready because the support test +// for it is not run until after DOM ready jQuery(function() { - // This hook cannot be added until DOM ready because the support test - // for it is not run until after DOM ready if ( !jQuery.support.reliableMarginRight ) { jQuery.cssHooks.marginRight = { get: function( elem, computed ) { @@ -562,6 +560,24 @@ jQuery(function() { } }; } + + // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 + // getComputedStyle returns percent when specified for top/left/bottom/right + // rather than make the css module depend on the offset module, we just check for it here + if ( !jQuery.support.pixelPosition && jQuery.fn.position ) { + jQuery.each( [ "top", "left" ], function( i, prop ) { + jQuery.cssHooks[ prop ] = { + get: function( elem, computed ) { + if ( computed ) { + var ret = curCSS( elem, prop ); + // if curCSS returns percentage, fallback to offset + return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret; + } + } + }; + }); + } + }); if ( jQuery.expr && jQuery.expr.filters ) { |