aboutsummaryrefslogtreecommitdiffstats
path: root/src/css.js
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2012-07-22 21:58:23 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-07-22 22:03:27 -0400
commitaa3fabce461313f7c31e9a250df57165f15be873 (patch)
tree5b1a227fd3fc96d6f8ec6b60670d467689dfd760 /src/css.js
parentff7a43456228826856f5f14f22fbe2d61ef59bf5 (diff)
downloadjquery-aa3fabce461313f7c31e9a250df57165f15be873.tar.gz
jquery-aa3fabce461313f7c31e9a250df57165f15be873.zip
Fix #12088, Safari 5 and more percentages in getComputedStyle
In particular, min-width and max-width are taunting the awesome hack. Closes gh-865.
Diffstat (limited to 'src/css.js')
-rw-r--r--src/css.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/css.js b/src/css.js
index 6c43be399..41b978542 100644
--- a/src/css.js
+++ b/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;
}
}