1
|
define( [
|
2
|
"../core",
|
3
|
"./var/rnumnonpx",
|
4
|
"./var/rmargin",
|
5
|
"./var/getStyles",
|
6
|
"./support",
|
7
|
"../selector" // Get jQuery.contains
|
8
|
], function( jQuery, rnumnonpx, rmargin, getStyles, support ) {
|
9
|
|
10
|
"use strict";
|
11
|
|
12
|
function curCSS( elem, name, computed ) {
|
13
|
var width, minWidth, maxWidth, ret,
|
14
|
|
15
|
// Support: Firefox 51+
|
16
|
// Retrieving style before computed somehow
|
17
|
// fixes an issue with getting wrong values
|
18
|
// on detached elements
|
19
|
style = elem.style;
|
20
|
|
21
|
computed = computed || getStyles( elem );
|
22
|
|
23
|
// getPropertyValue is needed for:
|
24
|
// .css('filter') (IE 9 only, #12537)
|
25
|
// .css('--customProperty) (#3144)
|
26
|
if ( computed ) {
|
27
|
ret = computed.getPropertyValue( name ) || computed[ name ];
|
28
|
|
29
|
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
|
30
|
ret = jQuery.style( elem, name );
|
31
|
}
|
32
|
|
33
|
// A tribute to the "awesome hack by Dean Edwards"
|
34
|
// Android Browser returns percentage for some values,
|
35
|
// but width seems to be reliably pixels.
|
36
|
// This is against the CSSOM draft spec:
|
37
|
// https://drafts.csswg.org/cssom/#resolved-values
|
38
|
if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
|
39
|
|
40
|
// Remember the original values
|
41
|
width = style.width;
|
42
|
minWidth = style.minWidth;
|
43
|
maxWidth = style.maxWidth;
|
44
|
|
45
|
// Put in the new values to get a computed value out
|
46
|
style.minWidth = style.maxWidth = style.width = ret;
|
47
|
ret = computed.width;
|
48
|
|
49
|
// Revert the changed values
|
50
|
style.width = width;
|
51
|
style.minWidth = minWidth;
|
52
|
style.maxWidth = maxWidth;
|
53
|
}
|
54
|
}
|
55
|
|
56
|
return ret !== undefined ?
|
57
|
|
58
|
// Support: IE <=9 - 11 only
|
59
|
// IE returns zIndex value as an integer.
|
60
|
ret + "" :
|
61
|
ret;
|
62
|
}
|
63
|
|
64
|
return curCSS;
|
65
|
} );
|