Sha256: 57706f1f9f32fb92ecc70914efedc63907ce32c087ff6d70dc395ff386df3ace

Contents?: true

Size: 1.02 KB

Versions: 41

Compression:

Stored size: 1.02 KB

Contents

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;
};

Version data entries

41 entries across 22 versions & 3 rubygems

Version Path
epuber-stylus-source-0.56.0 vendor/lib/functions/selectors.js
epuber-stylus-source-0.54.8 vendor/lib/functions/selectors.js
ela-4.1.6 node_modules/nib/node_modules/stylus/lib/functions/selectors.js
ela-4.1.6 node_modules/stylus/lib/functions/selectors.js
ela-4.1.5 node_modules/nib/node_modules/stylus/lib/functions/selectors.js
ela-4.1.5 node_modules/stylus/lib/functions/selectors.js
ela-4.1.4 node_modules/nib/node_modules/stylus/lib/functions/selectors.js
ela-4.1.4 node_modules/stylus/lib/functions/selectors.js
ela-4.1.3 node_modules/stylus/lib/functions/selectors.js
ela-4.1.3 node_modules/nib/node_modules/stylus/lib/functions/selectors.js
ela-4.1.2 node_modules/stylus/lib/functions/selectors.js
ela-4.1.2 node_modules/nib/node_modules/stylus/lib/functions/selectors.js
ela-4.1.1 node_modules/nib/node_modules/stylus/lib/functions/selectors.js
ela-4.1.1 node_modules/stylus/lib/functions/selectors.js
ela-4.1.0 node_modules/nib/node_modules/stylus/lib/functions/selectors.js
ela-4.1.0 node_modules/stylus/lib/functions/selectors.js
ela-4.0.0 node_modules/stylus/lib/functions/selectors.js
ela-4.0.0 node_modules/nib/node_modules/stylus/lib/functions/selectors.js
ela-3.4.3 node_modules/nib/node_modules/stylus/lib/functions/selectors.js
ela-3.4.3 node_modules/stylus/lib/functions/selectors.js