diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:38:48 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 21:53:09 +0800 |
| commit | 26105034da4fcce7ac883c899d781f016559310d (patch) | |
| tree | c459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/stylus/lib/nodes/group.js | |
| parent | 2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff) | |
| download | xmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip | |
switch to vuepress
Diffstat (limited to 'node_modules/stylus/lib/nodes/group.js')
| -rw-r--r-- | node_modules/stylus/lib/nodes/group.js | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/node_modules/stylus/lib/nodes/group.js b/node_modules/stylus/lib/nodes/group.js new file mode 100644 index 00000000..8c1a4ea3 --- /dev/null +++ b/node_modules/stylus/lib/nodes/group.js @@ -0,0 +1,110 @@ + +/*! + * Stylus - Group + * Copyright (c) Automattic <developer.wordpress.com> + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var Node = require('./node'); + +/** + * Initialize a new `Group`. + * + * @api public + */ + +var Group = module.exports = function Group(){ + Node.call(this); + this.nodes = []; + this.extends = []; +}; + +/** + * Inherit from `Node.prototype`. + */ + +Group.prototype.__proto__ = Node.prototype; + +/** + * Push the given `selector` node. + * + * @param {Selector} selector + * @api public + */ + +Group.prototype.push = function(selector){ + this.nodes.push(selector); +}; + +/** + * Return this set's `Block`. + */ + +Group.prototype.__defineGetter__('block', function(){ + return this.nodes[0].block; +}); + +/** + * Assign `block` to each selector in this set. + * + * @param {Block} block + * @api public + */ + +Group.prototype.__defineSetter__('block', function(block){ + for (var i = 0, len = this.nodes.length; i < len; ++i) { + this.nodes[i].block = block; + } +}); + +/** + * Check if this set has only placeholders. + * + * @return {Boolean} + * @api public + */ + +Group.prototype.__defineGetter__('hasOnlyPlaceholders', function(){ + return this.nodes.every(function(selector) { return selector.isPlaceholder; }); +}); + +/** + * Return a clone of this node. + * + * @return {Node} + * @api public + */ + +Group.prototype.clone = function(parent){ + var clone = new Group; + clone.lineno = this.lineno; + clone.column = this.column; + this.nodes.forEach(function(node){ + clone.push(node.clone(parent, clone)); + }); + clone.filename = this.filename; + clone.block = this.block.clone(parent, clone); + return clone; +}; + +/** + * Return a JSON representation of this node. + * + * @return {Object} + * @api public + */ + +Group.prototype.toJSON = function(){ + return { + __type: 'Group', + nodes: this.nodes, + block: this.block, + lineno: this.lineno, + column: this.column, + filename: this.filename + }; +}; |
