|
1 |
| -var curCSS, getStyles, iframe, |
2 |
| - ralpha = /alpha\([^)]*\)/i, |
3 |
| - ropacity = /opacity\s*=\s*([^)]*)/, |
4 |
| - rposition = /^(top|right|bottom|left)$/, |
| 1 | +var curCSS, iframe, |
5 | 2 | // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
|
6 | 3 | // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
|
7 | 4 | rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
@@ -50,6 +47,12 @@ function isHidden( elem, el ) {
|
50 | 47 | return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
|
51 | 48 | }
|
52 | 49 |
|
| 50 | +// NOTE: we've included the "window" in window.getComputedStyle |
| 51 | +// because jsdom on node.js will break without it. |
| 52 | +function getStyles( elem ) { |
| 53 | + return window.getComputedStyle( elem, null ); |
| 54 | +} |
| 55 | + |
53 | 56 | function showHide( elements, show ) {
|
54 | 57 | var elem,
|
55 | 58 | values = [],
|
@@ -294,99 +297,47 @@ jQuery.extend({
|
294 | 297 | }
|
295 | 298 | });
|
296 | 299 |
|
297 |
| -// NOTE: we've included the "window" in window.getComputedStyle |
298 |
| -// because jsdom on node.js will break without it. |
299 |
| -if ( window.getComputedStyle ) { |
300 |
| - getStyles = function( elem ) { |
301 |
| - return window.getComputedStyle( elem, null ); |
302 |
| - }; |
303 |
| - |
304 |
| - curCSS = function( elem, name, _computed ) { |
305 |
| - var width, minWidth, maxWidth, |
306 |
| - computed = _computed || getStyles( elem ), |
307 |
| - |
308 |
| - // getPropertyValue is only needed for .css('filter') in IE9, see #12537 |
309 |
| - ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined, |
310 |
| - style = elem.style; |
311 |
| - |
312 |
| - if ( computed ) { |
| 300 | +curCSS = function( elem, name, _computed ) { |
| 301 | + var width, minWidth, maxWidth, |
| 302 | + computed = _computed || getStyles( elem ), |
313 | 303 |
|
314 |
| - if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { |
315 |
| - ret = jQuery.style( elem, name ); |
316 |
| - } |
317 |
| - |
318 |
| - // A tribute to the "awesome hack by Dean Edwards" |
319 |
| - // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right |
320 |
| - // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels |
321 |
| - // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values |
322 |
| - if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { |
323 |
| - |
324 |
| - // Remember the original values |
325 |
| - width = style.width; |
326 |
| - minWidth = style.minWidth; |
327 |
| - maxWidth = style.maxWidth; |
328 |
| - |
329 |
| - // Put in the new values to get a computed value out |
330 |
| - style.minWidth = style.maxWidth = style.width = ret; |
331 |
| - ret = computed.width; |
332 |
| - |
333 |
| - // Revert the changed values |
334 |
| - style.width = width; |
335 |
| - style.minWidth = minWidth; |
336 |
| - style.maxWidth = maxWidth; |
337 |
| - } |
338 |
| - } |
339 |
| - |
340 |
| - return ret; |
341 |
| - }; |
342 |
| -} else if ( document.documentElement.currentStyle ) { |
343 |
| - getStyles = function( elem ) { |
344 |
| - return elem.currentStyle; |
345 |
| - }; |
| 304 | + // Support: IE9 |
| 305 | + // getPropertyValue is only needed for .css('filter') in IE9, see #12537 |
| 306 | + ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined, |
| 307 | + style = elem.style; |
346 | 308 |
|
347 |
| - curCSS = function( elem, name, _computed ) { |
348 |
| - var left, rs, rsLeft, |
349 |
| - computed = _computed || getStyles( elem ), |
350 |
| - ret = computed ? computed[ name ] : undefined, |
351 |
| - style = elem.style; |
| 309 | + if ( computed ) { |
352 | 310 |
|
353 |
| - // Avoid setting ret to empty string here |
354 |
| - // so we don't default to auto |
355 |
| - if ( ret == null && style && style[ name ] ) { |
356 |
| - ret = style[ name ]; |
| 311 | + if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { |
| 312 | + ret = jQuery.style( elem, name ); |
357 | 313 | }
|
358 | 314 |
|
359 |
| - // From the awesome hack by Dean Edwards |
360 |
| - // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 |
361 |
| - |
362 |
| - // If we're not dealing with a regular pixel number |
363 |
| - // but a number that has a weird ending, we need to convert it to pixels |
364 |
| - // but not position css attributes, as those are proportional to the parent element instead |
365 |
| - // and we can't measure the parent instead because it might trigger a "stacking dolls" problem |
366 |
| - if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { |
| 315 | + // Support: Chrome <17, Safari 5.1 |
| 316 | + // A tribute to the "awesome hack by Dean Edwards" |
| 317 | + // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right |
| 318 | + // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels |
| 319 | + // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values |
| 320 | + if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { |
367 | 321 |
|
368 | 322 | // Remember the original values
|
369 |
| - left = style.left; |
370 |
| - rs = elem.runtimeStyle; |
371 |
| - rsLeft = rs && rs.left; |
| 323 | + width = style.width; |
| 324 | + minWidth = style.minWidth; |
| 325 | + maxWidth = style.maxWidth; |
372 | 326 |
|
373 | 327 | // Put in the new values to get a computed value out
|
374 |
| - if ( rsLeft ) { |
375 |
| - rs.left = elem.currentStyle.left; |
376 |
| - } |
377 |
| - style.left = name === "fontSize" ? "1em" : ret; |
378 |
| - ret = style.pixelLeft + "px"; |
| 328 | + style.minWidth = style.maxWidth = style.width = ret; |
| 329 | + ret = computed.width; |
379 | 330 |
|
380 | 331 | // Revert the changed values
|
381 |
| - style.left = left; |
382 |
| - if ( rsLeft ) { |
383 |
| - rs.left = rsLeft; |
384 |
| - } |
| 332 | + style.width = width; |
| 333 | + style.minWidth = minWidth; |
| 334 | + style.maxWidth = maxWidth; |
385 | 335 | }
|
| 336 | + } |
| 337 | + |
| 338 | + return ret; |
| 339 | +}; |
386 | 340 |
|
387 |
| - return ret === "" ? "auto" : ret; |
388 |
| - }; |
389 |
| -} |
390 | 341 |
|
391 | 342 | function setPositiveNumber( elem, value, subtract ) {
|
392 | 343 | var matches = rnumsplit.exec( value );
|
@@ -547,50 +498,6 @@ jQuery.each([ "height", "width" ], function( i, name ) {
|
547 | 498 | };
|
548 | 499 | });
|
549 | 500 |
|
550 |
| -if ( !jQuery.support.opacity ) { |
551 |
| - jQuery.cssHooks.opacity = { |
552 |
| - get: function( elem, computed ) { |
553 |
| - // IE uses filters for opacity |
554 |
| - return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? |
555 |
| - ( 0.01 * parseFloat( RegExp.$1 ) ) + "" : |
556 |
| - computed ? "1" : ""; |
557 |
| - }, |
558 |
| - |
559 |
| - set: function( elem, value ) { |
560 |
| - var style = elem.style, |
561 |
| - currentStyle = elem.currentStyle, |
562 |
| - opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", |
563 |
| - filter = currentStyle && currentStyle.filter || style.filter || ""; |
564 |
| - |
565 |
| - // IE has trouble with opacity if it does not have layout |
566 |
| - // Force it by setting the zoom level |
567 |
| - style.zoom = 1; |
568 |
| - |
569 |
| - // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 |
570 |
| - // if value === "", then remove inline opacity #12685 |
571 |
| - if ( ( value >= 1 || value === "" ) && |
572 |
| - jQuery.trim( filter.replace( ralpha, "" ) ) === "" && |
573 |
| - style.removeAttribute ) { |
574 |
| - |
575 |
| - // Setting style.filter to null, "" & " " still leave "filter:" in the cssText |
576 |
| - // if "filter:" is present at all, clearType is disabled, we want to avoid this |
577 |
| - // style.removeAttribute is IE Only, but so apparently is this code path... |
578 |
| - style.removeAttribute( "filter" ); |
579 |
| - |
580 |
| - // if there is no filter style applied in a css rule or unset inline opacity, we are done |
581 |
| - if ( value === "" || currentStyle && !currentStyle.filter ) { |
582 |
| - return; |
583 |
| - } |
584 |
| - } |
585 |
| - |
586 |
| - // otherwise, set new filter values |
587 |
| - style.filter = ralpha.test( filter ) ? |
588 |
| - filter.replace( ralpha, opacity ) : |
589 |
| - filter + " " + opacity; |
590 |
| - } |
591 |
| - }; |
592 |
| -} |
593 |
| - |
594 | 501 | // These hooks cannot be added until DOM ready because the support test
|
595 | 502 | // for it is not run until after DOM ready
|
596 | 503 | jQuery(function() {
|
|
0 commit comments