@@ -166,97 +166,16 @@ jQuery.extend({
166
166
// DEPRECATED, Use jQuery.css() instead
167
167
jQuery . curCSS = jQuery . css ;
168
168
169
- jQuery . each ( [ "height" , "width" ] , function ( i , name ) {
170
- jQuery . cssHooks [ name ] = {
171
- get : function ( elem , computed , extra ) {
172
- if ( computed ) {
173
- if ( elem . offsetWidth !== 0 ) {
174
- return getWidthOrHeight ( elem , name , extra ) ;
175
- } else {
176
- return jQuery . swap ( elem , cssShow , function ( ) {
177
- return getWidthOrHeight ( elem , name , extra ) ;
178
- } ) ;
179
- }
180
- }
181
- } ,
182
-
183
- set : function ( elem , value ) {
184
- return rnum . test ( value ) ?
185
- value + "px" :
186
- value ;
187
- }
188
- } ;
189
- } ) ;
190
-
191
- if ( ! jQuery . support . opacity ) {
192
- jQuery . cssHooks . opacity = {
193
- get : function ( elem , computed ) {
194
- // IE uses filters for opacity
195
- return ropacity . test ( ( computed && elem . currentStyle ? elem . currentStyle . filter : elem . style . filter ) || "" ) ?
196
- ( parseFloat ( RegExp . $1 ) / 100 ) + "" :
197
- computed ? "1" : "" ;
198
- } ,
199
-
200
- set : function ( elem , value ) {
201
- var style = elem . style ,
202
- currentStyle = elem . currentStyle ,
203
- opacity = jQuery . isNumeric ( value ) ? "alpha(opacity=" + value * 100 + ")" : "" ,
204
- filter = currentStyle && currentStyle . filter || style . filter || "" ;
205
-
206
- // IE has trouble with opacity if it does not have layout
207
- // Force it by setting the zoom level
208
- style . zoom = 1 ;
209
-
210
- // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
211
- if ( value >= 1 && jQuery . trim ( filter . replace ( ralpha , "" ) ) === "" ) {
212
-
213
- // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
214
- // if "filter:" is present at all, clearType is disabled, we want to avoid this
215
- // style.removeAttribute is IE Only, but so apparently is this code path...
216
- style . removeAttribute ( "filter" ) ;
217
-
218
- // if there there is no filter style applied in a css rule, we are done
219
- if ( currentStyle && ! currentStyle . filter ) {
220
- return ;
221
- }
222
- }
223
-
224
- // otherwise, set new filter values
225
- style . filter = ralpha . test ( filter ) ?
226
- filter . replace ( ralpha , opacity ) :
227
- filter + " " + opacity ;
228
- }
229
- } ;
230
- }
231
-
232
- jQuery ( function ( ) {
233
- // This hook cannot be added until DOM ready because the support test
234
- // for it is not run until after DOM ready
235
- if ( ! jQuery . support . reliableMarginRight ) {
236
- jQuery . cssHooks . marginRight = {
237
- get : function ( elem , computed ) {
238
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
239
- // Work around by temporarily setting element display to inline-block
240
- return jQuery . swap ( elem , { "display" : "inline-block" } , function ( ) {
241
- if ( computed ) {
242
- return curCSS ( elem , "margin-right" , "marginRight" ) ;
243
- } else {
244
- return elem . style . marginRight ;
245
- }
246
- } ) ;
247
- }
248
- } ;
249
- }
250
- } ) ;
251
-
252
169
if ( document . defaultView && document . defaultView . getComputedStyle ) {
253
170
getComputedStyle = function ( elem , name ) {
254
- var ret , defaultView , computedStyle , width , style = elem . style ;
171
+ var ret , defaultView , computedStyle , width ,
172
+ style = elem . style ;
255
173
256
174
name = name . replace ( rupper , "-$1" ) . toLowerCase ( ) ;
257
175
258
176
if ( ( defaultView = elem . ownerDocument . defaultView ) &&
259
177
( computedStyle = defaultView . getComputedStyle ( elem , null ) ) ) {
178
+
260
179
ret = computedStyle . getPropertyValue ( name ) ;
261
180
if ( ret === "" && ! jQuery . contains ( elem . ownerDocument . documentElement , elem ) ) {
262
181
ret = jQuery . style ( elem , name ) ;
@@ -349,6 +268,12 @@ function getWidthOrHeight( elem, name, extra ) {
349
268
if ( val < 0 || val == null ) {
350
269
val = elem . style [ name ] ;
351
270
}
271
+
272
+ // Computed unit is not pixels. Stop here and return.
273
+ if ( rnumnonpx . test ( val ) ) {
274
+ return val ;
275
+ }
276
+
352
277
// Normalize "", auto, and prepare for extra
353
278
val = parseFloat ( val ) || 0 ;
354
279
@@ -368,6 +293,89 @@ function getWidthOrHeight( elem, name, extra ) {
368
293
return val + "px" ;
369
294
}
370
295
296
+ jQuery . each ( [ "height" , "width" ] , function ( i , name ) {
297
+ jQuery . cssHooks [ name ] = {
298
+ get : function ( elem , computed , extra ) {
299
+ if ( computed ) {
300
+ if ( elem . offsetWidth !== 0 ) {
301
+ return getWidthOrHeight ( elem , name , extra ) ;
302
+ } else {
303
+ return jQuery . swap ( elem , cssShow , function ( ) {
304
+ return getWidthOrHeight ( elem , name , extra ) ;
305
+ } ) ;
306
+ }
307
+ }
308
+ } ,
309
+
310
+ set : function ( elem , value ) {
311
+ return rnum . test ( value ) ?
312
+ value + "px" :
313
+ value ;
314
+ }
315
+ } ;
316
+ } ) ;
317
+
318
+ if ( ! jQuery . support . opacity ) {
319
+ jQuery . cssHooks . opacity = {
320
+ get : function ( elem , computed ) {
321
+ // IE uses filters for opacity
322
+ return ropacity . test ( ( computed && elem . currentStyle ? elem . currentStyle . filter : elem . style . filter ) || "" ) ?
323
+ ( parseFloat ( RegExp . $1 ) / 100 ) + "" :
324
+ computed ? "1" : "" ;
325
+ } ,
326
+
327
+ set : function ( elem , value ) {
328
+ var style = elem . style ,
329
+ currentStyle = elem . currentStyle ,
330
+ opacity = jQuery . isNumeric ( value ) ? "alpha(opacity=" + value * 100 + ")" : "" ,
331
+ filter = currentStyle && currentStyle . filter || style . filter || "" ;
332
+
333
+ // IE has trouble with opacity if it does not have layout
334
+ // Force it by setting the zoom level
335
+ style . zoom = 1 ;
336
+
337
+ // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
338
+ if ( value >= 1 && jQuery . trim ( filter . replace ( ralpha , "" ) ) === "" ) {
339
+
340
+ // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
341
+ // if "filter:" is present at all, clearType is disabled, we want to avoid this
342
+ // style.removeAttribute is IE Only, but so apparently is this code path...
343
+ style . removeAttribute ( "filter" ) ;
344
+
345
+ // if there there is no filter style applied in a css rule, we are done
346
+ if ( currentStyle && ! currentStyle . filter ) {
347
+ return ;
348
+ }
349
+ }
350
+
351
+ // otherwise, set new filter values
352
+ style . filter = ralpha . test ( filter ) ?
353
+ filter . replace ( ralpha , opacity ) :
354
+ filter + " " + opacity ;
355
+ }
356
+ } ;
357
+ }
358
+
359
+ jQuery ( function ( ) {
360
+ // This hook cannot be added until DOM ready because the support test
361
+ // for it is not run until after DOM ready
362
+ if ( ! jQuery . support . reliableMarginRight ) {
363
+ jQuery . cssHooks . marginRight = {
364
+ get : function ( elem , computed ) {
365
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
366
+ // Work around by temporarily setting element display to inline-block
367
+ return jQuery . swap ( elem , { "display" : "inline-block" } , function ( ) {
368
+ if ( computed ) {
369
+ return curCSS ( elem , "margin-right" , "marginRight" ) ;
370
+ } else {
371
+ return elem . style . marginRight ;
372
+ }
373
+ } ) ;
374
+ }
375
+ } ;
376
+ }
377
+ } ) ;
378
+
371
379
if ( jQuery . expr && jQuery . expr . filters ) {
372
380
jQuery . expr . filters . hidden = function ( elem ) {
373
381
var width = elem . offsetWidth ,
0 commit comments