@@ -8,10 +8,13 @@ var Token = require('../../tokenizer/token');
8
8
var animationNameRegex = / ^ ( \- m o z \- | \- o \- | \- w e b k i t \- ) ? a n i m a t i o n - n a m e $ / ;
9
9
var animationRegex = / ^ ( \- m o z \- | \- o \- | \- w e b k i t \- ) ? a n i m a t i o n $ / ;
10
10
var keyframeRegex = / ^ @ ( \- m o z \- | \- o \- | \- w e b k i t \- ) ? k e y f r a m e s / ;
11
+ var importantRegex = / \s * ! i m p o r t a n t $ / ;
11
12
var optionalMatchingQuotesRegex = / ^ ( [ ' " ] ? ) ( .* ) \1$ / ;
12
13
13
- function removeQuotes ( value ) {
14
- return value . replace ( optionalMatchingQuotesRegex , '$2' ) ;
14
+ function normalize ( value ) {
15
+ return value
16
+ . replace ( optionalMatchingQuotesRegex , '$2' )
17
+ . replace ( importantRegex , '' ) ;
15
18
}
16
19
17
20
function removeUnusedAtRules ( tokens , context ) {
@@ -112,7 +115,7 @@ function matchFontFace(token, atRules) {
112
115
property = token [ 2 ] [ i ] ;
113
116
114
117
if ( property [ 1 ] [ 1 ] == 'font-family' ) {
115
- match = removeQuotes ( property [ 2 ] [ 1 ] . toLowerCase ( ) ) ;
118
+ match = normalize ( property [ 2 ] [ 1 ] . toLowerCase ( ) ) ;
116
119
atRules [ match ] = atRules [ match ] || [ ] ;
117
120
atRules [ match ] . push ( token ) ;
118
121
break ;
@@ -139,7 +142,7 @@ function markFontFacesAsUsed(atRules) {
139
142
component = wrappedProperty . components [ 6 ] ;
140
143
141
144
for ( j = 0 , m = component . value . length ; j < m ; j ++ ) {
142
- normalizedMatch = removeQuotes ( component . value [ j ] [ 1 ] . toLowerCase ( ) ) ;
145
+ normalizedMatch = normalize ( component . value [ j ] [ 1 ] . toLowerCase ( ) ) ;
143
146
144
147
if ( normalizedMatch in atRules ) {
145
148
delete atRules [ normalizedMatch ] ;
@@ -151,7 +154,7 @@ function markFontFacesAsUsed(atRules) {
151
154
152
155
if ( property [ 1 ] [ 1 ] == 'font-family' ) {
153
156
for ( j = 2 , m = property . length ; j < m ; j ++ ) {
154
- normalizedMatch = removeQuotes ( property [ j ] [ 1 ] . toLowerCase ( ) ) ;
157
+ normalizedMatch = normalize ( property [ j ] [ 1 ] . toLowerCase ( ) ) ;
155
158
156
159
if ( normalizedMatch in atRules ) {
157
160
delete atRules [ normalizedMatch ] ;
0 commit comments