|
13 | 13 | - [API](#api)
|
14 | 14 | - [isShorthandProperty(property: string): boolean](#isshorthandpropertyproperty-string-boolean)
|
15 | 15 | - [Examples](#examples)
|
16 |
| - - [[Experimental] isValidDeclaration(property: string, value: string): boolean](#experimental-isvaliddeclarationproperty-string-value-string-boolean) |
| 16 | + - [[Experimental] [isValidDeclaration(property: string, value: string): boolean](./src/isValidDeclaration.js)](#experimental-isvaliddeclarationproperty-string-value-string-booleansrcisvaliddeclarationjs) |
17 | 17 | - [Examples](#examples-1)
|
18 |
| - - [getShorthandComputedProperties(property: string): Array](#getshorthandcomputedpropertiesproperty-string-array) |
| 18 | + - [getShorthandComputedProperties(property: string, [recursivelyResolve=false]): Array](#getshorthandcomputedpropertiesproperty-string-recursivelyresolvefalse-array) |
19 | 19 | - [Examples](#examples-2)
|
20 |
| - - [expandShorthandProperty(property: string, value: string, [recursivelyResolve=false]): Object](#expandshorthandpropertyproperty-string-value-string-recursivelyresolvetrue-object) |
| 20 | + - [expandShorthandProperty(property: string, value: string, [recursivelyResolve=false]): Object](#expandshorthandpropertyproperty-string-value-string-recursivelyresolvefalse-object) |
21 | 21 | - [Examples](#examples-3)
|
| 22 | + - [Developer/Contribution HOWTO](#developercontribution-howto) |
22 | 23 |
|
23 | 24 | <!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
24 | 25 |
|
|
30 | 31 |
|
31 | 32 | ## Installation
|
32 | 33 | ```
|
33 |
| -$ npm instal css-property-parser |
| 34 | +$ npm install css-property-parser |
34 | 35 | ```
|
35 | 36 |
|
36 | 37 | ## Usage
|
@@ -142,35 +143,57 @@ isValidDeclaration('width', '300ms')
|
142 | 143 | // => false ('ms' is not a valid length unit)
|
143 | 144 | ```
|
144 | 145 |
|
145 |
| -### [getShorthandComputedProperties(property: string): Array](./src/getShorthandComputedProperties.js) |
| 146 | +### [getShorthandComputedProperties(property: string, [recursivelyResolve=false]): Array](./src/getShorthandComputedProperties.js) |
146 | 147 | Given a shorthand property, returns an array of the computed properties for that shorthand property. If given
|
147 | 148 | a known property that is not a shorthand, simply returns the given property. If given an unknown property,
|
148 | 149 | returns an empty array.
|
149 | 150 |
|
150 | 151 | * shorthandProperty - the shorthand property name. For example, "background" or "border".
|
| 152 | + * [recursivelyResolve=false] - recursively resolve additional longhand properties if the shorthands expand to additional shorthands. For example, the border property expands to border-width, which expands further to border-left-width, border-right-width, etc. |
151 | 153 | * returns an array containing the computed properties for the given shorthand property. Returns an empty array if the given property is not a valid property.
|
152 | 154 |
|
153 | 155 | ##### Examples
|
154 | 156 |
|
155 | 157 | ```js
|
156 | 158 | getShorthandComputedProperties('background');
|
157 |
| - // -> [ |
158 |
| - // "background-image", |
159 |
| - // "background-position", |
160 |
| - // "background-size", |
161 |
| - // "background-repeat", |
162 |
| - // "background-origin", |
163 |
| - // "background-clip", |
164 |
| - // "background-attachment", |
165 |
| - // "background-color" |
166 |
| - // ] |
| 159 | +// -> [ |
| 160 | +// "background-image", |
| 161 | +// "background-position", |
| 162 | +// "background-size", |
| 163 | +// "background-repeat", |
| 164 | +// "background-origin", |
| 165 | +// "background-clip", |
| 166 | +// "background-attachment", |
| 167 | +// "background-color" |
| 168 | +// ] |
167 | 169 | ```
|
168 | 170 |
|
169 | 171 | ```js
|
170 | 172 | getShorthandComputedProperties('color');
|
171 | 173 | // -> ["color"]
|
172 | 174 | ```
|
173 | 175 |
|
| 176 | +```js |
| 177 | +getShorthandComputedProperties('border', true); |
| 178 | +// -> [ |
| 179 | +// 'border-width', |
| 180 | +// 'border-style', |
| 181 | +// 'border-color', |
| 182 | +// 'border-bottom-width', |
| 183 | +// 'border-left-width', |
| 184 | +// 'border-right-width', |
| 185 | +// 'border-top-width', |
| 186 | +// 'border-bottom-style', |
| 187 | +// 'border-left-style', |
| 188 | +// 'border-right-style', |
| 189 | +// 'border-top-style', |
| 190 | +// 'border-bottom-color', |
| 191 | +// 'border-left-color', |
| 192 | +// 'border-right-color', |
| 193 | +// 'border-top-color' |
| 194 | +// ]; |
| 195 | +``` |
| 196 | + |
174 | 197 | ```js
|
175 | 198 | getShorthandComputedProperties('unknownProperty');
|
176 | 199 | // -> []
|
|
0 commit comments