Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ffloriel committed Apr 20, 2019
1 parent 8815852 commit fbac428
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

# v1.3.0 - 2019-04-20

* Merged https://github.com/FullHuman/purgecss/pull/183, adding `defaultExtractor` option
* remove ignore comment once purged, issue https://github.com/FullHuman/purgecss/issues/121

# v1.2.0 - 2019-04-05

* fix issue https://github.com/FullHuman/purgecss/issues/148, so the default extract is used for any file type that is not specified
Expand Down
2 changes: 1 addition & 1 deletion __tests__/purgecss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ describe('special characters, overriding the default Extractor with a function',
purgecssResult = new Purgecss({
content: [`${root}special_characters/special_characters.js`],
css: [`${root}special_characters/special_characters.css`],
defaultExtractor: content => content.match(/[A-z0-9-:/]+/g),
defaultExtractor: content => content.match(/[A-z0-9-:/]+/g)
}).purge()[0].css
})

Expand Down
3 changes: 0 additions & 3 deletions __tests__/purgecssDefault.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ describe('purge methods with files and default extractor', () => {
})

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

it('removes the comments', () => {
console.log(purgecssResult)
expect(purgecssResult.includes('/* purgecss start ignore */')).toBe(false)
expect(purgecssResult.includes('/* purgecss end ignore */')).toBe(false)
})
Expand Down Expand Up @@ -399,7 +397,6 @@ describe('purge methods with files and default extractor', () => {
],
keyframes: false
}).purge()[0].css
// console.log(purgecssResult)
})
it('keeps `99.9%`', () => {
expect(purgecssResult.includes('99.9%')).toBe(true)
Expand Down
18 changes: 16 additions & 2 deletions lib/purgecss.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,15 @@ function () {
}

if (node.type === 'comment') {
if (_this.isIgnoreAnnotation(node, 'start')) _this.ignore = true;else if (_this.isIgnoreAnnotation(node, 'end')) _this.ignore = false;
if (_this.isIgnoreAnnotation(node, 'start')) {
_this.ignore = true; // remove ignore annotation

node.remove();
} else if (_this.isIgnoreAnnotation(node, 'end')) {
_this.ignore = false; // remove ignore annotation

node.remove();
}
}
});
}
Expand All @@ -768,7 +776,13 @@ function () {
var _this2 = this;

var annotation = node.prev();
if (this.isIgnoreAnnotation(annotation, 'next') || this.ignore === true) return;
if (this.ignore) return;

if (typeof annotation !== 'undefined' && annotation.type === 'comment' && this.isIgnoreAnnotation(annotation, 'next')) {
annotation.remove();
return;
}

var keepSelector = true;
node.selector = selectorParser(function (selectorsParsed) {
selectorsParsed.walk(function (selector) {
Expand Down
18 changes: 16 additions & 2 deletions lib/purgecss.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,15 @@ function () {
}

if (node.type === 'comment') {
if (_this.isIgnoreAnnotation(node, 'start')) _this.ignore = true;else if (_this.isIgnoreAnnotation(node, 'end')) _this.ignore = false;
if (_this.isIgnoreAnnotation(node, 'start')) {
_this.ignore = true; // remove ignore annotation

node.remove();
} else if (_this.isIgnoreAnnotation(node, 'end')) {
_this.ignore = false; // remove ignore annotation

node.remove();
}
}
});
}
Expand All @@ -772,7 +780,13 @@ function () {
var _this2 = this;

var annotation = node.prev();
if (this.isIgnoreAnnotation(annotation, 'next') || this.ignore === true) return;
if (this.ignore) return;

if (typeof annotation !== 'undefined' && annotation.type === 'comment' && this.isIgnoreAnnotation(annotation, 'next')) {
annotation.remove();
return;
}

var keepSelector = true;
node.selector = selectorParser(function (selectorsParsed) {
selectorsParsed.walk(function (selector) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "purgecss",
"version": "1.2.1",
"version": "1.3.0",
"description": "Remove unused css selectors.",
"main": "./lib/purgecss.js",
"module": "./lib/purgecss.es.js",
Expand Down

0 comments on commit fbac428

Please sign in to comment.