import.js 1.2 KB

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