blob: 98a594a7705d93ebb30943b257fc0e97929ac27d [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001define( [
2 "../core",
3 "../core/isAttached",
4 "./var/rboxStyle",
5 "./var/rnumnonpx",
6 "./var/getStyles",
7 "./support"
8], function( jQuery, isAttached, rboxStyle, rnumnonpx, getStyles, support ) {
9
10"use strict";
11
12function 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 === "" && !isAttached( 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.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.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
64return curCSS;
65} );