MCPcopy Create free account
hub / github.com/jquery/jquery / curCSS

Function curCSS

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

Source from the content-addressed store, hash-verified

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

Callers 2

getWidthOrHeightFunction · 0.70
jQueryFactoryWrapperFunction · 0.70

Calls 2

getStylesFunction · 0.70
isAttachedFunction · 0.70

Tested by

no test coverage detected