aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2011-12-08 20:26:50 -0500
committerDave Methvin <dave.methvin@gmail.com>2011-12-08 20:26:50 -0500
commitd6500cc8ded8d3d02e19a3ab831b6b9cf43e82ae (patch)
tree3719715715c75544e88972c051b5c05c94a5d7b8
parent8f5f1b2e6c0f7b8b6d66bfc06c7b169a9443c2b8 (diff)
downloadjquery-d6500cc8ded8d3d02e19a3ab831b6b9cf43e82ae.tar.gz
jquery-d6500cc8ded8d3d02e19a3ab831b6b9cf43e82ae.zip
Fix #10858: CSS regexps recognize non-integer and explicit positive numbers.
-rw-r--r--src/css.js22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/css.js b/src/css.js
index 4d4e2dc82..3c2e2b59b 100644
--- a/src/css.js
+++ b/src/css.js
@@ -4,8 +4,8 @@ var ralpha = /alpha\([^)]*\)/i,
ropacity = /opacity=([^)]*)/,
// fixed for IE9, see #8346
rupper = /([A-Z]|^ms)/g,
- rnumpx = /^-?\d+(?:px)?$/i,
- rnumnopx = /^-?\d+(?!px)[^\d\s]+$/i,
+ rnum = /^[\-+]?(?:\d*\.)?\d+$/i,
+ rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,
rrelNum = /^([\-+])=([\-+.\de]+)/,
rmargin = /^margin/,
@@ -181,17 +181,9 @@ jQuery.each(["height", "width"], function( i, name ) {
},
set: function( elem, value ) {
- if ( rnumpx.test( value ) ) {
- // ignore negative width and height values #1599
- value = parseFloat( value );
-
- if ( value >= 0 ) {
- return value + "px";
- }
-
- } else {
- return value;
- }
+ return rnum.test( value ) ?
+ value + "px" :
+ value;
}
};
});
@@ -274,7 +266,7 @@ if ( document.defaultView && document.defaultView.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 && computedStyle && rmargin.test( name ) && rnumnopx.test( ret ) ) {
+ if ( !jQuery.support.pixelMargin && computedStyle && rmargin.test( name ) && rnumnonpx.test( ret ) ) {
width = style.width;
style.width = ret;
ret = computedStyle.width;
@@ -302,7 +294,7 @@ if ( document.documentElement.currentStyle ) {
// If we're not dealing with a regular pixel number
// but a number that has a weird ending, we need to convert it to pixels
- if ( rnumnopx.test( ret ) ) {
+ if ( rnumnonpx.test( ret ) ) {
// Remember the original values
left = style.left;