UNPKG

4.53 kBJavaScriptView Raw
1/**
2 * @externs
3 * @fileoverview Externs for PolymerDomApi for backwards compatibility with
4 * the Polymer 1 externs.
5 */
6
7/**
8 * A Polymer DOM API for manipulating DOM such that local DOM and light DOM
9 * trees are properly maintained.
10 *
11 * This type exists only to provide compatibility between compiled hybrid
12 * Polymer V1 and V2 code. Polymer V2 only code should simply use the DomApi
13 * class type.
14 *
15 * @interface
16 */
17var PolymerDomApi = function() {};
18
19/**
20 * @param {?Node} node
21 * @return {boolean}
22 */
23PolymerDomApi.prototype.deepContains = function(node) {};
24
25/** @param {!Node} node */
26PolymerDomApi.prototype.appendChild = function(node) {};
27
28/**
29 * @param {!Node} oldNode
30 * @param {!Node} newNode
31 */
32PolymerDomApi.prototype.replaceChild = function(oldNode, newNode) {};
33
34/**
35 * @param {!Node} node
36 * @param {?Node} beforeNode
37 */
38PolymerDomApi.prototype.insertBefore = function(node, beforeNode) {};
39
40/** @param {!Node} node */
41PolymerDomApi.prototype.removeChild = function(node) {};
42
43/** @type {!Array<!HTMLElement>|!NodeList<!HTMLElement>} */
44PolymerDomApi.prototype.children;
45
46/** @type {!Array<!Node>|!NodeList<!Node>} */
47PolymerDomApi.prototype.childNodes;
48
49/** @type {?Node} */
50PolymerDomApi.prototype.parentNode;
51
52/** @type {?Node} */
53PolymerDomApi.prototype.firstChild;
54
55/** @type {?Node} */
56PolymerDomApi.prototype.lastChild;
57
58/** @type {?HTMLElement} */
59PolymerDomApi.prototype.firstElementChild;
60
61/** @type {?HTMLElement} */
62PolymerDomApi.prototype.lastElementChild;
63
64/** @type {?Node} */
65PolymerDomApi.prototype.previousSibling;
66
67/** @type {?Node} */
68PolymerDomApi.prototype.nextSibling;
69
70/** @type {?HTMLElement} */
71PolymerDomApi.prototype.previousElementSibling;
72
73/** @type {?HTMLElement} */
74PolymerDomApi.prototype.nextElementSibling;
75
76/** @type {string} */
77PolymerDomApi.prototype.textContent;
78
79/** @type {string} */
80PolymerDomApi.prototype.innerHTML;
81
82/** @type {?HTMLElement} */
83PolymerDomApi.prototype.activeElement;
84
85/**
86 * @param {string} selector
87 * @return {?Element}
88 */
89PolymerDomApi.prototype.querySelector = function(selector) {};
90
91/**
92 * @param {string} selector
93 * @return {!Array<!Element>|!NodeList<!Element>}
94 */
95PolymerDomApi.prototype.querySelectorAll = function(selector) {};
96
97/** @return {!Array<!Node>} */
98PolymerDomApi.prototype.getDistributedNodes = function() {};
99
100/** @return {!Array<!Node>} */
101PolymerDomApi.prototype.getDestinationInsertionPoints = function() {};
102
103/** @return {?Node} */
104PolymerDomApi.prototype.getOwnerRoot = function() {};
105
106/** @type {!Node} */
107PolymerDomApi.prototype.node;
108
109/**
110 * @param {string} attribute
111 * @param {string} value
112 */
113PolymerDomApi.prototype.setAttribute = function(attribute, value) {};
114
115/** @param {string} attribute */
116PolymerDomApi.prototype.removeAttribute = function(attribute) {};
117
118/**
119 * @typedef {function(!PolymerDomApi.ObserveInfo)}
120 */
121PolymerDomApi.ObserveCallback;
122
123/**
124 * @typedef {{
125 * target: !Node,
126 * addedNodes: !Array<!Node>,
127 * removedNodes: !Array<!Node>
128 * }}
129 */
130PolymerDomApi.ObserveInfo;
131
132/**
133 * A virtual type for observer callback handles.
134 *
135 * @interface
136 */
137PolymerDomApi.ObserveHandle = function() {};
138
139/**
140 * @return {void}
141 */
142PolymerDomApi.ObserveHandle.prototype.disconnect = function() {};
143
144/**
145 * Notifies callers about changes to the element's effective child nodes,
146 * the same list as returned by `getEffectiveChildNodes`.
147 *
148 * @param {!PolymerDomApi.ObserveCallback} callback The supplied callback
149 * is called with an `info` argument which is an object that provides
150 * the `target` on which the changes occurred, a list of any nodes
151 * added in the `addedNodes` array, and nodes removed in the
152 * `removedNodes` array.
153 *
154 * @return {!PolymerDomApi.ObserveHandle} Handle which is the argument to
155 * `unobserveNodes`.
156 */
157PolymerDomApi.prototype.observeNodes = function(callback) {};
158
159/**
160 * Stops observing changes to the element's effective child nodes.
161 *
162 * @param {!PolymerDomApi.ObserveHandle} handle The handle for the
163 * callback that should no longer receive notifications. This
164 * handle is returned from `observeNodes`.
165 */
166PolymerDomApi.prototype.unobserveNodes = function(handle) {};
167
168/** @type {?DOMTokenList} */
169PolymerDomApi.prototype.classList;
170
171/**
172 * @param {string} selector
173 * @return {!Array<!HTMLElement>}
174 */
175PolymerDomApi.prototype.queryDistributedElements = function(selector) {};
176
177/**
178 * Returns a list of effective child nodes for this element.
179 *
180 * @return {!Array<!HTMLElement>}
181 */
182PolymerDomApi.prototype.getEffectiveChildNodes = function() {};