From 2b5f5d5e90b37f4a735738a6d0b6f22affbea340 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Sat, 24 Feb 2018 17:17:24 -0500 Subject: CSS: Avoid filling jQuery.cssProps Fixes gh-3986 Closes gh-4005 Avoids filling jQuery.cssProps by introducing a second internal prop cache. This allows jQuery Migrate to detect external usage. --- src/css/finalPropName.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/css/finalPropName.js (limited to 'src/css/finalPropName.js') diff --git a/src/css/finalPropName.js b/src/css/finalPropName.js new file mode 100644 index 000000000..e5c77b0b2 --- /dev/null +++ b/src/css/finalPropName.js @@ -0,0 +1,39 @@ +define( [ "../var/document" ], function( document ) { + +"use strict"; + +var cssPrefixes = [ "Webkit", "Moz", "ms" ], + emptyStyle = document.createElement( "div" ).style, + vendorProps = {}; + +// Return a vendor-prefixed property or undefined +function vendorPropName( name ) { + + // Check for vendor prefixed names + var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), + i = cssPrefixes.length; + + while ( i-- ) { + name = cssPrefixes[ i ] + capName; + if ( name in emptyStyle ) { + return name; + } + } +} + +// Return a potentially-mapped jQuery.cssProps or vendor prefixed property +function finalPropName( name ) { + var final = jQuery.cssProps[ name ] || vendorProps[ name ]; + + if ( final ) { + return final; + } + if ( name in emptyStyle ) { + return name; + } + return vendorProps[ name ] = vendorPropName( name ) || name; +} + +return finalPropName; + +} ); -- cgit v1.2.3