var animationNameRegex = /^(\-moz\-|\-o\-|\-webkit\-)?animation-name$/;
var animationRegex = /^(\-moz\-|\-o\-|\-webkit\-)?animation$/;
var keyframeRegex = /^@(\-moz\-|\-o\-|\-webkit\-)?keyframes /;
+var importantRegex = /\s*!important$/;
var optionalMatchingQuotesRegex = /^(['"]?)(.*)\1$/;
-function removeQuotes(value) {
- return value.replace(optionalMatchingQuotesRegex, '$2');
+function normalize(value) {
+ return value
+ .replace(optionalMatchingQuotesRegex, '$2')
+ .replace(importantRegex, '');
}
function removeUnusedAtRules(tokens, context) {
property = token[2][i];
if (property[1][1] == 'font-family') {
- match = removeQuotes(property[2][1].toLowerCase());
+ match = normalize(property[2][1].toLowerCase());
atRules[match] = atRules[match] || [];
atRules[match].push(token);
break;
component = wrappedProperty.components[6];
for (j = 0, m = component.value.length; j < m; j++) {
- normalizedMatch = removeQuotes(component.value[j][1].toLowerCase());
+ normalizedMatch = normalize(component.value[j][1].toLowerCase());
if (normalizedMatch in atRules) {
delete atRules[normalizedMatch];
if (property[1][1] == 'font-family') {
for (j = 2, m = property.length; j < m; j++) {
- normalizedMatch = removeQuotes(property[j][1].toLowerCase());
+ normalizedMatch = normalize(property[j][1].toLowerCase());
if (normalizedMatch in atRules) {
delete atRules[normalizedMatch];
'@font-face{font-family:test}.block{font:16px test!important}',
'@font-face{font-family:test}.block{font:16px test!important}'
],
+ 'one used as font-family with !important': [
+ '@font-face{font-family:test}.block{font-family:test!important}',
+ '@font-face{font-family:test}.block{font-family:test!important}'
+ ],
'one used declaration in another @font-face': [
'@font-face{font-family:test;font-weight:normal}@font-face{font-family:test;font-weight:bold}',
''