Sha256: 31fe16fc1f62e24f33bacc17ef26bf181a33bc5462407965ed404bd0637079ae

Contents?: true

Size: 769 Bytes

Versions: 41

Compression:

Stored size: 769 Bytes

Contents

var utils = require('../utils')
  , nodes = require('../nodes');

/**
 * Add property `name` with the given `expr`
 * to the mixin-able block.
 *
 * @param {String|Ident|Literal} name
 * @param {Expression} expr
 * @return {Property}
 * @api public
 */

(module.exports = function addProperty(name, expr){
  utils.assertType(name, 'expression', 'name');
  name = utils.unwrap(name).first;
  utils.assertString(name, 'name');
  utils.assertType(expr, 'expression', 'expr');
  var prop = new nodes.Property([name], expr);
  var block = this.closestBlock;

  var len = block.nodes.length
    , head = block.nodes.slice(0, block.index)
    , tail = block.nodes.slice(block.index++, len);
  head.push(prop);
  block.nodes = head.concat(tail);

  return prop;
}).raw = true;

Version data entries

41 entries across 22 versions & 3 rubygems

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