1
// TODO(rictic): upstream this to dom5 itself.
3
declare module 'dom5' {
4
export interface Node {
16
export interface Attr {
20
interface ParseOptions {
21
locationInfo: boolean;
24
export function parse(text: string, opts?: ParseOptions):Node;
25
export function parseFragment(text: string, opts?: ParseOptions):Node;
27
export function serialize(node: Node): string;
29
export type Predicate = (n:Node) => boolean;
30
export function query(root: Node, predicate: Predicate):Node;
31
export function queryAll(root: Node, predicate: Predicate):Node[];
32
export function nodeWalk(node: Node, predicate: Predicate):Node;
33
export function nodeWalkAll(node: Node, predicate: Predicate):Node[];
34
export function nodeWalkAllPrior(node: Node, predicate: Predicate):Node[];
35
export function treeMap(node: Node, walker:(node: Node)=>void):void;
36
export function getAttribute(node: Node, attrName: string): string;
37
export function removeAttribute(node: Node, attrName: string): string;
38
export function getTextContent(node: Node): string;
39
export function setTextContent(node: Node, string: string): void;
40
export function append(parent: Node, newNode: Node): void;
41
export function remove(willBeRemoved: Node): void;
42
export function replace(current: Node, replacement: Node): void;
44
export var isCommentNode: Predicate;
45
interface PredicateCombinators {
46
hasTagName(name: string):Predicate;
47
hasAttr(name: string): Predicate;
48
hasAttrValue(name: string, value: string): Predicate;
49
NOT(pred: Predicate):Predicate;
50
AND(...preds: Predicate[]):Predicate;
51
OR(...preds: Predicate[]):Predicate;
53
export var predicates: PredicateCombinators;
55
interface Constructors {
56
element(tagName: string): Node;
57
text(content: string): Node;
59
export var constructors: Constructors;