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