purgecss 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -355,6 +355,8 @@ var CSS_WHITELIST = ['*', '::-webkit-scrollbar', '::selection', ':root', '::befo
355
355
 
356
356
  var SELECTOR_STANDARD_TYPES = ['class', 'id', 'universal', 'pseudo'];
357
357
 
358
+ var IS_NTH = /^:nth-/;
359
+
358
360
  var Purgecss =
359
361
  /*#__PURE__*/
360
362
  function () {
@@ -825,8 +827,8 @@ function () {
825
827
 
826
828
  if (SELECTOR_STANDARD_TYPES.includes(type) && typeof value !== 'undefined') {
827
829
  selectorsInRule.push(value);
828
- } else if (type === 'tag' && !/[+]|n|-|(even)|(odd)|^from$|^to$|^\d/.test(value)) {
829
- // test if we do not have a pseudo class parameter (e.g. 2n in :nth-child(2n))
830
+ } else if (type === 'tag' && !( // skip everything inside :nth-* pseudo selectors
831
+ selector.parent && selector.parent.type === 'pseudo' && IS_NTH.test(selector.parent.value))) {
830
832
  selectorsInRule.push(value);
831
833
  }
832
834
  }
package/lib/purgecss.js CHANGED
@@ -359,6 +359,8 @@ var CSS_WHITELIST = ['*', '::-webkit-scrollbar', '::selection', ':root', '::befo
359
359
 
360
360
  var SELECTOR_STANDARD_TYPES = ['class', 'id', 'universal', 'pseudo'];
361
361
 
362
+ var IS_NTH = /^:nth-/;
363
+
362
364
  var Purgecss =
363
365
  /*#__PURE__*/
364
366
  function () {
@@ -829,8 +831,8 @@ function () {
829
831
 
830
832
  if (SELECTOR_STANDARD_TYPES.includes(type) && typeof value !== 'undefined') {
831
833
  selectorsInRule.push(value);
832
- } else if (type === 'tag' && !/[+]|n|-|(even)|(odd)|^from$|^to$|^\d/.test(value)) {
833
- // test if we do not have a pseudo class parameter (e.g. 2n in :nth-child(2n))
834
+ } else if (type === 'tag' && !( // skip everything inside :nth-* pseudo selectors
835
+ selector.parent && selector.parent.type === 'pseudo' && IS_NTH.test(selector.parent.value))) {
834
836
  selectorsInRule.push(value);
835
837
  }
836
838
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "purgecss",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Remove unused css selectors.",
5
5
  "main": "./lib/purgecss.js",
6
6
  "module": "./lib/purgecss.es.js",
@@ -61,7 +61,7 @@
61
61
  "codacy-coverage": "^3.4.0",
62
62
  "eslint": "^6.6.0",
63
63
  "eslint-plugin-flowtype": "^4.3.0",
64
- "flow-bin": "^0.110.0",
64
+ "flow-bin": "^0.113.0",
65
65
  "jest": "^24.9.0",
66
66
  "prettier": "^1.18.2",
67
67
  "regenerator-runtime": "^0.13.3",
@@ -74,5 +74,8 @@
74
74
  "engines": {
75
75
  "npm": ">=5.2.0",
76
76
  "node": ">=4.4.0"
77
+ },
78
+ "funding": {
79
+ "url": "https://github.com/sponsors/Ffloriel"
77
80
  }
78
81
  }