版博士V2.0程序
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.
 
 
 
 

138 lines
4.0 KiB

  1. import Node from '../node/Node';
  2. import ICharacterData from './ICharacterData';
  3. import IElement from '../element/IElement';
  4. /**
  5. * Character data base class.
  6. *
  7. * Reference:
  8. * https://developer.mozilla.org/en-US/docs/Web/API/CharacterData.
  9. */
  10. export default abstract class CharacterData extends Node implements ICharacterData {
  11. protected _data: string;
  12. /**
  13. * Constructor.
  14. *
  15. * @param [data] Data.
  16. */
  17. constructor(data?: string);
  18. /**
  19. * Returns text content.
  20. *
  21. * @returns Text content.
  22. */
  23. get length(): number;
  24. /**
  25. * Returns text content.
  26. *
  27. * @returns Text content.
  28. */
  29. get data(): string;
  30. /**
  31. * Sets text content.
  32. *
  33. * @param textContent Text content.
  34. */
  35. set data(data: string);
  36. /**
  37. * Returns text content.
  38. *
  39. * @returns Text content.
  40. */
  41. get textContent(): string;
  42. /**
  43. * Sets text content.
  44. *
  45. * @param textContent Text content.
  46. */
  47. set textContent(textContent: string);
  48. /**
  49. * Returns node value.
  50. *
  51. * @returns Node value.
  52. */
  53. get nodeValue(): string;
  54. /**
  55. * Sets node value.
  56. *
  57. * @param nodeValue Node value.
  58. */
  59. set nodeValue(nodeValue: string);
  60. /**
  61. * Previous element sibling.
  62. *
  63. * @returns Element.
  64. */
  65. get previousElementSibling(): IElement;
  66. /**
  67. * Next element sibling.
  68. *
  69. * @returns Element.
  70. */
  71. get nextElementSibling(): IElement;
  72. /**
  73. * Appends the given DOMString to the CharacterData.data string; when this method returns, data contains the concatenated DOMString.
  74. *
  75. * @param data Data.
  76. */
  77. appendData(data: string): void;
  78. /**
  79. * Removes the specified amount of characters, starting at the specified offset, from the CharacterData.data string; when this method returns, data contains the shortened DOMString.
  80. *
  81. * @param offset Offset.
  82. * @param count Count.
  83. */
  84. deleteData(offset: number, count: number): void;
  85. /**
  86. * Inserts the specified characters, at the specified offset, in the CharacterData.data string; when this method returns, data contains the modified DOMString.
  87. *
  88. * @param offset Offset.
  89. * @param data Data.
  90. */
  91. insertData(offset: number, data: string): void;
  92. /**
  93. * Replaces the specified amount of characters, starting at the specified offset, with the specified DOMString; when this method returns, data contains the modified DOMString.
  94. *
  95. * @param offset Offset.
  96. * @param count Count.
  97. * @param data Data.
  98. */
  99. replaceData(offset: number, count: number, data: string): void;
  100. /**
  101. * Returns a DOMString containing the part of CharacterData.data of the specified length and starting at the specified offset.
  102. *
  103. * @param offset Offset.
  104. * @param count Count.
  105. */
  106. substringData(offset: number, count: number): string;
  107. /**
  108. * Removes the object from its parent children list.
  109. */
  110. remove(): void;
  111. /**
  112. * The Node.replaceWith() method replaces this Node in the children list of its parent with a set of Node or DOMString objects.
  113. *
  114. * @param nodes List of Node or DOMString.
  115. */
  116. replaceWith(...nodes: (Node | string)[]): void;
  117. /**
  118. * Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just before this ChildNode. DOMString objects are inserted as equivalent Text nodes.
  119. *
  120. * @param nodes List of Node or DOMString.
  121. */
  122. before(...nodes: (string | Node)[]): void;
  123. /**
  124. * Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just after this ChildNode. DOMString objects are inserted as equivalent Text nodes.
  125. *
  126. * @param nodes List of Node or DOMString.
  127. */
  128. after(...nodes: (string | Node)[]): void;
  129. /**
  130. * Clones a node.
  131. *
  132. * @override
  133. * @param [deep=false] "true" to clone deep.
  134. * @returns Cloned node.
  135. */
  136. cloneNode(deep?: boolean): ICharacterData;
  137. }