tuiHoneyPot

front and back end of my TUI honeypot
Log | Files | Refs | README

curCSS.js (3305B)


      1 define( [
      2 	"../core",
      3 	"../core/isAttached",
      4 	"./var/rboxStyle",
      5 	"./var/rnumnonpx",
      6 	"./var/getStyles",
      7 	"./var/rcustomProp",
      8 	"../var/rtrimCSS",
      9 	"./support"
     10 ], function( jQuery, isAttached, rboxStyle, rnumnonpx, getStyles,
     11 	rcustomProp, rtrimCSS, support ) {
     12 
     13 "use strict";
     14 
     15 function curCSS( elem, name, computed ) {
     16 	var width, minWidth, maxWidth, ret,
     17 		isCustomProp = rcustomProp.test( name ),
     18 
     19 		// Support: Firefox 51+
     20 		// Retrieving style before computed somehow
     21 		// fixes an issue with getting wrong values
     22 		// on detached elements
     23 		style = elem.style;
     24 
     25 	computed = computed || getStyles( elem );
     26 
     27 	// getPropertyValue is needed for:
     28 	//   .css('filter') (IE 9 only, trac-12537)
     29 	//   .css('--customProperty) (gh-3144)
     30 	if ( computed ) {
     31 
     32 		// Support: IE <=9 - 11+
     33 		// IE only supports `"float"` in `getPropertyValue`; in computed styles
     34 		// it's only available as `"cssFloat"`. We no longer modify properties
     35 		// sent to `.css()` apart from camelCasing, so we need to check both.
     36 		// Normally, this would create difference in behavior: if
     37 		// `getPropertyValue` returns an empty string, the value returned
     38 		// by `.css()` would be `undefined`. This is usually the case for
     39 		// disconnected elements. However, in IE even disconnected elements
     40 		// with no styles return `"none"` for `getPropertyValue( "float" )`
     41 		ret = computed.getPropertyValue( name ) || computed[ name ];
     42 
     43 		if ( isCustomProp && ret ) {
     44 
     45 			// Support: Firefox 105+, Chrome <=105+
     46 			// Spec requires trimming whitespace for custom properties (gh-4926).
     47 			// Firefox only trims leading whitespace. Chrome just collapses
     48 			// both leading & trailing whitespace to a single space.
     49 			//
     50 			// Fall back to `undefined` if empty string returned.
     51 			// This collapses a missing definition with property defined
     52 			// and set to an empty string but there's no standard API
     53 			// allowing us to differentiate them without a performance penalty
     54 			// and returning `undefined` aligns with older jQuery.
     55 			//
     56 			// rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED
     57 			// as whitespace while CSS does not, but this is not a problem
     58 			// because CSS preprocessing replaces them with U+000A LINE FEED
     59 			// (which *is* CSS whitespace)
     60 			// https://www.w3.org/TR/css-syntax-3/#input-preprocessing
     61 			ret = ret.replace( rtrimCSS, "$1" ) || undefined;
     62 		}
     63 
     64 		if ( ret === "" && !isAttached( elem ) ) {
     65 			ret = jQuery.style( elem, name );
     66 		}
     67 
     68 		// A tribute to the "awesome hack by Dean Edwards"
     69 		// Android Browser returns percentage for some values,
     70 		// but width seems to be reliably pixels.
     71 		// This is against the CSSOM draft spec:
     72 		// https://drafts.csswg.org/cssom/#resolved-values
     73 		if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
     74 
     75 			// Remember the original values
     76 			width = style.width;
     77 			minWidth = style.minWidth;
     78 			maxWidth = style.maxWidth;
     79 
     80 			// Put in the new values to get a computed value out
     81 			style.minWidth = style.maxWidth = style.width = ret;
     82 			ret = computed.width;
     83 
     84 			// Revert the changed values
     85 			style.width = width;
     86 			style.minWidth = minWidth;
     87 			style.maxWidth = maxWidth;
     88 		}
     89 	}
     90 
     91 	return ret !== undefined ?
     92 
     93 		// Support: IE <=9 - 11 only
     94 		// IE returns zIndex value as an integer.
     95 		ret + "" :
     96 		ret;
     97 }
     98 
     99 return curCSS;
    100 } );