6 "../selector" // contains
7 ], function( exports, jQuery, rnumnonpx, rmargin ) {
10 rposition = /^(top|right|bottom|left)$/;
12 if ( window.getComputedStyle ) {
13 getStyles = function( elem ) {
14 // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
15 // IE throws on elements created in popups
16 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
17 if ( elem.ownerDocument.defaultView.opener ) {
18 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
21 return window.getComputedStyle( elem, null );
24 curCSS = function( elem, name, computed ) {
25 var width, minWidth, maxWidth, ret,
28 computed = computed || getStyles( elem );
30 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
31 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
35 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
36 ret = jQuery.style( elem, name );
39 // A tribute to the "awesome hack by Dean Edwards"
40 // Chrome < 17 and Safari 5.0 uses "computed value"
41 // instead of "used value" for margin-right
42 // Safari 5.1.7 (at least) returns percentage for a larger set of values,
43 // but width seems to be reliably pixels
44 // this is against the CSSOM draft spec:
45 // http://dev.w3.org/csswg/cssom/#resolved-values
46 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
48 // Remember the original values
50 minWidth = style.minWidth;
51 maxWidth = style.maxWidth;
53 // Put in the new values to get a computed value out
54 style.minWidth = style.maxWidth = style.width = ret;
57 // Revert the changed values
59 style.minWidth = minWidth;
60 style.maxWidth = maxWidth;
65 // IE returns zIndex value as an integer.
66 return ret === undefined ?
70 } else if ( document.documentElement.currentStyle ) {
71 getStyles = function( elem ) {
72 return elem.currentStyle;
75 curCSS = function( elem, name, computed ) {
76 var left, rs, rsLeft, ret,
79 computed = computed || getStyles( elem );
80 ret = computed ? computed[ name ] : undefined;
82 // Avoid setting ret to empty string here
83 // so we don't default to auto
84 if ( ret == null && style && style[ name ] ) {
88 // From the awesome hack by Dean Edwards
89 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
91 // If we're not dealing with a regular pixel number
92 // but a number that has a weird ending, we need to convert it to pixels
93 // but not position css attributes, as those are
94 // proportional to the parent element instead
95 // and we can't measure the parent instead because it
96 // might trigger a "stacking dolls" problem
97 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
99 // Remember the original values
101 rs = elem.runtimeStyle;
102 rsLeft = rs && rs.left;
104 // Put in the new values to get a computed value out
106 rs.left = elem.currentStyle.left;
108 style.left = name === "fontSize" ? "1em" : ret;
109 ret = style.pixelLeft + "px";
111 // Revert the changed values
119 // IE returns zIndex value as an integer.
120 return ret === undefined ?
126 exports.getStyles = getStyles;
127 exports.curCSS = curCSS;