diff options
author | Michał Gołębiowski <m.goleb@gmail.com> | 2015-05-11 23:23:09 +0200 |
---|---|---|
committer | Michał Gołębiowski <m.goleb@gmail.com> | 2015-06-01 14:05:05 +0200 |
commit | d471842b3e3af83c9a1be06b5d16f75bfa96af8c (patch) | |
tree | a0bbfce6e33b05a48b73a442d5c82d5737d9a1ad /src/css.js | |
parent | 6df669f0fb87cd9975a18bf6bbe3c3548afa4fee (diff) | |
download | jquery-d471842b3e3af83c9a1be06b5d16f75bfa96af8c.tar.gz jquery-d471842b3e3af83c9a1be06b5d16f75bfa96af8c.zip |
CSS: Don't cache unrecognized CSS property names
This prevents jQuery from caching a prefixed property name if provided
directly by the user, e.g. the following code:
elem.css( "msTransform", "translate(5px, 2px)" );
should not prevent one from from later setting the transition directly:
elem.css( "transform", "translate(5px, 2px)" );
on a browser not understanding the unprefixed version which is the case
for Safari 8 & transform.
Fixes gh-2015
Closes gh-2298
Diffstat (limited to 'src/css.js')
-rw-r--r-- | src/css.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/css.js b/src/css.js index 7b011668e..566f5a0fd 100644 --- a/src/css.js +++ b/src/css.js @@ -3,6 +3,7 @@ define([ "./var/pnum", "./core/access", "./css/var/rmargin", + "./var/document", "./var/rcssNum", "./css/var/rnumnonpx", "./css/var/cssExpand", @@ -18,8 +19,8 @@ define([ "./core/init", "./core/ready", "./selector" // contains -], function( jQuery, pnum, access, rmargin, rcssNum, rnumnonpx, cssExpand, isHidden, - getStyles, swap, curCSS, adjustCSS, addGetHookIf, support, showHide ) { +], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand, + isHidden, getStyles, swap, curCSS, adjustCSS, addGetHookIf, support, showHide ) { var // Swappable if display is none or starts with table @@ -34,29 +35,27 @@ var fontWeight: "400" }, - cssPrefixes = [ "Webkit", "Moz", "ms" ]; + cssPrefixes = [ "Webkit", "Moz", "ms" ], + emptyStyle = document.createElement( "div" ).style; // Return a css property mapped to a potentially vendor prefixed property -function vendorPropName( style, name ) { +function vendorPropName( name ) { // Shortcut for names that are not vendor prefixed - if ( name in style ) { + if ( name in emptyStyle ) { return name; } // Check for vendor prefixed names var capName = name[0].toUpperCase() + name.slice(1), - origName = name, i = cssPrefixes.length; while ( i-- ) { name = cssPrefixes[ i ] + capName; - if ( name in style ) { + if ( name in emptyStyle ) { return name; } } - - return origName; } function setPositiveNumber( elem, value, subtract ) { @@ -203,7 +202,7 @@ jQuery.extend({ style = elem.style; name = jQuery.cssProps[ origName ] || - ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); + ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); // Gets hook for the prefixed version, then unprefixed version hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; @@ -261,7 +260,7 @@ jQuery.extend({ // Make sure that we're working with the right name name = jQuery.cssProps[ origName ] || - ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); + ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); // Try prefixed name followed by the unprefixed name hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |