text.js

  1. 'use strict'
  2. /**
  3. * @class
  4. * @memberof node-html-light
  5. */
  6. class Text {
  7. /**
  8. * Creates a new text node
  9. * @param {string} string
  10. * @returns {Text} a new Text node
  11. */
  12. static of(string) {
  13. return new Text(string)
  14. }
  15. /**
  16. * @constructor
  17. * @param {string} text
  18. * @returns {Text} a new Text node
  19. */
  20. constructor(text) {
  21. this._element = {
  22. type: 'text',
  23. data: text,
  24. next: null,
  25. prev: null,
  26. parent: null
  27. }
  28. }
  29. get() {
  30. return this._element
  31. }
  32. }
  33. module.exports = Text