supports.js 1.3 KB

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