-
Notifications
You must be signed in to change notification settings - Fork 29.9k
/
index.d.ts
127 lines (126 loc) · 4.97 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Type definitions for domutils 1.7
// Project: https://github.com/FB55/domutils#readme
// Definitions by: Johan Davidsson <https://github.com/johandavidson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
import { DomElement } from "domhandler";
/***
* Append an element after another
*
* @argument elem The element to append to
* @argument next The element be added
*/
export function append(elem: DomElement, next: DomElement): void;
/***
* Append a child to an element
*
* @argument elem The element to append to
* @argument child The element to be added as a child
*/
export function appendChild(elem: DomElement, child: DomElement): void;
/***
* Compare the position of one node against another node in any other document.
* The return value is a bitmask with the following values:
*
* document order:
* > There is an ordering, document order, defined on all the nodes in the
* > document corresponding to the order in which the first character of the
* > XML representation of each node occurs in the XML representation of the
* > document after expansion of general entities. Thus, the document element
* > node will be the first node. Element nodes occur before their children.
* > Thus, document order orders element nodes in order of the occurrence of
* > their start-tag in the XML (after expansion of entities). The attribute
* > nodes of an element occur after the element and before its children. The
* > relative order of attribute nodes is implementation-dependent./
*
* Source:
* http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order
* @argument nodaA The first node to use in the comparison
* @argument nodeB The second node to use in the comparison
*
* @return A bitmask describing the input nodes' relative position.
*
* See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for
* a description of these values.
*/
export function compareDocumentPosition(nodeA: DomElement, nodeB: DomElement): number;
export function existsOne(test: any, elems: DomElement[]): boolean;
export function filter(test: any, element: DomElement, recurse: boolean, limit: number): DomElement[];
export function find(test: any, elems: DomElement[], recurse: boolean, limit: number): DomElement[];
export function findAll(test: any, rootElems: DomElement[]): DomElement[];
export function findOne(test: any, elems: DomElement[]): DomElement;
export function findOneChild(test: any, elems: DomElement[]): DomElement;
export function getAttributeValue(elem: DomElement, name: string): string;
export function getChildren(elem: DomElement): DomElement[];
/***
* Legacy
*/
export function getElementById(id: any, element: any, recurse?: any): any;
/***
* Legacy
*/
export function getElements(options: any, element: any, recurse?: any, limit?: any): any;
/***
* Legacy
*/
export function getElementsByTagName(name: any, element: any, recurse?: any, limit?: any): any;
/***
* Legacy
*/
export function getElementsByTagType(type: any, element: any, recurse?: any, limit?: any): any;
export function getInnerHTML(elem: DomElement, opts: any): string;
/***
* Returns the name property of an element
*
* @argument elem The element to get the name for
*/
export function getName(elem: DomElement): string;
/***
* Returns a string representing the array of DomElements
*
* @argument dom An array of DomElement that should be stringified
* @argument [opts] Optional options object
*/
export function getOuterHTML(dom: DomElement[], opts: { decodeEntities?: boolean, xmlMode?: boolean}): string;
export function getParent(elem: DomElement): DomElement;
export function getSiblings(elem: DomElement): DomElement[];
export function getText(elem: DomElement): string;
export function hasAttrib(elem: DomElement, name: string): boolean;
export function isTag(elem: DomElement): boolean;
/***
* Prepend an element before another
*
* @argument elem The element to append to
* @argument prev The element be added
*/
export function prepend(elem: DomElement, prev: DomElement): void;
/***
* Remove an element from the dom
*
* @argument elem The element to be removed
*/
export function removeElement(elem: DomElement): void;
/***
* Given an array of nodes, remove any member that is contained by another.
*/
export function removeSubsets(nodes: DomElement[]): DomElement[];
/***
* Replace an element in the dom
*
* @argument elem The element to be replaced
* @argument replacement The element to be added
*/
export function replaceElement(elem: DomElement, replacement: DomElement): void;
/***
* Legacy
*/
export function testElement(options: any, element: any): any;
/***
* Sort an array of nodes based on their relative position in the document and
* remove any duplicate nodes. If the array contains nodes that do not belong
* to the same document, sort order is unspecified.
*
* @argument nodes Array of DOM nodes
* @returns collection of unique nodes, sorted in document order
*/
export function uniqueSort(nodes: DomElement[]): DomElement[];