source: trip-planner-front/node_modules/stylus/lib/nodes/query-list.js@ 76712b2

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

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1
2/*!
3 * Stylus - QueryList
4 * Copyright (c) Automattic <developer.wordpress.com>
5 * MIT Licensed
6 */
7
8/**
9 * Module dependencies.
10 */
11
12var Node = require('./node');
13
14/**
15 * Initialize a new `QueryList`.
16 *
17 * @api public
18 */
19
20var QueryList = module.exports = function QueryList(){
21 Node.call(this);
22 this.nodes = [];
23};
24
25/**
26 * Inherit from `Node.prototype`.
27 */
28
29QueryList.prototype.__proto__ = Node.prototype;
30
31/**
32 * Return a clone of this node.
33 *
34 * @return {Node}
35 * @api public
36 */
37
38QueryList.prototype.clone = function(parent){
39 var clone = new QueryList;
40 clone.lineno = this.lineno;
41 clone.column = this.column;
42 clone.filename = this.filename;
43 for (var i = 0; i < this.nodes.length; ++i) {
44 clone.push(this.nodes[i].clone(parent, clone));
45 }
46 return clone;
47};
48
49/**
50 * Push the given `node`.
51 *
52 * @param {Node} node
53 * @api public
54 */
55
56QueryList.prototype.push = function(node){
57 this.nodes.push(node);
58};
59
60/**
61 * Merges this query list with the `other`.
62 *
63 * @param {QueryList} other
64 * @return {QueryList}
65 * @api private
66 */
67
68QueryList.prototype.merge = function(other){
69 var list = new QueryList
70 , merged;
71 this.nodes.forEach(function(query){
72 for (var i = 0, len = other.nodes.length; i < len; ++i){
73 merged = query.merge(other.nodes[i]);
74 if (merged) list.push(merged);
75 }
76 });
77 return list;
78};
79
80/**
81 * Return "<a>, <b>, <c>"
82 *
83 * @return {String}
84 * @api public
85 */
86
87QueryList.prototype.toString = function(){
88 return '(' + this.nodes.map(function(node){
89 return node.toString();
90 }).join(', ') + ')';
91};
92
93/**
94 * Return a JSON representation of this node.
95 *
96 * @return {Object}
97 * @api public
98 */
99
100QueryList.prototype.toJSON = function(){
101 return {
102 __type: 'QueryList',
103 nodes: this.nodes,
104 lineno: this.lineno,
105 column: this.column,
106 filename: this.filename
107 };
108};
Note: See TracBrowser for help on using the repository browser.