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