Created
September 23, 2011 00:32
-
-
Save sdesai/1236459 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Shorten colors from #AABBCC to #ABC. Note that we want to make sure | |
// the color is not preceded by either ", " or =. Indeed, the property | |
// filter: chroma(color="#FFFFFF"); | |
// would become | |
// filter: chroma(color="#FFF"); | |
// which makes the filter break in IE. | |
BEFORE: | |
var pattern = /([^"'=\s])(\s*)#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])/gi | |
BUG: It also compresses ids. e.g #AABBCC { ... } .foo, #AABBCC { ... } | |
AFTER (make sure we only pick up matches inside a { ... }: | |
var pattern = /([^"'=\s])(\s*)#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([^\{]*?\})/gi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment