forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
incremental-dom.d.ts
82 lines (80 loc) · 3.93 KB
/
incremental-dom.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
// Type definitions for Incremetal DOM
// Project: https://github.com/google/incremental-dom
// Definitions by: Basarat Ali Syed <https://github.com/basarat>, Markus Lanthaler <https://github.com/lanthaler>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "incremental-dom" {
/**
* Patches the document starting at el with the provided function. This function
* may be called during an existing patch operation.
* @param {!Element} el the element to patch
* @param {!function(T)} fn A function containing elementOpen/elementClose/etc.
* calls that describe the DOM.
* @param {?T} data An argument passed to fn to represent DOM state.
*/
export var patch: <T>(el: Node, fn: (data: T) => void, data?: T) => void;
/**
* Declares a virtual Element at the current location in the document. This
* corresponds to an opening tag and a elementClose tag is required.
* @param {string} tag The element's tag.
* @param {?string} key The key used to identify this element. This can be an
* empty string, but performance may be better if a unique value is used
* when iterating over an array of items.
* @param {?Array<*>} statics An array of attribute name/value pairs of the
* static attributes for the Element. These will only be set once when the
* Element is created.
* @param {...*} var_args Attribute name/value pairs of the dynamic attributes
* for the Element.
*/
export var elementOpen: (tag: string, key?: string, statics?: any[], ...var_args: any[]) => void;
/**
* Declares a virtual Element at the current location in the document. This
* corresponds to an opening tag and a elementClose tag is required. This is
* like elementOpen, but the attributes are defined using the attr function
* rather than being passed as arguments. Must be folllowed by 0 or more calls
* to attr, then a call to elementOpenEnd.
* @param {string} tag The element's tag.
* @param {?string} key The key used to identify this element. This can be an
* empty string, but performance may be better if a unique value is used
* when iterating over an array of items.
* @param {?Array<*>} statics An array of attribute name/value pairs of the
* static attributes for the Element. These will only be set once when the
* Element is created.
*/
export var elementOpenStart: (tag: string, key?: any, ...statics: any[]) => void;
/***
* Defines a virtual attribute at this point of the DOM. This is only valid
* when called between elementOpenStart and elementOpenEnd.
*
* @param {string} name
* @param {*} value
*/
export var attr: (name: string, value: any) => void;
/**
* Closes an open tag started with elementOpenStart.
*/
export var elementOpenEnd: () => void;
/**
* Closes an open virtual Element.
*/
export var elementClose: (tag: string) => void;
/**
* Declares a virtual Element at the current location in the document that has
* no children.
* @param {string} tag The element's tag.
* @param {?string} key The key used to identify this element. This can be an
* empty string, but performance may be better if a unique value is used
* when iterating over an array of items.
* @param {?Array<*>} statics An array of attribute name/value pairs of the
* static attributes for the Element. These will only be set once when the
* Element is created.
* @param {...*} var_args Attribute name/value pairs of the dynamic attributes
* for the Element.
*/
export var elementVoid: (tag: string, key?: string, statics?: any, ...var_args: any[]) => void;
/**
* Declares a virtual Text at this point in the document.
*
* @param {string} value The text of the Text.
*/
export var text: (value: string) => void;
}