@@ -4,8 +4,8 @@ var ralpha = /alpha\([^)]*\)/i,
4
4
ropacity = / o p a c i t y = ( [ ^ ) ] * ) / ,
5
5
// fixed for IE9, see #8346
6
6
rupper = / ( [ A - Z ] | ^ m s ) / g,
7
- rnumpx = / ^ - ? \d + (?: p x ) ? $ / i,
8
- rnumnopx = / ^ - ? \d + (? ! p x ) [ ^ \d \s ] + $ / i,
7
+ rnum = / ^ [ \- + ] ? (?: \d * \. ) ? \d + $ / i,
8
+ rnumnonpx = / ^ - ? (?: \d * \. ) ? \d + (? ! p x ) [ ^ \d \s ] + $ / i,
9
9
rrelNum = / ^ ( [ \- + ] ) = ( [ \- + . \d e ] + ) / ,
10
10
rmargin = / ^ m a r g i n / ,
11
11
@@ -181,17 +181,9 @@ jQuery.each(["height", "width"], function( i, name ) {
181
181
} ,
182
182
183
183
set : function ( elem , value ) {
184
- if ( rnumpx . test ( value ) ) {
185
- // ignore negative width and height values #1599
186
- value = parseFloat ( value ) ;
187
-
188
- if ( value >= 0 ) {
189
- return value + "px" ;
190
- }
191
-
192
- } else {
193
- return value ;
194
- }
184
+ return rnum . test ( value ) ?
185
+ value + "px" :
186
+ value ;
195
187
}
196
188
} ;
197
189
} ) ;
@@ -274,7 +266,7 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
274
266
// A tribute to the "awesome hack by Dean Edwards"
275
267
// WebKit uses "computed value (percentage if specified)" instead of "used value" for margins
276
268
// which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
277
- if ( ! jQuery . support . pixelMargin && computedStyle && rmargin . test ( name ) && rnumnopx . test ( ret ) ) {
269
+ if ( ! jQuery . support . pixelMargin && computedStyle && rmargin . test ( name ) && rnumnonpx . test ( ret ) ) {
278
270
width = style . width ;
279
271
style . width = ret ;
280
272
ret = computedStyle . width ;
@@ -302,7 +294,7 @@ if ( document.documentElement.currentStyle ) {
302
294
303
295
// If we're not dealing with a regular pixel number
304
296
// but a number that has a weird ending, we need to convert it to pixels
305
- if ( rnumnopx . test ( ret ) ) {
297
+ if ( rnumnonpx . test ( ret ) ) {
306
298
307
299
// Remember the original values
308
300
left = style . left ;
0 commit comments