@@ -89,12 +89,12 @@ class Purgecss {
89
89
// Get selectors from content files
90
90
const { content, extractors, css } = this . options
91
91
92
- const fileFormatContents = ( ( content . filter ( o => typeof o === 'string' ) : Array < any > ) : Array <
93
- string
94
- > )
95
- const rawFormatContents = ( ( content . filter ( o => typeof o === 'object' ) : Array < any > ) : Array <
96
- RawContent
97
- > )
92
+ const fileFormatContents = ( ( content . filter (
93
+ o => typeof o === ' string'
94
+ ) : Array < any > ) : Array < string > )
95
+ const rawFormatContents = ( ( content . filter (
96
+ o => typeof o === 'object'
97
+ ) : Array < any > ) : Array < RawContent > )
98
98
99
99
const cssFileSelectors = this . extractFileSelector ( fileFormatContents , extractors )
100
100
const cssRawSelectors = this . extractRawSelector ( rawFormatContents , extractors )
@@ -244,9 +244,10 @@ class Purgecss {
244
244
extractSelectors ( content : string , extractor : Object | Function ) : Set < string > {
245
245
let selectors = new Set ( )
246
246
247
- const arraySelector = typeof extractor . extract === 'undefined'
248
- ? extractor ( content )
249
- : extractor . extract ( content )
247
+ const arraySelector =
248
+ typeof extractor . extract === 'undefined'
249
+ ? extractor ( content )
250
+ : extractor . extract ( content )
250
251
if ( arraySelector === null ) {
251
252
throw new Error ( ERROR_EXTRACTER_FAILED )
252
253
}
@@ -271,8 +272,15 @@ class Purgecss {
271
272
return this . evaluateAtRule ( node )
272
273
}
273
274
if ( node . type === 'comment' ) {
274
- if ( this . isIgnoreAnnotation ( node , 'start' ) ) this . ignore = true
275
- else if ( this . isIgnoreAnnotation ( node , 'end' ) ) this . ignore = false
275
+ if ( this . isIgnoreAnnotation ( node , 'start' ) ) {
276
+ this . ignore = true
277
+ // remove ignore annotation
278
+ node . remove ( )
279
+ } else if ( this . isIgnoreAnnotation ( node , 'end' ) ) {
280
+ this . ignore = false
281
+ // remove ignore annotation
282
+ node . remove ( )
283
+ }
276
284
}
277
285
} )
278
286
}
@@ -284,7 +292,15 @@ class Purgecss {
284
292
*/
285
293
evaluateRule ( node : Object , selectors : Set < string > ) {
286
294
const annotation = node . prev ( )
287
- if ( this . isIgnoreAnnotation ( annotation , 'next' ) || this . ignore === true ) return
295
+ if ( this . ignore ) return
296
+ if (
297
+ typeof annotation !== 'undefined' &&
298
+ annotation . type === 'comment' &&
299
+ this . isIgnoreAnnotation ( annotation , 'next' )
300
+ ) {
301
+ annotation . remove ( )
302
+ return
303
+ }
288
304
289
305
let keepSelector = true
290
306
node . selector = selectorParser ( selectorsParsed => {
0 commit comments