This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/postcss-resolve-nested-sele...
cranberry ed23347e56 Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
..
LICENSE Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
README.md Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
index.js Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00
package.json Initial comission of TheLounge base files 2020-11-01 22:46:04 +00:00

README.md

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 youd like to help out by adding some automated tests for those, thatd be swell. In fact, if youd 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']