epiphany/node_modules/postcss-resolve-nested-selector
2023-12-09 22:48:07 -08:00
..
index.js stylelint/eleventy config 2023-12-09 22:48:07 -08:00
LICENSE stylelint/eleventy config 2023-12-09 22:48:07 -08:00
package.json stylelint/eleventy config 2023-12-09 22:48:07 -08:00
README.md stylelint/eleventy config 2023-12-09 22:48:07 -08:00

postcss-resolve-nested-selector

Build Status

Given a (nested) selector in a PostCSS AST, return an array of resolved selectors.

Tested to work with the syntax of postcss-nested and postcss-nesting. Should also work with SCSS and Less syntax. If you'd like to help out by adding some automated tests for those, that'd be swell. In fact, if you'd like to add any automated tests, you are a winner!

API

resolveNestedSelector(selector, node)

Returns an array of selectors resolved from selector.

For example, given this JS:

var resolvedNestedSelector = require('postcss-resolve-nested-selector');
postcssRoot.eachRule(function(rule) {
  rule.selectors.forEach(function(selector) {
    console.log(resolvedNestedSelector(selector, rule));
  });
});

And the following CSS:

.foo {
  .bar {
    color: pink;
  }
}

This should log:

['.foo']
['.foo .bar']

Or with this CSS:

.foo {
  .bar &,
  a {
    color: pink;
  }
}

This should log:

['.foo']
['.bar .foo']
['.foo a']