版博士V2.0程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

68 řádky
2.1 KiB

  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const Node_1 = __importDefault(require("../node/Node"));
  7. const CharacterData_1 = __importDefault(require("../character-data/CharacterData"));
  8. const DOMException_1 = __importDefault(require("../../exception/DOMException"));
  9. const DOMExceptionNameEnum_1 = __importDefault(require("../../exception/DOMExceptionNameEnum"));
  10. /**
  11. * Text node.
  12. */
  13. class Text extends CharacterData_1.default {
  14. constructor() {
  15. super(...arguments);
  16. this.nodeType = Node_1.default.TEXT_NODE;
  17. }
  18. /**
  19. * Node name.
  20. *
  21. * @returns Node name.
  22. */
  23. get nodeName() {
  24. return '#text';
  25. }
  26. /**
  27. * Breaks the Text node into two nodes at the specified offset, keeping both nodes in the tree as siblings.
  28. *
  29. * @see https://dom.spec.whatwg.org/#dom-text-splittext
  30. * @see https://dom.spec.whatwg.org/#dom-text-splittext
  31. * @param offset Offset.
  32. * @returns New text node.
  33. */
  34. splitText(offset) {
  35. const length = this._data.length;
  36. if (offset > length) {
  37. new DOMException_1.default('The index is not in the allowed range.', DOMExceptionNameEnum_1.default.indexSizeError);
  38. }
  39. const count = length - offset;
  40. const newData = this.substringData(offset, count);
  41. const newNode = this.ownerDocument.createTextNode(newData);
  42. if (this.parentNode !== null) {
  43. this.parentNode.insertBefore(newNode, this.nextSibling);
  44. }
  45. this.replaceData(offset, count, '');
  46. return newNode;
  47. }
  48. /**
  49. * Converts to string.
  50. *
  51. * @returns String.
  52. */
  53. toString() {
  54. return '[object Text]';
  55. }
  56. /**
  57. * Clones a node.
  58. *
  59. * @override
  60. * @param [deep=false] "true" to clone deep.
  61. * @returns Cloned node.
  62. */
  63. cloneNode(deep = false) {
  64. return super.cloneNode(deep);
  65. }
  66. }
  67. exports.default = Text;
  68. //# sourceMappingURL=Text.js.map