This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/stylus/lib/functions/selectors.js

44 lines
1 KiB
JavaScript
Raw Normal View History

2019-08-11 18:48:02 +00:00
var nodes = require('../nodes')
, Parser = require('../selector-parser');
/**
* Return a list with raw selectors parts
* of the current group.
*
* For example:
*
* .a, .b
* .c
* .d
* test: selectors() // => '.a,.b', '& .c', '& .d'
*
* @return {Expression}
* @api public
*/
module.exports = function selectors(){
var stack = this.selectorStack
, expr = new nodes.Expression(true);
if (stack.length) {
for (var i = 0; i < stack.length; i++) {
var group = stack[i]
, nested;
if (group.length > 1) {
expr.push(new nodes.String(group.map(function(selector) {
nested = new Parser(selector.val).parse().nested;
return (nested && i ? '& ' : '') + selector.val;
}).join(',')))
} else {
var selector = group[0].val
nested = new Parser(selector).parse().nested;
expr.push(new nodes.String((nested && i ? '& ' : '') + selector));
}
}
} else {
expr.push(new nodes.String('&'));
}
return expr;
};