Node.d.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import { EventTarget } from './EventTarget';
  2. import type { IChildNode, IDocument, IElement, IEventTarget, INode, IParentNode } from './interfaces';
  3. /**
  4. * @see https://developer.mozilla.org/en-US/docs/Web/API/Node
  5. */
  6. export declare abstract class Node extends EventTarget implements INode {
  7. /**
  8. * Both nodes are in different documents or different trees in the same document.
  9. */
  10. static DOCUMENT_POSITION_DISCONNECTED: number;
  11. /**
  12. * otherNode precedes the node in either a pre-order depth-first traversal
  13. * of a tree containing both (e.g., as an ancestor or previous sibling or a descendant of a previous sibling or previous sibling of an ancestor) or (if they are disconnected) in an arbitrary but consistent ordering.
  14. */
  15. static DOCUMENT_POSITION_PRECEDING: number;
  16. /**
  17. * otherNode follows the node in either a pre-order depth-first traversal of a tree containing both (e.g., as a descendant or following sibling or a descendant of a following sibling or following sibling of an ancestor) or (if they are disconnected) in an arbitrary but consistent ordering.
  18. */
  19. static DOCUMENT_POSITION_FOLLOWING: number;
  20. /**
  21. * otherNode is an ancestor of the node.
  22. */
  23. static DOCUMENT_POSITION_CONTAINS: number;
  24. /**
  25. * otherNode is a descendant of the node.
  26. */
  27. static DOCUMENT_POSITION_CONTAINED_BY: number;
  28. /**
  29. * The result relies upon arbitrary and/or implementation-specific behavior and is not guaranteed to be portable.
  30. */
  31. static DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number;
  32. static isNode(target: IEventTarget | INode): target is INode;
  33. shadow: boolean;
  34. /**
  35. * points to canvas.document
  36. * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/ownerDocument
  37. */
  38. ownerDocument: IDocument | null;
  39. /**
  40. * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/isConnected
  41. * @example
  42. circle.isConnected; // false
  43. canvas.appendChild(circle);
  44. circle.isConnected; // true
  45. */
  46. isConnected: boolean;
  47. /**
  48. * Returns node's node document's document base URL.
  49. * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node
  50. */
  51. readonly baseURI: string;
  52. /**
  53. * Returns the children.
  54. * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes
  55. */
  56. childNodes: IChildNode[];
  57. /**
  58. * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeType
  59. */
  60. nodeType: number;
  61. /**
  62. * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeName
  63. */
  64. nodeName: string;
  65. /**
  66. * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeValue
  67. */
  68. nodeValue: string | null;
  69. /**
  70. * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/textContent
  71. */
  72. get textContent(): string;
  73. set textContent(content: string);
  74. /**
  75. * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/getRootNode
  76. */
  77. getRootNode(opts?: {
  78. composed?: boolean;
  79. }): INode;
  80. hasChildNodes(): boolean;
  81. isDefaultNamespace(namespace: string | null): boolean;
  82. lookupNamespaceURI(prefix: string | null): string | null;
  83. lookupPrefix(namespace: string | null): string | null;
  84. normalize(): void;
  85. /**
  86. * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/isEqualNode
  87. */
  88. isEqualNode(otherNode: INode | null): boolean;
  89. isSameNode(otherNode: INode | null): boolean;
  90. /**
  91. * @see https://developer.mozilla.org/en-US/docs/Web/API/ParentNode
  92. */
  93. parentNode: (INode & IParentNode) | null;
  94. /**
  95. * @deprecated
  96. * @alias parentNode
  97. */
  98. get parent(): INode | null;
  99. get parentElement(): IElement | null;
  100. get nextSibling(): IChildNode | null;
  101. get previousSibling(): IChildNode | null;
  102. get firstChild(): IChildNode | null;
  103. get lastChild(): IChildNode | null;
  104. /**
  105. * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
  106. * @see https://github.com/b-fuze/deno-dom/blob/master/src/dom/node.ts#L338
  107. */
  108. compareDocumentPosition(other: INode): number;
  109. /**
  110. * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode
  111. */
  112. abstract cloneNode(deep?: boolean): this;
  113. /**
  114. * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
  115. */
  116. abstract appendChild<T extends INode>(newChild: T, index?: number): T;
  117. /**
  118. * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore
  119. */
  120. abstract insertBefore<T extends INode>(newChild: T, refChild: INode | null): T;
  121. /**
  122. * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild
  123. */
  124. abstract removeChild<T extends INode>(child: T): T;
  125. /**
  126. * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/replaceChild
  127. */
  128. abstract replaceChild<T extends INode>(newChild: INode, oldChild: T): T;
  129. abstract destroy(): void;
  130. /**
  131. * @deprecated
  132. * @alias contains
  133. */
  134. contain<T extends INode>(other: T | null): boolean;
  135. contains<T extends INode>(other: T | null): boolean;
  136. getAncestor(n: number): INode | null;
  137. forEach(callback: (o: INode) => void | boolean, assigned?: boolean): void;
  138. }
  139. //# sourceMappingURL=Node.d.ts.map