Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 126ad55

Browse files
committed
1.0.1
1 parent 3605b5f commit 126ad55

File tree

3 files changed

+53
-10
lines changed

3 files changed

+53
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changes to PostCSS Short Overflow
22

3+
### 1.0.1 (October 9, 2018)
4+
5+
- Fixed: Missing `skip` token
6+
- Updated documentation
7+
38
### 1.0.0 (October 9, 2018)
49

510
- Initial version

README.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,47 @@ postcss([
6464

6565
#### prefix
6666

67-
The `prefix` option determines the prefix applied to properties being processed
68-
(e.g. `x` for `-x-overflow`). Wrapping dashes (`-`) are automatically
69-
applied.
67+
The `prefix` option defines a prefix required by properties being transformed.
68+
Wrapping dashes are automatically applied, so that `x` would transform
69+
`-x-overflow`.
70+
71+
```js
72+
postcssShortOverflow({ prefix: 'x' });
73+
```
74+
75+
```pcss
76+
html {
77+
-x-overflow: hidden auto;
78+
}
79+
80+
/* becomes */
81+
82+
html {
83+
overflow-x: hidden;
84+
overflow-y: auto;
85+
}
86+
```
87+
88+
#### skip
89+
90+
The `skip` option defines the skip token used to ignore portions of the
91+
shorthand.
92+
93+
```js
94+
postcssShortOverflow({ skip: '-' });
95+
```
96+
97+
```pcss
98+
[contenteditable] {
99+
overflow: - auto;
100+
}
101+
102+
/* becomes */
103+
104+
[contenteditable] {
105+
overflow-y: auto;
106+
}
107+
```
70108

71109
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-short-overflow.svg
72110
[cli-url]: https://travis-ci.org/jonathantneal/postcss-short-overflow

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
import postcss from 'postcss';
22

33
export default postcss.plugin('postcss-short-overflow', opts => {
4-
// get the dashed prefix
54
const prefix = 'prefix' in Object(opts) ? `-${opts.prefix}-` : '';
5+
const skip = 'skip' in Object(opts) ? String(opts.skip) : '*';
66

77
// get the (conditionally prefixed) property pattern
8-
const propertyRegExp = new RegExp(`^${prefix}(overflow)$`);
8+
const overflowPropertyRegExp = new RegExp(`^${prefix}(overflow)$`);
99

1010
return root => {
1111
// walk each matching declaration
12-
root.walkDecls(propertyRegExp, decl => {
12+
root.walkDecls(overflowPropertyRegExp, decl => {
1313
// conditionally remove the prefix from the property
14-
const [, property] = decl.prop.match(propertyRegExp);
14+
const [, property] = decl.prop.match(overflowPropertyRegExp);
1515

1616
if (prefix) {
1717
decl.prop = property;
1818
}
1919

2020
// conditionally update multiple overflow values
21-
var [overflowX, overflowY] = postcss.list.space(decl.value);
21+
const [overflowX, overflowY] = postcss.list.space(decl.value);
2222

2323
if (overflowY) {
24-
if (overflowX !== '*') {
24+
if (overflowX !== skip) {
2525
decl.cloneBefore({ prop: 'overflow-x', value: overflowX });
2626
}
2727

28-
if (overflowY !== '*') {
28+
if (overflowY !== skip) {
2929
decl.cloneBefore({ prop: 'overflow-y', value: overflowY });
3030
}
3131

0 commit comments

Comments
 (0)