comment.js 578 B

1234567891011121314151617181920212223
  1. import Node from './node';
  2. import NodeType from './type';
  3. export default class CommentNode extends Node {
  4. constructor(rawText, parentNode) {
  5. super(parentNode);
  6. this.rawText = rawText;
  7. /**
  8. * Node Type declaration.
  9. * @type {Number}
  10. */
  11. this.nodeType = NodeType.COMMENT_NODE;
  12. }
  13. /**
  14. * Get unescaped text value of current node and its children.
  15. * @return {string} text content
  16. */
  17. get text() {
  18. return this.rawText;
  19. }
  20. toString() {
  21. return `<!--${this.rawText}-->`;
  22. }
  23. }