-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #986 - CSS 4 colors in level 2 optimizations.
- Loading branch information
1 parent
8f52600
commit ec259be
Showing
3 changed files
with
19 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,19 @@ var decimalRegex = /[0-9]/; | |
var functionAnyRegex = new RegExp('^' + functionAnyRegexStr + '$', 'i'); | ||
var hslColorRegex = /^hsl\(\s{0,31}[\-\.]?\d+\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+%\s{0,31}\)|hsla\(\s{0,31}[\-\.]?\d+\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+%\s{0,31},\s{0,31}\.?\d+\s{0,31}\)$/; | ||
var identifierRegex = /^(\-[a-z0-9_][a-z0-9\-_]*|[a-z][a-z0-9\-_]*)$/i; | ||
var longHexColorRegex = /^#[0-9a-f]{6}$/i; | ||
var namedEntityRegex = /^[a-z]+$/i; | ||
var prefixRegex = /^-([a-z0-9]|-)*$/i; | ||
var rgbColorRegex = /^rgb\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31}\)|rgba\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\.\d]+\s{0,31}\)$/; | ||
var shortHexColorRegex = /^#[0-9a-f]{3}$/i; | ||
var timingFunctionRegex = /^(cubic\-bezier|steps)\([^\)]+\)$/; | ||
var validTimeUnits = ['ms', 's']; | ||
var urlRegex = /^url\([\s\S]+\)$/i; | ||
var variableRegex = new RegExp('^' + variableRegexStr + '$', 'i'); | ||
|
||
var eightValueColorRegex = /^#[0-9a-f]{8}$/i; | ||
var fourValueColorRegex = /^#[0-9a-f]{4}$/i; | ||
var sixValueColorRegex = /^#[0-9a-f]{6}$/i; | ||
var threeValueColorRegex = /^#[0-9a-f]{3}$/i; | ||
|
||
var DECIMAL_DOT = '.'; | ||
var MINUS_SIGN = '-'; | ||
var PLUS_SIGN = '+'; | ||
|
@@ -365,7 +368,7 @@ function isFunction(value) { | |
} | ||
|
||
function isHexColor(value) { | ||
return shortHexColorRegex.test(value) || longHexColorRegex.test(value); | ||
return threeValueColorRegex.test(value) || fourValueColorRegex.test(value) || sixValueColorRegex.test(value) || eightValueColorRegex.test(value); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jakubpawlowicz
Author
Collaborator
|
||
} | ||
|
||
function isHslColor(value) { | ||
|
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 would be more efficient:
return /^#(?:(?:[0-9a-fA-F]{2}){2,4}|(?:[0-9a-fA-F]){3})$/.test(value)