source: trip-planner-front/node_modules/stylus/lib/functions/selectors.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1var nodes = require('../nodes')
2 , Parser = require('../selector-parser');
3
4/**
5 * Return a list with raw selectors parts
6 * of the current group.
7 *
8 * For example:
9 *
10 * .a, .b
11 * .c
12 * .d
13 * test: selectors() // => '.a,.b', '& .c', '& .d'
14 *
15 * @return {Expression}
16 * @api public
17 */
18
19module.exports = function selectors(){
20 var stack = this.selectorStack
21 , expr = new nodes.Expression(true);
22
23 if (stack.length) {
24 for (var i = 0; i < stack.length; i++) {
25 var group = stack[i]
26 , nested;
27
28 if (group.length > 1) {
29 expr.push(new nodes.String(group.map(function(selector) {
30 nested = new Parser(selector.val).parse().nested;
31 return (nested && i ? '& ' : '') + selector.val;
32 }).join(',')))
33 } else {
34 var selector = group[0].val
35 nested = new Parser(selector).parse().nested;
36 expr.push(new nodes.String((nested && i ? '& ' : '') + selector));
37 }
38 }
39 } else {
40 expr.push(new nodes.String('&'));
41 }
42 return expr;
43};
Note: See TracBrowser for help on using the repository browser.