aboutsummaryrefslogtreecommitdiffstats
path: root/src/css.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2018-04-23 21:00:14 +0200
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2019-04-08 19:26:08 +0200
commit00a9c2e5f4c855382435cec6b3908eb9bd5a53b7 (patch)
tree460e2907e1559eed4619bbdec9fc34f1cc6390b3 /src/css.js
parentc4f2fa2fb33d6e52f7c8fad9f687ef970f442179 (diff)
downloadjquery-00a9c2e5f4c855382435cec6b3908eb9bd5a53b7.tar.gz
jquery-00a9c2e5f4c855382435cec6b3908eb9bd5a53b7.zip
CSS: Don't automatically add "px" to properties with a few exceptions
Fixes gh-2795 Closes gh-4055 Ref gh-4009
Diffstat (limited to 'src/css.js')
-rw-r--r--src/css.js35
1 files changed, 5 insertions, 30 deletions
diff --git a/src/css.js b/src/css.js
index ac4c66e87..d6354a310 100644
--- a/src/css.js
+++ b/src/css.js
@@ -5,6 +5,7 @@ define( [
"./var/rcssNum",
"./css/var/rnumnonpx",
"./css/var/cssExpand",
+ "./css/isAutoPx",
"./css/var/getStyles",
"./css/var/swap",
"./css/curCSS",
@@ -16,7 +17,7 @@ define( [
"./core/init",
"./core/ready",
"./selector" // contains
-], function( jQuery, access, camelCase, rcssNum, rnumnonpx, cssExpand,
+], function( jQuery, access, camelCase, rcssNum, rnumnonpx, cssExpand, isAutoPx,
getStyles, swap, curCSS, adjustCSS, addGetHookIf, support, finalPropName ) {
"use strict";
@@ -198,30 +199,6 @@ jQuery.extend( {
}
},
- // Don't automatically add "px" to these possibly-unitless properties
- cssNumber: {
- "animationIterationCount": true,
- "columnCount": true,
- "fillOpacity": true,
- "flexGrow": true,
- "flexShrink": true,
- "fontWeight": true,
- "gridArea": true,
- "gridColumn": true,
- "gridColumnEnd": true,
- "gridColumnStart": true,
- "gridRow": true,
- "gridRowEnd": true,
- "gridRowStart": true,
- "lineHeight": true,
- "opacity": true,
- "order": true,
- "orphans": true,
- "widows": true,
- "zIndex": true,
- "zoom": true
- },
-
// Add in properties whose names you wish to fix before
// setting or getting the value
cssProps: {},
@@ -267,11 +244,9 @@ jQuery.extend( {
return;
}
- // If a number was passed in, add the unit (except for certain CSS properties)
- // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
- // "px" to a few hardcoded values.
- if ( type === "number" && !isCustomProp ) {
- value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
+ // If the value is a number, add `px` for certain CSS properties
+ if ( type === "number" ) {
+ value += ret && ret[ 3 ] || ( isAutoPx( origName ) ? "px" : "" );
}
// background-* props affect original clone's values