postcss-discard-duplicates
Advanced tools
Comparing version 5.0.1 to 5.0.2
@@ -8,4 +8,2 @@ "use strict"; | ||
function noop() {} | ||
function trimValue(value) { | ||
@@ -103,3 +101,3 @@ return value ? value.trim() : value; | ||
function dedupeNode(last, nodes) { | ||
let index = ~nodes.indexOf(last) ? nodes.indexOf(last) - 1 : nodes.length - 1; | ||
let index = nodes.includes(last) ? nodes.indexOf(last) - 1 : nodes.length - 1; | ||
@@ -115,9 +113,2 @@ while (index >= 0) { | ||
const handlers = { | ||
rule: dedupeRule, | ||
atrule: dedupeNode, | ||
decl: dedupeNode, | ||
comment: noop | ||
}; | ||
function dedupe(root) { | ||
@@ -142,3 +133,8 @@ const { | ||
dedupe(last); | ||
handlers[last.type](last, nodes); | ||
if (last.type === 'rule') { | ||
dedupeRule(last, nodes); | ||
} else if (last.type === 'atrule' || last.type === 'decl') { | ||
dedupeNode(last, nodes); | ||
} | ||
} | ||
@@ -145,0 +141,0 @@ } |
{ | ||
"name": "postcss-discard-duplicates", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "Discard duplicate rules in your CSS files with PostCSS.", | ||
@@ -10,7 +10,2 @@ "main": "dist/index.js", | ||
], | ||
"scripts": { | ||
"prebuild": "del-cli dist", | ||
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"", | ||
"prepublish": "yarn build" | ||
}, | ||
"keywords": [ | ||
@@ -43,3 +38,7 @@ "css", | ||
}, | ||
"gitHead": "28c247175032fa03f04911cde56ad82d74d211cc" | ||
} | ||
"scripts": { | ||
"prebuild": "rimraf dist", | ||
"build": "babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"" | ||
}, | ||
"readme": "# [postcss][postcss]-discard-duplicates\n\n> Discard duplicate rules in your CSS files with PostCSS.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-discard-duplicates) do:\n\n```\nnpm install postcss-discard-duplicates --save\n```\n\n## Example\n\nThis module will remove all duplicate rules from your stylesheets. It works on\nat rules, normal rules and declarations. Note that this module does not have any\nresponsibility for normalising declarations, selectors or whitespace, so that it\nconsiders these two rules to be different:\n\n```css\nh1, h2 {\n color: blue;\n}\n\nh2, h1 {\n color: blue;\n}\n```\n\nIt has to assume that your rules have already been transformed by another\nprocessor, otherwise it would be responsible for too many things.\n\n### Input\n\n```css\nh1 {\n margin: 0 auto;\n margin: 0 auto\n}\n\nh1 {\n margin: 0 auto\n}\n```\n\n### Output\n\n```css\nh1 {\n margin: 0 auto\n}\n```\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n\n[postcss]: https://github.com/postcss/postcss\n" | ||
} |
7279
4
116