atblock.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*!
  2. * Stylus - @block
  3. * Copyright (c) Automattic <developer.wordpress.com>
  4. * MIT Licensed
  5. */
  6. /**
  7. * Module dependencies.
  8. */
  9. var Node = require('./node');
  10. /**
  11. * Initialize a new `@block` node.
  12. *
  13. * @api public
  14. */
  15. var Atblock = module.exports = function Atblock(){
  16. Node.call(this);
  17. };
  18. /**
  19. * Return `block` nodes.
  20. */
  21. Atblock.prototype.__defineGetter__('nodes', function(){
  22. return this.block.nodes;
  23. });
  24. /**
  25. * Inherit from `Node.prototype`.
  26. */
  27. Atblock.prototype.__proto__ = Node.prototype;
  28. /**
  29. * Return a clone of this node.
  30. *
  31. * @return {Node}
  32. * @api public
  33. */
  34. Atblock.prototype.clone = function(parent){
  35. var clone = new Atblock;
  36. clone.block = this.block.clone(parent, clone);
  37. clone.lineno = this.lineno;
  38. clone.column = this.column;
  39. clone.filename = this.filename;
  40. return clone;
  41. };
  42. /**
  43. * Return @block.
  44. *
  45. * @return {String}
  46. * @api public
  47. */
  48. Atblock.prototype.toString = function(){
  49. return '@block';
  50. };
  51. /**
  52. * Return a JSON representation of this node.
  53. *
  54. * @return {Object}
  55. * @api public
  56. */
  57. Atblock.prototype.toJSON = function(){
  58. return {
  59. __type: 'Atblock',
  60. block: this.block,
  61. lineno: this.lineno,
  62. column: this.column,
  63. fileno: this.fileno
  64. };
  65. };