{"_id":"postcss-extend","_rev":"322331","name":"postcss-extend","description":"As close to cssnext @extend as possible for PostCSS","dist-tags":{"latest":"1.0.5"},"maintainers":[{"name":"travco","email":"hofnug@gmail.com"}],"time":{"modified":"2021-06-04T01:28:35.000Z","created":"2015-07-09T15:29:07.484Z","1.0.5":"2016-08-08T13:29:53.987Z","1.0.4":"2016-06-21T20:12:38.723Z","1.0.3":"2016-06-21T18:04:01.594Z","1.0.1":"2015-10-07T21:35:03.983Z","1.0.0":"2015-09-08T18:09:57.219Z","0.4.3":"2015-07-21T21:34:44.415Z","0.4.2":"2015-07-09T20:11:25.294Z","0.4.1":"2015-07-09T20:02:28.067Z","0.4.0":"2015-07-09T15:29:07.484Z"},"users":{"danielbayley":true},"author":{"name":"Travis Palmer","email":"hofnug@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/travco/postcss-extend.git"},"versions":{"1.0.5":{"name":"postcss-extend","author":{"name":"Travis Palmer","email":"hofnug@gmail.com"},"license":"MIT","version":"1.0.5","description":"As close to cssnext @extend as possible for PostCSS","homepage":"https://github.com/travco/postcss-extend","repository":{"type":"git","url":"git+https://github.com/travco/postcss-extend.git"},"keywords":["css","postcss","postcss-plugin","mixin","clone","extend"],"files":["index.js","LICENSE","README.md","CHANGELOG.md"],"main":"index.js","scripts":{"lint":"eslint index.js test/index.js","test":"rm -f test/debugout.txt && npm run lint && tape test"},"dependencies":{"postcss":"^5.0.4"},"devDependencies":{"eslint":"0.18.0","tape":"4.0.0"},"gitHead":"eab6709705ba0047c2bf61e139c838585b1e885c","bugs":{"url":"https://github.com/travco/postcss-extend/issues"},"_id":"postcss-extend@1.0.5","_shasum":"5ea98bf787ba3cacf4df4609743f80a833b1d0e7","_from":".","_npmVersion":"3.10.5","_nodeVersion":"4.4.7","_npmUser":{"name":"travco","email":"hofnug@gmail.com"},"dist":{"shasum":"5ea98bf787ba3cacf4df4609743f80a833b1d0e7","size":12380,"noattachment":false,"key":"/postcss-extend/-/postcss-extend-1.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/postcss-extend/download/postcss-extend-1.0.5.tgz"},"maintainers":[{"name":"travco","email":"hofnug@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/postcss-extend-1.0.5.tgz_1470662992107_0.5574139135424048"},"directories":{},"publish_time":1470662993987,"_cnpm_publish_time":1470662993987,"_hasShrinkwrap":false},"1.0.4":{"name":"postcss-extend","author":{"name":"Travis Palmer","email":"hofnug@gmail.com"},"license":"MIT","version":"1.0.4","description":"As close to cssnext @extend as possible for PostCSS","homepage":"https://github.com/travco/postcss-extend","repository":{"type":"git","url":"git+https://github.com/travco/postcss-extend.git"},"keywords":["css","postcss","postcss-plugin","mixin","clone","extend"],"files":["index.js","LICENSE","README.md","CHANGELOG.md"],"main":"index.js","scripts":{"lint":"eslint index.js test/index.js","test":"rm -f test/debugout.txt && npm run lint && tape test"},"dependencies":{"postcss":"^5.0.4"},"devDependencies":{"eslint":"0.18.0","tape":"4.0.0"},"gitHead":"ef35a910bfa0eb3d3c36b887d7f769f67415c9c0","bugs":{"url":"https://github.com/travco/postcss-extend/issues"},"_id":"postcss-extend@1.0.4","_shasum":"185dea58d29f754d07afd445e60417c1dddaa061","_from":".","_npmVersion":"3.9.5","_nodeVersion":"4.4.5","_npmUser":{"name":"travco","email":"hofnug@gmail.com"},"dist":{"shasum":"185dea58d29f754d07afd445e60417c1dddaa061","size":12277,"noattachment":false,"key":"/postcss-extend/-/postcss-extend-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/postcss-extend/download/postcss-extend-1.0.4.tgz"},"maintainers":[{"name":"travco","email":"hofnug@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/postcss-extend-1.0.4.tgz_1466539957152_0.48068345012143254"},"directories":{},"publish_time":1466539958723,"_cnpm_publish_time":1466539958723,"_hasShrinkwrap":false},"1.0.3":{"name":"postcss-extend","author":{"name":"Travis Palmer","email":"hofnug@gmail.com"},"license":"MIT","version":"1.0.3","description":"As close to cssnext @extend as possible for PostCSS","homepage":"https://github.com/travco/postcss-extend","repository":{"type":"git","url":"git+https://github.com/travco/postcss-extend.git"},"keywords":["css","postcss","postcss-plugin","mixin","clone","extend"],"files":["index.js","LICENSE","README.md","CHANGELOG.md"],"main":"index.js","scripts":{"lint":"eslint index.js test/index.js","test":"rm -f test/debugout.txt && npm run lint && tape test"},"dependencies":{"postcss":"^5.0.4"},"devDependencies":{"eslint":"0.18.0","tape":"4.0.0"},"gitHead":"bed3a650e374e0c48d25370f45f29ff18f69821e","bugs":{"url":"https://github.com/travco/postcss-extend/issues"},"_id":"postcss-extend@1.0.3","_shasum":"681bbaf0a728f548b74b707f836ec7832f6bee34","_from":".","_npmVersion":"3.9.5","_nodeVersion":"4.4.5","_npmUser":{"name":"travco","email":"hofnug@gmail.com"},"dist":{"shasum":"681bbaf0a728f548b74b707f836ec7832f6bee34","size":12158,"noattachment":false,"key":"/postcss-extend/-/postcss-extend-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/postcss-extend/download/postcss-extend-1.0.3.tgz"},"maintainers":[{"name":"travco","email":"hofnug@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/postcss-extend-1.0.3.tgz_1466532239147_0.3377532074227929"},"directories":{},"publish_time":1466532241594,"_cnpm_publish_time":1466532241594,"_hasShrinkwrap":false},"1.0.1":{"name":"postcss-extend","author":{"name":"Travis Palmer","email":"hofnug@gmail.com"},"license":"MIT","version":"1.0.1","description":"As close to cssnext @extend as possible for PostCSS","homepage":"https://github.com/travco/postcss-extend","repository":{"type":"git","url":"git+https://github.com/travco/postcss-extend.git"},"keywords":["css","postcss","postcss-plugin","mixin","clone","extend"],"files":["index.js","LICENSE","README.md","CHANGELOG.md"],"main":"index.js","scripts":{"lint":"eslint index.js test/index.js","test":"rm -f test/debugout.txt && npm run lint && tape test"},"dependencies":{"postcss":"^5.0.4"},"devDependencies":{"eslint":"0.18.0","tape":"4.0.0"},"gitHead":"3dc789b777f9b811351ce65e27a029c230750aad","bugs":{"url":"https://github.com/travco/postcss-extend/issues"},"_id":"postcss-extend@1.0.1","_shasum":"e0c8a8f3bacd7d4223a4680012bbae95ebf14b13","_from":".","_npmVersion":"2.9.1","_nodeVersion":"0.12.3","_npmUser":{"name":"travco","email":"hofnug@gmail.com"},"dist":{"shasum":"e0c8a8f3bacd7d4223a4680012bbae95ebf14b13","size":12155,"noattachment":false,"key":"/postcss-extend/-/postcss-extend-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/postcss-extend/download/postcss-extend-1.0.1.tgz"},"maintainers":[{"name":"travco","email":"hofnug@gmail.com"}],"directories":{},"publish_time":1444253703983,"_cnpm_publish_time":1444253703983,"_hasShrinkwrap":false},"1.0.0":{"name":"postcss-extend","author":{"name":"Travis Palmer","email":"hofnug@gmail.com"},"license":"MIT","version":"1.0.0","description":"As close to cssnext @extend as possible for PostCSS","homepage":"https://github.com/travco/postcss-extend","repository":{"type":"git","url":"git+https://github.com/travco/postcss-extend.git"},"keywords":["css","postcss","postcss-plugin","mixin","clone","extend"],"files":["index.js","LICENSE","README.md","CHANGELOG.md"],"main":"index.js","scripts":{"lint":"eslint index.js test/index.js","test":"rm -f test/debugout.txt && npm run lint && tape test"},"dependencies":{"postcss":"^5.0.4"},"devDependencies":{"eslint":"0.18.0","tape":"4.0.0"},"gitHead":"6ac2225d13b84dcdb8ca7143fe02fbc5903bc785","bugs":{"url":"https://github.com/travco/postcss-extend/issues"},"_id":"postcss-extend@1.0.0","_shasum":"e8292d06aad242f84ff66c122f60e5e9a4039dba","_from":".","_npmVersion":"2.9.1","_nodeVersion":"0.12.3","_npmUser":{"name":"travco","email":"hofnug@gmail.com"},"dist":{"shasum":"e8292d06aad242f84ff66c122f60e5e9a4039dba","size":11988,"noattachment":false,"key":"/postcss-extend/-/postcss-extend-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/postcss-extend/download/postcss-extend-1.0.0.tgz"},"maintainers":[{"name":"travco","email":"hofnug@gmail.com"}],"directories":{},"publish_time":1441735797219,"_cnpm_publish_time":1441735797219,"_hasShrinkwrap":false},"0.4.3":{"name":"postcss-extend","author":{"name":"Travis Palmer","email":"hofnug@gmail.com"},"license":"MIT","version":"0.4.3","description":"As close to cssnext @extend as possible for PostCSS","homepage":"https://github.com/travco/postcss-extend","repository":{"type":"git","url":"git+https://github.com/travco/postcss-extend.git"},"keywords":["css","postcss","postcss-plugin","mixin","clone","extend"],"files":["index.js","LICENSE","README.md","CHANGELOG.md"],"main":"index.js","scripts":{"lint":"eslint index.js test/index.js","test":"rm -f test/debugout.txt && npm run lint && tape test"},"dependencies":{"postcss":"^4.1.0"},"devDependencies":{"eslint":"0.18.0","tape":"4.0.0"},"gitHead":"985cbae8f212bc7c9c05169ef3fb22cd861475f1","bugs":{"url":"https://github.com/travco/postcss-extend/issues"},"_id":"postcss-extend@0.4.3","_shasum":"9830f4513d9761494bbab569d7b00d9bcb15b323","_from":"postcss-simple-extend","_resolved":"file:postcss-simple-extend","_npmVersion":"2.9.1","_nodeVersion":"0.12.3","_npmUser":{"name":"travco","email":"hofnug@gmail.com"},"dist":{"shasum":"9830f4513d9761494bbab569d7b00d9bcb15b323","size":10727,"noattachment":false,"key":"/postcss-extend/-/postcss-extend-0.4.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/postcss-extend/download/postcss-extend-0.4.3.tgz"},"maintainers":[{"name":"travco","email":"hofnug@gmail.com"}],"directories":{},"publish_time":1437514484415,"_cnpm_publish_time":1437514484415,"_hasShrinkwrap":false},"0.4.2":{"name":"postcss-extend","author":{"name":"Travis Palmer","email":"hofnug@gmail.com"},"license":"MIT","version":"0.4.2","description":"Simple extends for PostCSS","homepage":"https://github.com/travco/postcss-extend","repository":{"type":"git","url":"git+https://github.com/travco/postcss-extend.git"},"keywords":["css","postcss","postcss-plugin","mixin","clone","extend"],"files":["index.js","LICENSE","README.md","CHANGELOG.md"],"main":"index.js","scripts":{"lint":"eslint index.js test/index.js","test":"rm -f test/debugout.txt && npm run lint && tape test"},"dependencies":{"postcss":"^4.1.0"},"devDependencies":{"eslint":"0.18.0","tape":"4.0.0"},"gitHead":"3290985b923014e5a5c392245f3866e96bfbc741","bugs":{"url":"https://github.com/travco/postcss-extend/issues"},"_id":"postcss-extend@0.4.2","_shasum":"3f08f8ef93c6a8f06d34910cc0ac1079d20a4593","_from":".","_npmVersion":"2.9.1","_nodeVersion":"0.12.3","_npmUser":{"name":"travco","email":"hofnug@gmail.com"},"dist":{"shasum":"3f08f8ef93c6a8f06d34910cc0ac1079d20a4593","size":9454,"noattachment":false,"key":"/postcss-extend/-/postcss-extend-0.4.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/postcss-extend/download/postcss-extend-0.4.2.tgz"},"maintainers":[{"name":"travco","email":"hofnug@gmail.com"}],"directories":{},"publish_time":1436472685294,"_cnpm_publish_time":1436472685294,"_hasShrinkwrap":false},"0.4.1":{"name":"postcss-extend","author":{"name":"Travis Palmer","email":"hofnug@gmail.com"},"license":"MIT","version":"0.4.1","description":"Simple extends for PostCSS","homepage":"https://github.com/travco/postcss-extend","repository":{"type":"git","url":"git+https://github.com/travco/postcss-extend.git"},"keywords":["css","postcss","postcss-plugin","mixin","clone","extend"],"files":["index.js","LICENSE","README.md","CHANGELOG.md"],"main":"index.js","scripts":{"lint":"eslint index.js test/index.js","test":"rm -f test/debugout.txt && npm run lint && tape test"},"dependencies":{"postcss":"^4.1.0"},"devDependencies":{"eslint":"0.18.0","tape":"4.0.0"},"gitHead":"3290985b923014e5a5c392245f3866e96bfbc741","bugs":{"url":"https://github.com/travco/postcss-extend/issues"},"_id":"postcss-extend@0.4.1","_shasum":"f71df5e9078488890385e70d6f3e2c0b59916d17","_from":".","_npmVersion":"2.9.1","_nodeVersion":"0.12.3","_npmUser":{"name":"travco","email":"hofnug@gmail.com"},"dist":{"shasum":"f71df5e9078488890385e70d6f3e2c0b59916d17","size":9449,"noattachment":false,"key":"/postcss-extend/-/postcss-extend-0.4.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/postcss-extend/download/postcss-extend-0.4.1.tgz"},"maintainers":[{"name":"travco","email":"hofnug@gmail.com"}],"directories":{},"publish_time":1436472148067,"_cnpm_publish_time":1436472148067,"_hasShrinkwrap":false},"0.4.0":{"name":"postcss-extend","author":{"name":"Travis Palmer","email":"hofnug@gmail.com"},"license":"MIT","version":"0.4.0","description":"Simple extends for PostCSS","homepage":"https://github.com/travco/postcss-extend","repository":{"type":"git","url":"git+https://github.com/travco/postcss-extend.git"},"keywords":["css","postcss","postcss-plugin","mixin","clone","extend"],"files":["index.js","LICENSE","README.md","CHANGELOG.md"],"main":"index.js","scripts":{"lint":"eslint index.js test/index.js","test":"rm -f test/debugout.txt && npm run lint && tape test"},"dependencies":{"postcss":"^4.1.0"},"devDependencies":{"eslint":"0.18.0","tape":"4.0.0"},"gitHead":"ef406754590ac7f837d9eaa0558cab0488df7a5c","bugs":{"url":"https://github.com/travco/postcss-extend/issues"},"_id":"postcss-extend@0.4.0","_shasum":"fc08d09249af1626f7b85be9bd70300633b48b3d","_from":".","_npmVersion":"2.9.1","_nodeVersion":"0.12.3","_npmUser":{"name":"travco","email":"hofnug@gmail.com"},"dist":{"shasum":"fc08d09249af1626f7b85be9bd70300633b48b3d","size":10829,"noattachment":false,"key":"/postcss-extend/-/postcss-extend-0.4.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/postcss-extend/download/postcss-extend-0.4.0.tgz"},"maintainers":[{"name":"travco","email":"hofnug@gmail.com"}],"directories":{},"publish_time":1436455747484,"_cnpm_publish_time":1436455747484,"_hasShrinkwrap":false}},"readme":"# postcss-extend [![Build Status](https://travis-ci.org/travco/postcss-extend.svg?branch=master)](https://travis-ci.org/travco/postcss-extend)\n\n**A [PostCSS](https://github.com/postcss/postcss) plugin that tries to minimize the number of repeat selectors and rules you write in CSS.**\n\n\n\nUse this plugin to:\n- Define a \"silent\" extendable selector — a \"placeholder selector\" — to which you can (from anywhere in the doc) add concrete selectors from other rule sets.\n- Add concrete selectors from one rule (containing the `@extend`) to all rule sets with the selector specified (or a subclass of the one specified).\n- Pull in declarations in rulesets (most) anywhere in the doc (by a selector) from within `@media` statements (semi-safely)\n- Extend existing media-conscious rulesets, even if some of them are within `@media` statements.\n\n\n[Installation](https://github.com/travco/postcss-extend#installation) | [Usage](https://github.com/travco/postcss-extend#usage) | [Getting it Working](https://github.com/travco/postcss-extend#getting-it-working-with-postcss) | [Quirks](https://github.com/travco/postcss-extend#quirks)\n--- | --- | --- | ---\n\n\nThe logical statement of *this* `@extend` is to \"allow my parent rule to use the declarations of what I extend\".\nThe functionality is intended to somewhat mirror Sass's `@extend` with `%` placeholders (a.k.a. \"silent classes\") and real rules.\nUnlike Sass's `@extend`, however, this plugin (among other things) *does not allow you to extend into selector sequences*: i.e. if you want to `@extend a`, it will not go off and try to extend:\n```css\n#admin .tabbar a {\n  font-weight: bold;\n}\n```\n*Nor* will trying to `@extend a:hover` match:\n```css\n.comment a.user:hover {\n  color: red;\n}\n```\n\nIt **will** however, try to extend selector sequences with the base-piece to work with, i.e. trying to `@extend .never` will match:\n```css\n.never li:first {\n  color: red;\n}\n/*or*/\n.never.ever {\ncolor: blue;\n}\n```\n\nArguably, these limitations make this plugin both less dangerous than SASS's `@extend`, and enforce more (obviously-)predictable behaviors. However, many of SASS `@extend`'s other behaviors have been kept, or altered in such a way to allow ease of use, but not necessarily the same level of strict logical extension.\nIn regards to the concerns people have with Sass's `@extend`, and the problems that can arise from its use, many do not apply to this stripped-out version. However, it is by no means foolproof, and Smart Sass users often recommend to only ever `@extend` placeholders (cf. [Harry Robert](http://csswizardry.com/2014/01/extending-silent-classes-in-sass/) and [Hugo Giraudel](http://sass-guidelin.es/#extend)): *with this plugin, that recommendation is not enforced, but syntactically set apart*.\n\n**`postcss-extend` is compatible with PostCSS v5.0+.**\n\n> **A Note on \"mixins\" & \"extends\"**: Mixins copy declarations from an abstract definition into a concrete rule set. These `@extend`s (normally) clone a concrete rule set's selector(s) and add them to an abstract placeholder selector, or another existing rule. *This* plugin enables extends. If you would like to use mixins, as well — or instead — have a look at [`postcss-mixins`](https://github.com/postcss/postcss-mixins).\n\n## Installation\n```\nnpm install postcss-extend --save\n```\n\n\n**Public Service Announcement**: Because of [an issue with `postcss-nested`](https://github.com/postcss/postcss-nested/issues/11), if you are trying to use *both* `postcss-nested` and this plugin, you need to *use this plugin first*.\n\n\n## Usage\n\n- [Defining Placeholders](https://github.com/travco/postcss-extend#defining-placeholders)\n  - [The '%' placeholder](https://github.com/travco/postcss-extend#the--silent-placeholder)\n- [Extending Rules or Placeholders](https://github.com/travco/postcss-extend#extending-rules-or-placeholders)\n  - [Extending Sub Classes and Sub Elements](https://github.com/travco/postcss-extend#extending-sub-classes-and-sub-elements)\n  - [Extending with @media](https://github.com/travco/postcss-extend#extending-with-media)\n    - [Simple declaration-pulling](https://github.com/travco/postcss-extend#simple-declaration-pulling)\n    - [External Sub classes](https://github.com/travco/postcss-extend#external-sub-classes)\n    - [Extending something inside @media (on the outside looking in)](https://github.com/travco/postcss-extend#extending-something-inside-media-on-the-outside-looking-in)\n    - [Extending something in an @media while inside an @media](https://github.com/travco/postcss-extend#extending-something-in-an-media-while-inside-an-media)\n- [Chaining `@extend`s, or Extension-Recursion](https://github.com/travco/postcss-extend#chaining-extends-or-extension-recursion)\n\n### Defining Placeholders\n\nWith `@define-placeholder`, you associate a rule set with a placeholder selector, which you will later extend with concrete selectors. It (and its other aliases) can only be extended if it's already been declared in the document, is at the root-level (not inside anything) and *cannot be extended-out-of*.\n\nYou can also use its aliases: `@define-extend` or `@extend-define`.\n\n```css\n@define-placeholder simple-list {\n  list-style-type: none;\n  margin: 0;\n  padding: 0;\n}\n/* or @define-extend simple list {...} */\n/* or @extend-define list {...} */\n```\n\n`@define-placeholder` at-rules, and the placeholder names (e.g. `simple-list`, above), will be removed entirely from the generated CSS, replaced by the selectors you've added via `@extend` (see example above).\n\n##### The \"%\" (silent) placeholder\n\nThe \"%\" placeholder acts similarly to `@define-placeholder` and its aliases, with four exceptions. One, that it doesn't need to be declared before it is extended. Two, you can extend out of it (thus extending anything that extends the placeholder, or nothing if the placeholder isn't referenced). Three, it needs to be specifically targeted in the extend, for example: `@extend %simple-list`. Four, it doesn't need to be at the root in order to work - and can be inside of something else (e.g. an `@media`):\n\n```css\n%container {\n  padding-left: 15px;\n}\n@media (--md-viewport) {\n  %container {\n    padding-left: 2em;\n  }\n}\n.extendingClass {\n  @extend %container;\n}\n```\n\n(`@define-placeholder`'s limitations are an originally unintended feature, kept for its possible usefulness as a stricter, more controlled method of extending).\n\nAdditionally, all definitions will log a warning if they go unused, and should only contain declarations and comments: no statements (violations will also log warnings).\n\n### Extending Rules or Placeholders\n\nUse the at-rule `@extend` within a rule set to add that rule set's selector(s) to a placeholder (which was defined via `@define-placeholder`).\n\nYou can also use its alias `@define-extend'.\n\n```css\n.list-i-want-to-be-simple {\n  @extend simple-list;\n  font-size: 40em;\n}\n```\nRules and placeholders are extended in much the same fashion; the only real difference is that placeholders can be named most anything, whereas rules need to be extended via the same syntax in the css. For example, to extend a 'foo' class it'd be `@extend .foo`\n\nThere is only one overarching `@extend` guideline to obey: `@extend` must **not** occur at the root level, it only can be used inside rule sets.\n\n#### Extending Sub Classes and Sub Elements\n\nWhenever extending a rule or placeholder, you are also automatically trying to extend any subclasses or elements that have *exactly* what you selected (before a space, `.`, `:`, or `#`). For example:\n```css\n.potato {\n  color: white;\n}\n\n.potato:first-child,\n.potato a::after {\n  background: brown;\n}\n\n#superfun {\n  @extend .potato;\n}\n```\nResolves to:\n```css\n.potato, #superfun {\n  color: white;\n}\n\n.potato:first-child, .potato a::after, #superfun:first-child, #superfun a::after {\n  background: brown;\n}\n```\nMake note that `#superfun` deletes itself, because otherwise it would have been empty brackets.\n\nYou also can still specifically extend subclasses by-themselves by calling them out explicitly.\nIf (in the above example) you wanted to only get `background:brown` instead of everything having to do with `.potato`, you could just use `@extend .potato:first-child;`.\n\n#### Extending with `@media`\n\nThe bridging behavior of this plugin is by far its most dangerous, despite the steps to keep it relatively sane. Be mindful.\nThe logical statement of *this* `@extend` is to \"allow my parent rule to use the declarations of what I extend.\" Thus, when within an @media rule, its behavior takes on the contingency of the rule, and instead of tacking on its parent's selectors to rules it extends (thus using their declarations), it directly brings in the declarations.\n\n##### Simple declaration pulling\n\nTrying to extend a rule outside an `@media` from the inside is fairly straightforward. For example:\n```css\n.potato {\n  color: white;\n  outline: brown;\n  font-family: sans-serif;\n}\n\n@media (width > 600px) {\n  .potato:first {\n    float: center;\n  }\n\n  .spud {\n    @extend .potato;\n    color: red;\n    font-size: 4em;\n  }\n}\n```\nResolves to:\n```css\n.potato {\n  color: white;\n  outline: brown;\n  font-family: sans-serif;\n}\n\n@media (width > 600px) {\n  .potato:first, .spud:first {\n    float: center;\n  }\n\n  .spud {\n    color: red;\n    font-size: 4em;\n    outline: brown;\n    font-family: sans-serif;\n  }\n}\n```\nNotice how `.spud` only takes in declarations from `.potato` that it doesn't already have. Extending will never override declarations already present while copying. Additionally, notice how `.spud` extends `.potato`'s pseudo-class (`:first`) inside the media scope by tacking onto the target rule, just like before. That's because it is scope-conscious (especially while in an `@media`).\n\n##### External Sub classes\n\nSo what does it do when subclasses of the extended rule are also outside `@media`?\n```css\n.potato {\n  float: left;\n}\n\n.potato:first, .potato ul:first-child {\n  float: right;\n}\n\n@media (width > 600px) {\n  .spud {\n    @extend .potato;\n    font-weight: bold;\n    color: red;\n  }\n\n  .spud:first {\n    background: purple;\n  }\n}\n```\nResolves to:\n```css\n.potato {\n  float: left;\n}\n\n.potato:first, .potato ul:first-child {\n  float: right;\n}\n\n@media (width > 600px) {\n  .spud {\n    font-weight: bold;\n    color: red;\n    float: left;\n  }\n  .spud ul:first-child {\n    float: right;\n  }\n\n  .spud:first {\n    background: purple;\n    float: right;\n  }\n}\n```\nFirst let's notice that the sub class `.spud ul:first-child` (which wasn't within `@media` originally) is created with a copy of `.potato ul:first-child`'s declaration. Meanwhile, `.spud:first` was already within the `@media` rule, and it took on the extra declaration. If there is a rule within the `@media` with exactly the same selectors as what it would create, it will just pull in declarations. Keep in mind, the same ideas apply here while \"pulling in\" declarations: it copies, but won't replace.\n\n##### Extending something inside `@media` (on the outside looking in)\n\nSo what if you want to extend something that's within an `@media` from the root? It's actually fairly straightforward when you think about what that means.\n```css\n@media (width > 600px) {\n  .spud {\n    font-weight: bold;\n    color: red;\n  }\n  .spud:first-child {\n    background: purple;\n  }\n}\n\n.sputnik {\n  @extend .spud;\n  font-weight: normal;\n  font-style: italic;\n}\n```\nResolves to:\n```css\n@media (width > 600px) {\n  .spud, .sputnik {\n    font-weight: bold;\n    color: red;\n  }\n  .spud:first-child, .sputnik:first-child {\n    background: purple;\n  }\n}\n\n.sputnik {\n  font-weight: normal;\n  font-style: italic;\n}\n```\nExtending from the root, just like before, just tacks on selectors onto target rules, even into the `@media`. This stays true to the logic of *this* version of `@extend` because it's maintaining the conditionality of the declarations within `@media`.\n\n##### Extending something in an `@media` while inside an `@media`\n\n**Don't**. It's currently directly-disallowed in code to prevent unexpected things from happening, and will throw an error to warn you. The current expectation is that the only time the majority of users would do this is when making a mistake. That expectation remains unless someone can present a solution and a logical way of handling this (not in the native CSS parser) that is also a realistic common-use case.\n\n#### Chaining `@extend`s, or extension-recursion\n\nDefinitely one of the more powerful features of SASS's `@extend` is here too. It does, however, come with a slight caveat that it is order-agnostic, meaning that it doesn't enforce order by only extending that which came above it. It just goes.\n```css\n.charlie {\n  @extend .delta;\n  font-weight: bold;\n}\n.alpha {\n  @extend .bravo;\n  color: red;\n}\n.bravo {\n  @extend .charlie;\n  background: blue;\n}\n.delta {\n  color: green;\n  background: gray;\n}\n```\nResolves to:\n```css\n.charlie, .bravo, .alpha {\n  font-weight: bold;\n}\n.alpha {\n  color: red;\n}\n.bravo, .alpha {\n  background: blue;\n}\n.delta, .charlie, .bravo, .alpha {\n  color: green;\n  background: gray;\n}\n```\nDoesn't that take a lot of computation to do though? Well, not really since it's not \"true\" recursion. Since we're tacking on selectors, every rule is a living record of everything that has extended it, and if we're not tacking on selectors, we're copying everything we need from the other rule. Thus, in well-formed CSS we only need to go through the CSS doc once, top to bottom.\n\nIn anti-pattern CSS (extending things yet to be declared), it will handle `@extend` recursively, but only if the extended target has unresolved `@extend` rules in it (thus, slowing down processing, but keeping it working as expected). As a bonus, there is a built-in recursive-stack tracking that both detects infinite loops, and throws warnings (in order of least-tampered css first) for every step of the infinite loop. It also does its best to still process the CSS in the infinite loop (almost always as intended).\n\n## Getting It Working with PostCSS\n\nPlug it in just like any other [PostCSS](https://github.com/postcss/postcss) plugin. There are no frills and no options, so integration should be straightforward. For example (as a node script):\n\n```js\nvar fs = require('fs');\nvar postcss = require('postcss');\nvar simpleExtend = require('postcss-extend');\n\nvar inputCss = fs.readFileSync('input.css', 'utf8');\n\nvar outputCss = postcss()\n  .use(simpleExtend())\n  // or .use(simpleExtend)\n  .process(inputCss)\n  .css;\n\nconsole.log(outputCss);\n```\n\nOr take advantage of [any of the myriad of other ways to consume PostCSS](https://github.com/postcss/postcss#usage), and follow the plugin instructions they provide.\n\n## Quirks\nAs with any piece of code, it's got a few quirks. Behaviors that are not intended, and not enforced, may disappear (or be forcibly altered) with the next release, so it's useful to be aware of them.\n\n**Order of Processing** : Currently, all of the `@extend`s being processed are run in a sequential manner from the top to the bottom of the doc. This keeps things relatively snappy, but makes it so that we have to do conditional-recursion on not-yet-declared-or-extended rules. This leads to some blatant inefficiencies when processing badly formed CSS (anti-pattern CSS). So if you want to keep processing time down, write good CSS. If you're curious if what you're writing is an anti-pattern, don't worry, it will throw a warning.\n\n**Non-logical means of extension for `@media`** : As anyone who's aware of the complications discussed in the [SASS issue about extending across `@media`](https://github.com/sass/sass/issues/1050) would know. There is no way (known) of extending when `@media` rules are involved that is both 'clean and simple' and 'logically correct with how `@extend` is used elsewhere'. The way this plugin operates, and its logical meaning, is a blatant compromise so that it has both common use cases and easier implementation. While the current implementations will not change (without flags), such things as extending an `@media` from within an `@media` does nothing, this could possibly change in the future.\n\n#### 'TLDR' Contention with the `@extend` [spec](https://tabatkins.github.io/specs/css-extend-rule):\n\n- **Order of Processing/Specificity** In normal cases, the document is processed top-to-bottom; however, as a feature-fallout of the implementation, it is capable of extending in an anti-pattern (extending things yet to be declared). If what you're writing is an anti-pattern, it will throw a warning.\n- **Specificity Inheritance** [Unlike example 5 in the spec](http://tabatkins.github.io/specs/css-extend-rule/#issue-bd856557), `@extend` in this plugin *will not* maintain the specificity of the rules extended to. Avoiding anti-patterns in your CSS will allow you to avoid this becoming an issue (pending browser implemenation). Does not log a warning.\n- **Media-cross-media Inheritance** Attempting to extend a rule inside a media block from within another media block [is directly disallowed in the code](https://github.com/travco/postcss-extend#extending-something-in-an-media-while-inside-an-media) and will throw a warning.\n- **Silent placeholders** Includes both the stricter `@define-placeholder` and its aliases for compatibility with [simple-extend](https://github.com/davidtheclark/postcss-simple-extend), and the `%` placeholder [from the spec](https://tabatkins.github.io/specs/css-extend-rule/#placeholder). As this isn't the native parser, the placeholder will be wiped from the CSS if it goes unused (as well as throw a warning).\n- **Subclass inheritance** Currently doesn't log a warning for its use, as it is not stated in the spec for or against its behavior (despite it logically following). All [sub classes of an extended \"base\" class are extended](https://github.com/travco/postcss-extend#extending-sub-classes-and-sub-elements), creating subclasses for the extending class as a means of mimicking the inheritance of specific sub-class contingencies (like `:active`)\n- **\"Whiff\" extension** trying to extend something that doesn't exist will log an error, and like everything else, remove the `@extend` rule.\n\n\n##### Originally a fork of davidtheclark's [postcss-simple-extend](https://github.com/davidtheclark/postcss-simple-extend) (extended) by way of the included [MIT License](https://github.com/travco/postcss-extend/blob/master/LICENSE)\n","_attachments":{},"homepage":"https://github.com/travco/postcss-extend","bugs":{"url":"https://github.com/travco/postcss-extend/issues"},"license":"MIT"}