mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Fix #12088, Safari 5 and more percentages in getComputedStyle
In particular, min-width and max-width are taunting the awesome hack. Closes gh-865.
This commit is contained in:
committed by
Dave Methvin
parent
ff7a434562
commit
aa3fabce46
17
src/css.js
17
src/css.js
@@ -276,7 +276,7 @@ jQuery.extend({
|
||||
// and getComputedStyle here to produce a better gzip size
|
||||
if ( window.getComputedStyle ) {
|
||||
curCSS = function( elem, name ) {
|
||||
var ret, width,
|
||||
var ret, width, minWidth, maxWidth,
|
||||
computed = getComputedStyle( elem, null ),
|
||||
style = elem.style;
|
||||
|
||||
@@ -288,13 +288,20 @@ if ( window.getComputedStyle ) {
|
||||
}
|
||||
|
||||
// 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 ) ) {
|
||||
// Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
|
||||
// Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
|
||||
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
|
||||
if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
|
||||
width = style.width;
|
||||
style.width = ret;
|
||||
minWidth = style.minWidth;
|
||||
maxWidth = style.maxWidth;
|
||||
|
||||
style.minWidth = style.maxWidth = style.width = ret;
|
||||
ret = computed.width;
|
||||
|
||||
style.width = width;
|
||||
style.minWidth = minWidth;
|
||||
style.maxWidth = maxWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,6 @@ jQuery.support = (function() {
|
||||
inlineBlockNeedsLayout: false,
|
||||
shrinkWrapBlocks: false,
|
||||
reliableMarginRight: true,
|
||||
pixelMargin: true,
|
||||
boxSizingReliable: true,
|
||||
pixelPosition: false
|
||||
};
|
||||
@@ -220,7 +219,6 @@ jQuery.support = (function() {
|
||||
// The difference between window.getComputedStyle and getComputedStyle is
|
||||
// 7 bytes
|
||||
if ( window.getComputedStyle ) {
|
||||
support.pixelMargin = ( window.getComputedStyle( div, null ) || {} ).marginTop !== "1%";
|
||||
support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
|
||||
support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user