aboutsummaryrefslogtreecommitdiffstats
path: root/src/css/finalPropName.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2018-02-24 17:17:24 -0500
committerDave Methvin <dave.methvin@gmail.com>2018-03-19 20:33:35 -0400
commit2b5f5d5e90b37f4a735738a6d0b6f22affbea340 (patch)
treec6994421cc716eacba0d687b27a653a70d558558 /src/css/finalPropName.js
parentb95e0da68e1e3fce59a6a54c209b893f611b0b9c (diff)
downloadjquery-2b5f5d5e90b37f4a735738a6d0b6f22affbea340.tar.gz
jquery-2b5f5d5e90b37f4a735738a6d0b6f22affbea340.zip
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.
Diffstat (limited to 'src/css/finalPropName.js')
-rw-r--r--src/css/finalPropName.js39
1 files changed, 39 insertions, 0 deletions
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;
+
+} );