mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Fix #9505, percentage position values in Webkit, closes gh-825.
This commit is contained in:
committed by
Dave Methvin
parent
a101e81bde
commit
0b352f6cb5
42
src/css.js
42
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 ) {
|
||||
|
||||
Reference in New Issue
Block a user