(
parentSelectors: string[],
nodeSelectors: string[],
)
| 200 | const PostcssInst = postcss([]); |
| 201 | |
| 202 | const concatSelectors = ( |
| 203 | parentSelectors: string[], |
| 204 | nodeSelectors: string[], |
| 205 | ): string[] => { |
| 206 | // if parent is AtRule |
| 207 | if (parentSelectors.length === 0) return nodeSelectors; |
| 208 | |
| 209 | return ([] as string[]).concat( |
| 210 | ...parentSelectors.map(ps => |
| 211 | nodeSelectors.map( |
| 212 | /** |
| 213 | * No need to replace for children separated by spaces |
| 214 | * |
| 215 | * .parent { |
| 216 | * color: red; |
| 217 | * |
| 218 | * & .child { |
| 219 | * ^^^^^^^^ no need to do the replace here, |
| 220 | * since no new classnames are created |
| 221 | * color: pink; |
| 222 | * } |
| 223 | * } |
| 224 | */ |
| 225 | s => (/&[a-z0-1-_]/i.test(s) ? s.replace('&', ps) : s), |
| 226 | ), |
| 227 | ), |
| 228 | ); |
| 229 | }; |
| 230 | |
| 231 | function getParentRule(node: Node): undefined | Node { |
| 232 | const {parent} = node; |
no outgoing calls
no test coverage detected