Skip to content

Commit fbac428

Browse files
committed
v1.3.0
1 parent 8815852 commit fbac428

File tree

6 files changed

+39
-9
lines changed

6 files changed

+39
-9
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
# v1.3.0 - 2019-04-20
4+
5+
* Merged https://github.com/FullHuman/purgecss/pull/183, adding `defaultExtractor` option
6+
* remove ignore comment once purged, issue https://github.com/FullHuman/purgecss/issues/121
7+
38
# v1.2.0 - 2019-04-05
49

510
* fix issue https://github.com/FullHuman/purgecss/issues/148, so the default extract is used for any file type that is not specified

__tests__/purgecss.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ describe('special characters, overriding the default Extractor with a function',
366366
purgecssResult = new Purgecss({
367367
content: [`${root}special_characters/special_characters.js`],
368368
css: [`${root}special_characters/special_characters.css`],
369-
defaultExtractor: content => content.match(/[A-z0-9-:/]+/g),
369+
defaultExtractor: content => content.match(/[A-z0-9-:/]+/g)
370370
}).purge()[0].css
371371
})
372372

__tests__/purgecssDefault.test.js

-3
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ describe('purge methods with files and default extractor', () => {
217217
})
218218

219219
it('removes the comment', () => {
220-
console.log(purgecssResult)
221220
expect(purgecssResult.includes('/* purgecss ignore */')).toBe(false)
222221
})
223222
})
@@ -242,7 +241,6 @@ describe('purge methods with files and default extractor', () => {
242241
})
243242

244243
it('removes the comments', () => {
245-
console.log(purgecssResult)
246244
expect(purgecssResult.includes('/* purgecss start ignore */')).toBe(false)
247245
expect(purgecssResult.includes('/* purgecss end ignore */')).toBe(false)
248246
})
@@ -399,7 +397,6 @@ describe('purge methods with files and default extractor', () => {
399397
],
400398
keyframes: false
401399
}).purge()[0].css
402-
// console.log(purgecssResult)
403400
})
404401
it('keeps `99.9%`', () => {
405402
expect(purgecssResult.includes('99.9%')).toBe(true)

lib/purgecss.es.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,15 @@ function () {
752752
}
753753

754754
if (node.type === 'comment') {
755-
if (_this.isIgnoreAnnotation(node, 'start')) _this.ignore = true;else if (_this.isIgnoreAnnotation(node, 'end')) _this.ignore = false;
755+
if (_this.isIgnoreAnnotation(node, 'start')) {
756+
_this.ignore = true; // remove ignore annotation
757+
758+
node.remove();
759+
} else if (_this.isIgnoreAnnotation(node, 'end')) {
760+
_this.ignore = false; // remove ignore annotation
761+
762+
node.remove();
763+
}
756764
}
757765
});
758766
}
@@ -768,7 +776,13 @@ function () {
768776
var _this2 = this;
769777

770778
var annotation = node.prev();
771-
if (this.isIgnoreAnnotation(annotation, 'next') || this.ignore === true) return;
779+
if (this.ignore) return;
780+
781+
if (typeof annotation !== 'undefined' && annotation.type === 'comment' && this.isIgnoreAnnotation(annotation, 'next')) {
782+
annotation.remove();
783+
return;
784+
}
785+
772786
var keepSelector = true;
773787
node.selector = selectorParser(function (selectorsParsed) {
774788
selectorsParsed.walk(function (selector) {

lib/purgecss.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,15 @@ function () {
756756
}
757757

758758
if (node.type === 'comment') {
759-
if (_this.isIgnoreAnnotation(node, 'start')) _this.ignore = true;else if (_this.isIgnoreAnnotation(node, 'end')) _this.ignore = false;
759+
if (_this.isIgnoreAnnotation(node, 'start')) {
760+
_this.ignore = true; // remove ignore annotation
761+
762+
node.remove();
763+
} else if (_this.isIgnoreAnnotation(node, 'end')) {
764+
_this.ignore = false; // remove ignore annotation
765+
766+
node.remove();
767+
}
760768
}
761769
});
762770
}
@@ -772,7 +780,13 @@ function () {
772780
var _this2 = this;
773781

774782
var annotation = node.prev();
775-
if (this.isIgnoreAnnotation(annotation, 'next') || this.ignore === true) return;
783+
if (this.ignore) return;
784+
785+
if (typeof annotation !== 'undefined' && annotation.type === 'comment' && this.isIgnoreAnnotation(annotation, 'next')) {
786+
annotation.remove();
787+
return;
788+
}
789+
776790
var keepSelector = true;
777791
node.selector = selectorParser(function (selectorsParsed) {
778792
selectorsParsed.walk(function (selector) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "purgecss",
3-
"version": "1.2.1",
3+
"version": "1.3.0",
44
"description": "Remove unused css selectors.",
55
"main": "./lib/purgecss.js",
66
"module": "./lib/purgecss.es.js",

0 commit comments

Comments
 (0)