mirror-rhinstaller-node-cache/postcss-resolve-nested-selector
2026-07-29 11:17:32 +00:00
..
CHANGELOG.md e70823e4e1d9a96103445df8a444afc74aecb88ec97af898277d6e59ac07ae32 package.json 2026-07-29 11:17:32 +00:00
index.js e70823e4e1d9a96103445df8a444afc74aecb88ec97af898277d6e59ac07ae32 package.json 2026-07-29 11:17:32 +00:00
LICENSE e70823e4e1d9a96103445df8a444afc74aecb88ec97af898277d6e59ac07ae32 package.json 2026-07-29 11:17:32 +00:00
package.json e70823e4e1d9a96103445df8a444afc74aecb88ec97af898277d6e59ac07ae32 package.json 2026-07-29 11:17:32 +00:00
README.md e70823e4e1d9a96103445df8a444afc74aecb88ec97af898277d6e59ac07ae32 package.json 2026-07-29 11:17:32 +00:00

postcss-resolve-nested-selector

test

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

Tested to work with the syntax of postcss-nested. 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!

If you want to resolve selectors in the same style as postcss-nesting you should instead use selector-resolve-nested

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']