You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.1 KiB

  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. var __importDefault = (this && this.__importDefault) || function (mod) {
  16. return (mod && mod.__esModule) ? mod : { "default": mod };
  17. };
  18. Object.defineProperty(exports, "__esModule", { value: true });
  19. var type_1 = __importDefault(require("./type"));
  20. var node_1 = __importDefault(require("./node"));
  21. /**
  22. * TextNode to contain a text element in DOM tree.
  23. * @param {string} value [description]
  24. */
  25. var TextNode = /** @class */ (function (_super) {
  26. __extends(TextNode, _super);
  27. function TextNode(rawText) {
  28. var _this = _super.call(this) || this;
  29. _this.rawText = rawText;
  30. /**
  31. * Node Type declaration.
  32. * @type {Number}
  33. */
  34. _this.nodeType = type_1.default.TEXT_NODE;
  35. return _this;
  36. }
  37. Object.defineProperty(TextNode.prototype, "text", {
  38. /**
  39. * Get unescaped text value of current node and its children.
  40. * @return {string} text content
  41. */
  42. get: function () {
  43. return this.rawText;
  44. },
  45. enumerable: false,
  46. configurable: true
  47. });
  48. Object.defineProperty(TextNode.prototype, "isWhitespace", {
  49. /**
  50. * Detect if the node contains only white space.
  51. * @return {bool}
  52. */
  53. get: function () {
  54. return /^(\s| )*$/.test(this.rawText);
  55. },
  56. enumerable: false,
  57. configurable: true
  58. });
  59. TextNode.prototype.toString = function () {
  60. return this.text;
  61. };
  62. return TextNode;
  63. }(node_1.default));
  64. exports.default = TextNode;