extend.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*!
  2. * Stylus - Extend
  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 `Extend` with the given `selectors` array.
  12. *
  13. * @param {Array} selectors array of the selectors
  14. * @api public
  15. */
  16. var Extend = module.exports = function Extend(selectors){
  17. Node.call(this);
  18. this.selectors = selectors;
  19. };
  20. /**
  21. * Inherit from `Node.prototype`.
  22. */
  23. Extend.prototype.__proto__ = Node.prototype;
  24. /**
  25. * Return a clone of this node.
  26. *
  27. * @return {Node}
  28. * @api public
  29. */
  30. Extend.prototype.clone = function(){
  31. return new Extend(this.selectors);
  32. };
  33. /**
  34. * Return `@extend selectors`.
  35. *
  36. * @return {String}
  37. * @api public
  38. */
  39. Extend.prototype.toString = function(){
  40. return '@extend ' + this.selectors.join(', ');
  41. };
  42. /**
  43. * Return a JSON representation of this node.
  44. *
  45. * @return {Object}
  46. * @api public
  47. */
  48. Extend.prototype.toJSON = function(){
  49. return {
  50. __type: 'Extend',
  51. selectors: this.selectors,
  52. lineno: this.lineno,
  53. column: this.column,
  54. filename: this.filename
  55. };
  56. };