-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSS: Don't automatically add "px" to properties with a few exceptions
- Loading branch information
Showing
5 changed files
with
129 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
define( function() { | ||
|
||
"use strict"; | ||
|
||
var ralphaStart = /^[a-z]/, | ||
|
||
// The regex visualized: | ||
// | ||
// /----------\ | ||
// | | /-------\ | ||
// | / Top \ | | | | ||
// /--- Border ---+-| Right |-+---+- Width -+---\ | ||
// | | Bottom | | | ||
// | \ Left / | | ||
// | | | ||
// | /----------\ | | ||
// | /-------------\ | | |- END | ||
// | | | | / Top \ | | | ||
// | | / Margin \ | | | Right | | | | ||
// |---------+-| |-+---+-| Bottom |-+----| | ||
// | \ Padding / \ Left / | | ||
// BEGIN -| | | ||
// | /---------\ | | ||
// | | | | | ||
// | | / Min \ | / Width \ | | ||
// \--------------+-| |-+---| |---/ | ||
// \ Max / \ Height / | ||
rautoPx = /^(?:Border(?:Top|Right|Bottom|Left)?(?:Width|)|(?:Margin|Padding)?(?:Top|Right|Bottom|Left)?|(?:Min|Max)?(?:Width|Height))$/; | ||
|
||
function isAutoPx( prop ) { | ||
|
||
// The first test is used to ensure that: | ||
// 1. The prop starts with a lowercase letter (as we uppercase it for the second regex). | ||
// 2. The prop is not empty. | ||
return ralphaStart.test( prop ) && | ||
rautoPx.test( prop[ 0 ].toUpperCase() + prop.slice( 1 ) ); | ||
}; | ||
|
||
return isAutoPx; | ||
|
||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters