Skip to content

Commit 489a8a0

Browse files
author
Jed Mao
committed
Simplify logic
1 parent 5e5f737 commit 489a8a0

File tree

5 files changed

+9
-12
lines changed

5 files changed

+9
-12
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# postcss-nested-props
22

33
<img align="right" width="135" height="95"
4-
title="Philosopher’s stone, logo of PostCSS"
4+
title="Philosopher’s stone, logo of PostCSS"
55
src="http://postcss.github.io/postcss/logo-leftp.png">
66

77
[![Build Status](https://travis-ci.org/jedmao/postcss-nested-props.svg?branch=master)](https://travis-ci.org/jedmao/postcss-nested-props)
@@ -16,7 +16,7 @@
1616

1717
## Nested Properties
1818

19-
CSS has quite a few properties that are in “namespaces;” for instance, `font-family`, `font-size`, and `font-weight` are all in the `font` namespace. In CSS, if you want to set a bunch of properties in the same namespace, you have to type it out each time. This plugin provides a shortcut: just write the namespace once, then nest each of the sub-properties within it. For example:
19+
CSS has quite a few properties that are in “namespaces;” for instance, `font-family`, `font-size`, and `font-weight` are all in the `font` namespace. In CSS, if you want to set a bunch of properties in the same namespace, you have to type it out each time. This plugin provides a shortcut: just write the namespace once, then nest each of the sub-properties within it. For example:
2020

2121
```scss
2222
.funky {
@@ -57,7 +57,7 @@ is compiled to:
5757
}
5858
```
5959

60-
For nested rules, use the [`postcss-nested`](https://github.com/postcss/postcss-nested) plugin.
60+
For nested rules, use the [`postcss-nested`](https://github.com/postcss/postcss-nested) plugin, but make sure to run it **AFTER** this one.
6161

6262
## Installation
6363

js/plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function unwrapRule(namespace, rule) {
4141
break;
4242
}
4343
});
44-
rule.each(function (node) {
45-
node.moveBefore(rule);
44+
rule.eachDecl(function (decl) {
45+
decl.moveBefore(rule);
4646
});
4747
rule.removeSelf();
4848
namespace.pop();

lib/plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var PostCssNestedProps = postcss.plugin(
1414
});
1515
};
1616
}
17-
);
17+
);
1818

1919
var HAS_COLON = /:/;
2020
var ALL_PSEUDO = pseudoClasses().concat(pseudoElements());
@@ -47,8 +47,8 @@ function unwrapRule(namespace: string[], rule: any) {
4747
break;
4848
}
4949
});
50-
rule.each(node => {
51-
node.moveBefore(rule);
50+
rule.eachDecl(decl => {
51+
decl.moveBefore(rule);
5252
});
5353
rule.removeSelf();
5454
namespace.pop();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcss-nested-props",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "PostCSS plugin to unwrap nested properties.",
55
"main": "js/plugin.js",
66
"scripts": {

postcss-nested-props.DotSettings

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)