MCPcopy Index your code
hub / github.com/jquery/jquery / curCSS

Function curCSS

dist-module/jquery.module.js:5786–5841  ·  view source on GitHub ↗
( elem, name, computed )

Source from the content-addressed store, hash-verified

5784}
5785
5786function curCSS( elem, name, computed ) {
5787 var ret,
5788 isCustomProp = rcustomProp.test( name );
5789
5790 computed = computed || getStyles( elem );
5791
5792 // getPropertyValue is needed for `.css('--customProperty')` (gh-3144)
5793 if ( computed ) {
5794
5795 // A fallback to direct property access is needed as `computed`, being
5796 // the output of `getComputedStyle`, contains camelCased keys and
5797 // `getPropertyValue` requires kebab-case ones.
5798 //
5799 // Support: IE <=9 - 11+
5800 // IE only supports `"float"` in `getPropertyValue`; in computed styles
5801 // it's only available as `"cssFloat"`. We no longer modify properties
5802 // sent to `.css()` apart from camelCasing, so we need to check both.
5803 // Normally, this would create difference in behavior: if
5804 // `getPropertyValue` returns an empty string, the value returned
5805 // by `.css()` would be `undefined`. This is usually the case for
5806 // disconnected elements. However, in IE even disconnected elements
5807 // with no styles return `"none"` for `getPropertyValue( "float" )`
5808 ret = computed.getPropertyValue( name ) || computed[ name ];
5809
5810 if ( isCustomProp && ret ) {
5811
5812 // Support: Firefox 105 - 135+
5813 // Spec requires trimming whitespace for custom properties (gh-4926).
5814 // Firefox only trims leading whitespace.
5815 //
5816 // Fall back to `undefined` if empty string returned.
5817 // This collapses a missing definition with property defined
5818 // and set to an empty string but there's no standard API
5819 // allowing us to differentiate them without a performance penalty
5820 // and returning `undefined` aligns with older jQuery.
5821 //
5822 // rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED
5823 // as whitespace while CSS does not, but this is not a problem
5824 // because CSS preprocessing replaces them with U+000A LINE FEED
5825 // (which *is* CSS whitespace)
5826 // https://www.w3.org/TR/css-syntax-3/#input-preprocessing
5827 ret = ret.replace( rtrimCSS, "$1" ) || undefined;
5828 }
5829
5830 if ( ret === "" && !isAttached( elem ) ) {
5831 ret = jQuery.style( elem, name );
5832 }
5833 }
5834
5835 return ret !== undefined ?
5836
5837 // Support: IE <=9 - 11+
5838 // IE returns zIndex value as an integer.
5839 ret + "" :
5840 ret;
5841}
5842
5843var cssPrefixes = [ "Webkit", "Moz", "ms" ],

Callers 2

getWidthOrHeightFunction · 0.70
jQueryFactoryFunction · 0.70

Calls 2

getStylesFunction · 0.70
isAttachedFunction · 0.70

Tested by

no test coverage detected