Last change
on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[6a3a178] | 1 |
|
---|
| 2 | /*!
|
---|
| 3 | * Stylus - Each
|
---|
| 4 | * Copyright (c) Automattic <developer.wordpress.com>
|
---|
| 5 | * MIT Licensed
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | /**
|
---|
| 9 | * Module dependencies.
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 | var Node = require('./node')
|
---|
| 13 | , nodes = require('./');
|
---|
| 14 |
|
---|
| 15 | /**
|
---|
| 16 | * Initialize a new `Each` node with the given `val` name,
|
---|
| 17 | * `key` name, `expr`, and `block`.
|
---|
| 18 | *
|
---|
| 19 | * @param {String} val
|
---|
| 20 | * @param {String} key
|
---|
| 21 | * @param {Expression} expr
|
---|
| 22 | * @param {Block} block
|
---|
| 23 | * @api public
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | var Each = module.exports = function Each(val, key, expr, block){
|
---|
| 27 | Node.call(this);
|
---|
| 28 | this.val = val;
|
---|
| 29 | this.key = key;
|
---|
| 30 | this.expr = expr;
|
---|
| 31 | this.block = block;
|
---|
| 32 | };
|
---|
| 33 |
|
---|
| 34 | /**
|
---|
| 35 | * Inherit from `Node.prototype`.
|
---|
| 36 | */
|
---|
| 37 |
|
---|
| 38 | Each.prototype.__proto__ = Node.prototype;
|
---|
| 39 |
|
---|
| 40 | /**
|
---|
| 41 | * Return a clone of this node.
|
---|
| 42 | *
|
---|
| 43 | * @return {Node}
|
---|
| 44 | * @api public
|
---|
| 45 | */
|
---|
| 46 |
|
---|
| 47 | Each.prototype.clone = function(parent){
|
---|
| 48 | var clone = new Each(this.val, this.key);
|
---|
| 49 | clone.expr = this.expr.clone(parent, clone);
|
---|
| 50 | clone.block = this.block.clone(parent, clone);
|
---|
| 51 | clone.lineno = this.lineno;
|
---|
| 52 | clone.column = this.column;
|
---|
| 53 | clone.filename = this.filename;
|
---|
| 54 | return clone;
|
---|
| 55 | };
|
---|
| 56 |
|
---|
| 57 | /**
|
---|
| 58 | * Return a JSON representation of this node.
|
---|
| 59 | *
|
---|
| 60 | * @return {Object}
|
---|
| 61 | * @api public
|
---|
| 62 | */
|
---|
| 63 |
|
---|
| 64 | Each.prototype.toJSON = function(){
|
---|
| 65 | return {
|
---|
| 66 | __type: 'Each',
|
---|
| 67 | val: this.val,
|
---|
| 68 | key: this.key,
|
---|
| 69 | expr: this.expr,
|
---|
| 70 | block: this.block,
|
---|
| 71 | lineno: this.lineno,
|
---|
| 72 | column: this.column,
|
---|
| 73 | filename: this.filename
|
---|
| 74 | };
|
---|
| 75 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.