aboutsummaryrefslogtreecommitdiff
path: root/node_modules/postcss-discard-duplicates
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/postcss-discard-duplicates')
-rw-r--r--node_modules/postcss-discard-duplicates/CHANGELOG.md65
-rw-r--r--node_modules/postcss-discard-duplicates/LICENSE-MIT22
-rw-r--r--node_modules/postcss-discard-duplicates/README.md80
-rw-r--r--node_modules/postcss-discard-duplicates/dist/index.js138
-rw-r--r--node_modules/postcss-discard-duplicates/package.json58
5 files changed, 363 insertions, 0 deletions
diff --git a/node_modules/postcss-discard-duplicates/CHANGELOG.md b/node_modules/postcss-discard-duplicates/CHANGELOG.md
new file mode 100644
index 00000000..c6635b0a
--- /dev/null
+++ b/node_modules/postcss-discard-duplicates/CHANGELOG.md
@@ -0,0 +1,65 @@
+# 2.1.0
+
+* Now supports discarding duplicates irrespective of property order, better
+ support for legacy hacks & partial duplicate removal (thanks to @andyjansson).
+
+# 2.0.2
+
+* Major performance boost by lessening algorithmic complexity; each node is
+ now cached and the nested loop removed, meaning that each node is cast to a
+ string only once (thanks to @asztal).
+
+# 2.0.1
+
+* Now compiled with babel 6.
+* Minor performance boost from exiting from the `dedupe` function if the node
+ has less than two child nodes.
+
+# 2.0.0
+
+* Upgraded to PostCSS 5.
+
+# 1.2.1
+
+* Fixes an integration test failure with cssnano; use PostCSS `each` rather
+ than native `forEach` (thanks to @TrySound).
+
+# 1.2.0
+
+* Improved duplicate detection (thanks to @TrySound).
+
+# 1.1.6
+
+* Improved performance by caching string representations of nodes, and
+ minimising stringifying as much as possible (thanks to @TrySound).
+
+# 1.1.5
+
+* Fixed an issue where comments were being deduplicated.
+
+# 1.1.4
+
+* Improved performance by making all AST iterations in a single pass.
+
+# 1.1.3
+
+* Improved documentation for compatibility with the plugin guidelines.
+* Simplify main source code.
+
+# 1.1.2
+
+* Fixed an issue where declarations inside similar keyframes were being
+ discarded incorrectly.
+
+# 1.1.1
+
+* Fixed a bug where keyframe rules were being incorrectly discarded, if they had
+ the same declarations but different vendor prefixes.
+
+# 1.1.0
+
+* Now uses the PostCSS `4.1` plugin API.
+
+# 1.0.0
+
+* Initial release.
diff --git a/node_modules/postcss-discard-duplicates/LICENSE-MIT b/node_modules/postcss-discard-duplicates/LICENSE-MIT
new file mode 100644
index 00000000..fd0e863a
--- /dev/null
+++ b/node_modules/postcss-discard-duplicates/LICENSE-MIT
@@ -0,0 +1,22 @@
+Copyright (c) Ben Briggs <beneb.info@gmail.com> (http://beneb.info)
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/postcss-discard-duplicates/README.md b/node_modules/postcss-discard-duplicates/README.md
new file mode 100644
index 00000000..1c7def8c
--- /dev/null
+++ b/node_modules/postcss-discard-duplicates/README.md
@@ -0,0 +1,80 @@
+# [postcss][postcss]-discard-duplicates [![Build Status](https://travis-ci.org/ben-eb/postcss-discard-duplicates.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-discard-duplicates.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-discard-duplicates.svg)][deps]
+
+> Discard duplicate rules in your CSS files with PostCSS.
+
+## Install
+
+With [npm](https://npmjs.org/package/postcss-discard-duplicates) do:
+
+```
+npm install postcss-discard-duplicates --save
+```
+
+## Example
+
+This module will remove all duplicate rules from your stylesheets. It works on
+at rules, normal rules and declarations. Note that this module does not have any
+responsibility for normalising declarations, selectors or whitespace, so that it
+considers these two rules to be different:
+
+```css
+h1, h2 {
+ color: blue;
+}
+
+h2, h1 {
+ color: blue;
+}
+```
+
+It has to assume that your rules have already been transformed by another
+processor, otherwise it would be responsible for too many things.
+
+### Input
+
+```css
+h1 {
+ margin: 0 auto;
+ margin: 0 auto
+}
+
+h1 {
+ margin: 0 auto
+}
+```
+
+### Output
+
+```css
+h1 {
+ margin: 0 auto
+}
+```
+
+## Usage
+
+See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
+examples for your environment.
+
+## Contributors
+
+Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
+
+<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
+| [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=ben-eb) [📖](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=ben-eb) 👀 [⚠️](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/5635476?v=3" width="100px;"/><br /><sub>Bogdan Chadkin</sub>](https://github.com/TrySound)<br />[💻](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=TrySound) 👀 [⚠️](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=TrySound) | [<img src="https://avatars.githubusercontent.com/u/68302?v=3" width="100px;"/><br /><sub>Lee Houghton</sub>](https://github.com/asztal)<br />[💻](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=asztal) | [<img src="https://avatars.githubusercontent.com/u/1737375?v=3" width="100px;"/><br /><sub>Andy Jansson</sub>](https://github.com/andyjansson)<br />[💻](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=andyjansson) [⚠️](https://github.com/ben-eb/postcss-discard-duplicates/commits?author=andyjansson) |
+| :---: | :---: | :---: | :---: |
+<!-- ALL-CONTRIBUTORS-LIST:END -->
+
+This project follows the [all-contributors] specification. Contributions of
+any kind welcome!
+
+## License
+
+MIT © [Ben Briggs](http://beneb.info)
+
+
+[all-contributors]: https://github.com/kentcdodds/all-contributors
+[ci]: https://travis-ci.org/ben-eb/postcss-discard-duplicates
+[deps]: https://gemnasium.com/ben-eb/postcss-discard-duplicates
+[npm]: http://badge.fury.io/js/postcss-discard-duplicates
+[postcss]: https://github.com/postcss/postcss
diff --git a/node_modules/postcss-discard-duplicates/dist/index.js b/node_modules/postcss-discard-duplicates/dist/index.js
new file mode 100644
index 00000000..3fd2fd8a
--- /dev/null
+++ b/node_modules/postcss-discard-duplicates/dist/index.js
@@ -0,0 +1,138 @@
+'use strict';
+
+exports.__esModule = true;
+
+var _postcss = require('postcss');
+
+function noop() {}
+
+function trimValue(value) {
+ return value ? value.trim() : value;
+}
+
+function empty(node) {
+ return !node.nodes.filter(function (child) {
+ return child.type !== 'comment';
+ }).length;
+}
+
+function equals(a, b) {
+ if (a.type !== b.type) {
+ return false;
+ }
+
+ if (a.important !== b.important) {
+ return false;
+ }
+
+ if (a.raws && !b.raws || !a.raws && b.raws) {
+ return false;
+ }
+
+ switch (a.type) {
+ case 'rule':
+ if (a.selector !== b.selector) {
+ return false;
+ }
+ break;
+ case 'atrule':
+ if (a.name !== b.name || a.params !== b.params) {
+ return false;
+ }
+
+ if (a.raws && trimValue(a.raws.before) !== trimValue(b.raws.before)) {
+ return false;
+ }
+
+ if (a.raws && trimValue(a.raws.afterName) !== trimValue(b.raws.afterName)) {
+ return false;
+ }
+ break;
+ case 'decl':
+ if (a.prop !== b.prop || a.value !== b.value) {
+ return false;
+ }
+
+ if (a.raws && trimValue(a.raws.before) !== trimValue(b.raws.before)) {
+ return false;
+ }
+ break;
+ }
+
+ if (a.nodes) {
+ if (a.nodes.length !== b.nodes.length) {
+ return false;
+ }
+
+ for (var i = 0; i < a.nodes.length; i++) {
+ if (!equals(a.nodes[i], b.nodes[i])) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+function dedupeRule(last, nodes) {
+ var index = nodes.indexOf(last) - 1;
+
+ var _loop = function _loop() {
+ var node = nodes[index--];
+ if (node && node.type === 'rule' && node.selector === last.selector) {
+ last.each(function (child) {
+ if (child.type === 'decl') {
+ dedupeNode(child, node.nodes);
+ }
+ });
+
+ if (empty(node)) {
+ node.remove();
+ }
+ }
+ };
+
+ while (index >= 0) {
+ _loop();
+ }
+}
+
+function dedupeNode(last, nodes) {
+ var index = !!~nodes.indexOf(last) ? nodes.indexOf(last) - 1 : nodes.length - 1;
+
+ while (index >= 0) {
+ var _node = nodes[index--];
+ if (_node && equals(_node, last)) {
+ _node.remove();
+ }
+ }
+}
+
+var handlers = {
+ rule: dedupeRule,
+ atrule: dedupeNode,
+ decl: dedupeNode,
+ comment: noop
+};
+
+function dedupe(root) {
+ var nodes = root.nodes;
+
+ if (!nodes) {
+ return;
+ }
+
+ var index = nodes.length - 1;
+ while (index >= 0) {
+ var last = nodes[index--];
+ if (!last || !last.parent) {
+ continue;
+ }
+ dedupe(last);
+ handlers[last.type](last, nodes);
+ }
+}
+
+exports.default = (0, _postcss.plugin)('postcss-discard-duplicates', function () {
+ return dedupe;
+});
+module.exports = exports['default']; \ No newline at end of file
diff --git a/node_modules/postcss-discard-duplicates/package.json b/node_modules/postcss-discard-duplicates/package.json
new file mode 100644
index 00000000..532f1ba2
--- /dev/null
+++ b/node_modules/postcss-discard-duplicates/package.json
@@ -0,0 +1,58 @@
+{
+ "name": "postcss-discard-duplicates",
+ "version": "2.1.0",
+ "description": "Discard duplicate rules in your CSS files with PostCSS.",
+ "main": "dist/index.js",
+ "files": [
+ "dist",
+ "LICENSE-MIT"
+ ],
+ "scripts": {
+ "contributorAdd": "all-contributors add",
+ "contributorGenerate": "all-contributors generate",
+ "pretest": "eslint src",
+ "prepublish": "del-cli dist && babel src --out-dir dist --ignore /__tests__/",
+ "test": "ava src/__tests__",
+ "test-012": "ava src/__tests__"
+ },
+ "keywords": [
+ "css",
+ "dedupe",
+ "optimise",
+ "postcss",
+ "postcss-plugin"
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "postcss": "^5.0.4"
+ },
+ "devDependencies": {
+ "all-contributors-cli": "^3.0.5",
+ "ava": "^0.17.0",
+ "babel-cli": "^6.3.17",
+ "babel-core": "^6.3.26",
+ "babel-plugin-add-module-exports": "^0.2.0",
+ "babel-preset-es2015": "^6.5.0",
+ "babel-preset-es2015-loose": "^7.0.0",
+ "babel-preset-stage-0": "^6.3.13",
+ "babel-register": "^6.9.0",
+ "del-cli": "^0.2.0",
+ "eslint": "^3.0.0",
+ "eslint-config-cssnano": "^3.0.0",
+ "eslint-plugin-babel": "^3.3.0",
+ "eslint-plugin-import": "^2.0.1"
+ },
+ "homepage": "https://github.com/ben-eb/postcss-discard-duplicates",
+ "author": {
+ "name": "Ben Briggs",
+ "email": "beneb.info@gmail.com",
+ "url": "http://beneb.info"
+ },
+ "repository": "ben-eb/postcss-discard-duplicates",
+ "eslintConfig": {
+ "extends": "cssnano"
+ },
+ "ava": {
+ "require": "babel-register"
+ }
+}