UNPKG

119 kBTypeScriptView Raw
1/// <reference types="chai" />
2/// <reference types="jquery" />
3
4declare namespace Chai {
5 interface Assertion {
6 attr(name: string, value?: string): Assertion;
7 prop(name: string, value?: any): Assertion;
8 css(name: string, value?: string): Assertion;
9 data(name: string, value?: string): Assertion;
10 class(className: string): Assertion;
11 id(id: string): Assertion;
12 html(html: string): Assertion;
13 text(text: string): Assertion;
14 value(text: string): Assertion;
15 descendants(selector: string): Assertion;
16 visible(): Assertion;
17 hidden(): Assertion;
18 selected(): Assertion;
19 checked(): Assertion;
20 disabled(): Assertion;
21 enabled(): Assertion;
22 (selector: string): Assertion;
23 }
24
25 interface Match {
26 (selector: string): Assertion;
27 }
28}
29
30/**
31 * Static members of chai-jquery (those on $ and jQuery themselves)
32 */
33interface ChaiJQueryStatic {
34 /**
35 * Perform an asynchronous HTTP (Ajax) request.
36 *
37 * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup().
38 */
39 ajax(settings: JQueryAjaxSettings): JQueryXHR;
40 /**
41 * Perform an asynchronous HTTP (Ajax) request.
42 *
43 * @param url A string containing the URL to which the request is sent.
44 * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup().
45 */
46 ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR;
47
48 /**
49 * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax().
50 *
51 * @param dataTypes An optional string containing one or more space-separated dataTypes
52 * @param handler A handler to set default values for future Ajax requests.
53 */
54 ajaxPrefilter(
55 dataTypes: string,
56 handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any,
57 ): void;
58 /**
59 * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax().
60 *
61 * @param handler A handler to set default values for future Ajax requests.
62 */
63 ajaxPrefilter(handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void;
64
65 ajaxSettings: JQueryAjaxSettings;
66
67 /**
68 * Set default values for future Ajax requests. Its use is not recommended.
69 *
70 * @param options A set of key/value pairs that configure the default Ajax request. All options are optional.
71 */
72 ajaxSetup(options: JQueryAjaxSettings): void;
73
74 /**
75 * Load data from the server using a HTTP GET request.
76 *
77 * @param url A string containing the URL to which the request is sent.
78 * @param success A callback function that is executed if the request succeeds.
79 * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).
80 */
81 get(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
82 /**
83 * Load data from the server using a HTTP GET request.
84 *
85 * @param url A string containing the URL to which the request is sent.
86 * @param data A plain object or string that is sent to the server with the request.
87 * @param success A callback function that is executed if the request succeeds.
88 * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).
89 */
90 get(
91 url: string,
92 data?: Object | string,
93 success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any,
94 dataType?: string,
95 ): JQueryXHR;
96 /**
97 * Load JSON-encoded data from the server using a GET HTTP request.
98 *
99 * @param url A string containing the URL to which the request is sent.
100 * @param success A callback function that is executed if the request succeeds.
101 */
102 getJSON(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR;
103 /**
104 * Load JSON-encoded data from the server using a GET HTTP request.
105 *
106 * @param url A string containing the URL to which the request is sent.
107 * @param data A plain object or string that is sent to the server with the request.
108 * @param success A callback function that is executed if the request succeeds.
109 */
110 getJSON(
111 url: string,
112 data?: Object | string,
113 success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any,
114 ): JQueryXHR;
115 /**
116 * Load a JavaScript file from the server using a GET HTTP request, then execute it.
117 *
118 * @param url A string containing the URL to which the request is sent.
119 * @param success A callback function that is executed if the request succeeds.
120 */
121 getScript(url: string, success?: (script: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR;
122
123 /**
124 * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request.
125 */
126 param: JQueryParam;
127
128 /**
129 * Load data from the server using a HTTP POST request.
130 *
131 * @param url A string containing the URL to which the request is sent.
132 * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case.
133 * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).
134 */
135 post(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
136 /**
137 * Load data from the server using a HTTP POST request.
138 *
139 * @param url A string containing the URL to which the request is sent.
140 * @param data A plain object or string that is sent to the server with the request.
141 * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case.
142 * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).
143 */
144 post(
145 url: string,
146 data?: Object | string,
147 success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any,
148 dataType?: string,
149 ): JQueryXHR;
150
151 /**
152 * A multi-purpose callbacks list object that provides a powerful way to manage callback lists.
153 *
154 * @param flags An optional list of space-separated flags that change how the callback list behaves.
155 */
156 Callbacks(flags?: string): JQueryCallback;
157
158 /**
159 * Holds or releases the execution of jQuery's ready event.
160 *
161 * @param hold Indicates whether the ready hold is being requested or released
162 */
163 holdReady(hold: boolean): void;
164
165 /**
166 * Accepts a string containing a CSS selector which is then used to match a set of elements.
167 *
168 * @param selector A string containing a selector expression
169 * @param context A DOM Element, Document, or jQuery to use as context
170 */
171 (selector: string, context?: Element | JQuery): ChaiJQuery;
172 /**
173 * Accepts a string containing a CSS selector which is then used to match a set of elements.
174 *
175 * @param element A DOM element to wrap in a jQuery object.
176 */
177 (element: Element): ChaiJQuery;
178 /**
179 * Accepts a string containing a CSS selector which is then used to match a set of elements.
180 *
181 * @param elementArray An array containing a set of DOM elements to wrap in a jQuery object.
182 */
183 (elementArray: Element[]): ChaiJQuery;
184 /**
185 * Accepts a string containing a CSS selector which is then used to match a set of elements.
186 *
187 * @param object A plain object to wrap in a jQuery object.
188 */
189 (object: {}): ChaiJQuery;
190 /**
191 * Accepts a string containing a CSS selector which is then used to match a set of elements.
192 *
193 * @param object An existing jQuery object to clone.
194 */
195 (object: JQuery): ChaiJQuery;
196 /**
197 * Specify a function to execute when the DOM is fully loaded.
198 */
199 (): ChaiJQuery;
200
201 /**
202 * Creates DOM elements on the fly from the provided string of raw HTML.
203 *
204 * @param html A string of HTML to create on the fly. Note that this parses HTML, not XML.
205 * @param ownerDocument A document in which the new elements will be created.
206 */
207 (html: string, ownerDocument?: Document): ChaiJQuery;
208 /**
209 * Creates DOM elements on the fly from the provided string of raw HTML.
210 *
211 * @param html A string defining a single, standalone, HTML element (e.g. <div/> or <div></div>).
212 * @param attributes An object of attributes, events, and methods to call on the newly-created element.
213 */
214 (html: string, attributes: Object): ChaiJQuery;
215
216 /**
217 * Binds a function to be executed when the DOM has finished loading.
218 *
219 * @param callback A function to execute after the DOM is ready.
220 */
221 (callback: Function): ChaiJQuery;
222
223 /**
224 * Relinquish jQuery's control of the $ variable.
225 *
226 * @param removeAll A Boolean indicating whether to remove all jQuery variables from the global scope (including jQuery itself).
227 */
228 noConflict(removeAll?: boolean): Object;
229
230 /**
231 * Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events.
232 *
233 * @param deferreds One or more Deferred objects, or plain JavaScript objects.
234 */
235 when<T>(...deferreds: Array<T | JQueryPromise<T> /* as JQueryDeferred<T> */>): JQueryPromise<T>;
236
237 /**
238 * Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties.
239 */
240 cssHooks: { [key: string]: any };
241 cssNumber: any;
242
243 /**
244 * Store arbitrary data associated with the specified element. Returns the value that was set.
245 *
246 * @param element The DOM element to associate with the data.
247 * @param key A string naming the piece of data to set.
248 * @param value The new data value.
249 */
250 data<T>(element: Element, key: string, value: T): T;
251 /**
252 * Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element.
253 *
254 * @param element The DOM element to associate with the data.
255 * @param key A string naming the piece of data to set.
256 */
257 data(element: Element, key: string): any;
258 /**
259 * Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element.
260 *
261 * @param element The DOM element to associate with the data.
262 */
263 data(element: Element): any;
264
265 /**
266 * Execute the next function on the queue for the matched element.
267 *
268 * @param element A DOM element from which to remove and execute a queued function.
269 * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
270 */
271 dequeue(element: Element, queueName?: string): void;
272
273 /**
274 * Determine whether an element has any jQuery data associated with it.
275 *
276 * @param element A DOM element to be checked for data.
277 */
278 hasData(element: Element): boolean;
279
280 /**
281 * Show the queue of functions to be executed on the matched element.
282 *
283 * @param element A DOM element to inspect for an attached queue.
284 * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
285 */
286 queue(element: Element, queueName?: string): any[];
287 /**
288 * Manipulate the queue of functions to be executed on the matched element.
289 *
290 * @param element A DOM element where the array of queued functions is attached.
291 * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
292 * @param newQueue An array of functions to replace the current queue contents.
293 */
294 queue(element: Element, queueName: string, newQueue: Function[]): ChaiJQuery;
295 /**
296 * Manipulate the queue of functions to be executed on the matched element.
297 *
298 * @param element A DOM element on which to add a queued function.
299 * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
300 * @param callback The new function to add to the queue.
301 */
302 queue(element: Element, queueName: string, callback: Function): ChaiJQuery;
303
304 /**
305 * Remove a previously-stored piece of data.
306 *
307 * @param element A DOM element from which to remove data.
308 * @param name A string naming the piece of data to remove.
309 */
310 removeData(element: Element, name?: string): ChaiJQuery;
311
312 /**
313 * A constructor function that returns a chainable utility object with methods to register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function.
314 *
315 * @param beforeStart A function that is called just before the constructor returns.
316 */
317 Deferred<T>(beforeStart?: (deferred: JQueryDeferred<T>) => any): JQueryDeferred<T>;
318
319 /**
320 * Effects
321 */
322 fx: {
323 tick: () => void;
324 /**
325 * The rate (in milliseconds) at which animations fire.
326 */
327 interval: number;
328 stop: () => void;
329 speeds: { slow: number; fast: number };
330 /**
331 * Globally disable all animations.
332 */
333 off: boolean;
334 step: any;
335 };
336
337 /**
338 * Takes a function and returns a new one that will always have a particular context.
339 *
340 * @param fnction The function whose context will be changed.
341 * @param context The object to which the context (this) of the function should be set.
342 * @param additionalArguments Any number of arguments to be passed to the function referenced in the function argument.
343 */
344 proxy(fnction: (...args: any[]) => any, context: Object, ...additionalArguments: any[]): any;
345 /**
346 * Takes a function and returns a new one that will always have a particular context.
347 *
348 * @param context The object to which the context (this) of the function should be set.
349 * @param name The name of the function whose context will be changed (should be a property of the context object).
350 * @param additionalArguments Any number of arguments to be passed to the function named in the name argument.
351 */
352 proxy(context: Object, name: string, ...additionalArguments: any[]): any;
353
354 Event: JQueryEventConstructor;
355
356 /**
357 * Takes a string and throws an exception containing it.
358 *
359 * @param message The message to send out.
360 */
361 error(message: any): ChaiJQuery;
362
363 expr: any;
364 fn: any; // TODO: Decide how we want to type this
365
366 isReady: boolean;
367
368 // Properties
369 support: JQuerySupport;
370
371 /**
372 * Check to see if a DOM element is a descendant of another DOM element.
373 *
374 * @param container The DOM element that may contain the other element.
375 * @param contained The DOM element that may be contained by (a descendant of) the other element.
376 */
377 contains(container: Element, contained: Element): boolean;
378
379 /**
380 * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.
381 *
382 * @param collection The object or array to iterate over.
383 * @param callback The function that will be executed on every object.
384 */
385 each<T>(
386 collection: T[],
387 callback: (indexInArray: number, valueOfElement: T) => any,
388 ): any;
389
390 /**
391 * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.
392 *
393 * @param collection The object or array to iterate over.
394 * @param callback The function that will be executed on every object.
395 */
396 each(
397 collection: any,
398 callback: (indexInArray: any, valueOfElement: any) => any,
399 ): any;
400
401 /**
402 * Merge the contents of two or more objects together into the first object.
403 *
404 * @param target An object that will receive the new properties if additional objects are passed in or that will extend the jQuery namespace if it is the sole argument.
405 * @param object1 An object containing additional properties to merge in.
406 * @param objectN Additional objects containing properties to merge in.
407 */
408 extend(target: any, object1?: any, ...objectN: any[]): any;
409 /**
410 * Merge the contents of two or more objects together into the first object.
411 *
412 * @param deep If true, the merge becomes recursive (aka. deep copy).
413 * @param target The object to extend. It will receive the new properties.
414 * @param object1 An object containing additional properties to merge in.
415 * @param objectN Additional objects containing properties to merge in.
416 */
417 extend(deep: boolean, target: any, object1?: any, ...objectN: any[]): any;
418
419 /**
420 * Execute some JavaScript code globally.
421 *
422 * @param code The JavaScript code to execute.
423 */
424 globalEval(code: string): any;
425
426 /**
427 * Finds the elements of an array which satisfy a filter function. The original array is not affected.
428 *
429 * @param array The array to search through.
430 * @param func The function to process each item against. The first argument to the function is the item, and the second argument is the index. The function should return a Boolean value. this will be the global window object.
431 * @param invert If "invert" is false, or not provided, then the function returns an array consisting of all elements for which "callback" returns true. If "invert" is true, then the function returns an array consisting of all elements for which "callback" returns false.
432 */
433 grep<T>(array: T[], func: (elementOfArray: T, indexInArray: number) => boolean, invert?: boolean): T[];
434
435 /**
436 * Search for a specified value within an array and return its index (or -1 if not found).
437 *
438 * @param value The value to search for.
439 * @param array An array through which to search.
440 * @param fromIndex The index of the array at which to begin the search. The default is 0, which will search the whole array.
441 */
442 inArray<T>(value: T, array: T[], fromIndex?: number): number;
443
444 /**
445 * Determine whether the argument is an array.
446 *
447 * @param obj Object to test whether or not it is an array.
448 */
449 isArray(obj: any): boolean;
450 /**
451 * Check to see if an object is empty (contains no enumerable properties).
452 *
453 * @param obj The object that will be checked to see if it's empty.
454 */
455 isEmptyObject(obj: any): boolean;
456 /**
457 * Determine if the argument passed is a Javascript function object.
458 *
459 * @param obj Object to test whether or not it is a function.
460 */
461 isFunction(obj: any): boolean;
462 /**
463 * Determines whether its argument is a number.
464 *
465 * @param obj The value to be tested.
466 */
467 isNumeric(value: any): boolean;
468 /**
469 * Check to see if an object is a plain object (created using "{}" or "new Object").
470 *
471 * @param obj The object that will be checked to see if it's a plain object.
472 */
473 isPlainObject(obj: any): boolean;
474 /**
475 * Determine whether the argument is a window.
476 *
477 * @param obj Object to test whether or not it is a window.
478 */
479 isWindow(obj: any): boolean;
480 /**
481 * Check to see if a DOM node is within an XML document (or is an XML document).
482 *
483 * @param node The DOM node that will be checked to see if it's in an XML document.
484 */
485 isXMLDoc(node: Node): boolean;
486
487 /**
488 * Convert an array-like object into a true JavaScript array.
489 *
490 * @param obj Any object to turn into a native Array.
491 */
492 makeArray(obj: any): any[];
493
494 /**
495 * Translate all items in an array or object to new array of items.
496 *
497 * @param array The Array to translate.
498 * @param callback The function to process each item against. The first argument to the function is the array item, the second argument is the index in array The function can return any value. Within the function, this refers to the global (window) object.
499 */
500 map<T, U>(array: T[], callback: (elementOfArray: T, indexInArray: number) => U): U[];
501 /**
502 * Translate all items in an array or object to new array of items.
503 *
504 * @param arrayOrObject The Array or Object to translate.
505 * @param callback The function to process each item against. The first argument to the function is the value; the second argument is the index or key of the array or object property. The function can return any value to add to the array. A returned array will be flattened into the resulting array. Within the function, this refers to the global (window) object.
506 */
507 map(arrayOrObject: any, callback: (value: any, indexOrKey: any) => any): any;
508
509 /**
510 * Merge the contents of two arrays together into the first array.
511 *
512 * @param first The first array to merge, the elements of second added.
513 * @param second The second array to merge into the first, unaltered.
514 */
515 merge<T>(first: T[], second: T[]): T[];
516
517 /**
518 * An empty function.
519 */
520 noop(): any;
521
522 /**
523 * Return a number representing the current time.
524 */
525 now(): number;
526
527 /**
528 * Takes a well-formed JSON string and returns the resulting JavaScript object.
529 *
530 * @param json The JSON string to parse.
531 */
532 parseJSON(json: string): any;
533
534 /**
535 * Parses a string into an XML document.
536 *
537 * @param data a well-formed XML string to be parsed
538 */
539 parseXML(data: string): XMLDocument;
540
541 /**
542 * Remove the whitespace from the beginning and end of a string.
543 *
544 * @param str Remove the whitespace from the beginning and end of a string.
545 */
546 trim(str: string): string;
547
548 /**
549 * Determine the internal JavaScript [[Class]] of an object.
550 *
551 * @param obj Object to get the internal JavaScript [[Class]] of.
552 */
553 type(obj: any): string;
554
555 /**
556 * Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers.
557 *
558 * @param array The Array of DOM elements.
559 */
560 unique(array: Element[]): Element[];
561
562 /**
563 * Parses a string into an array of DOM nodes.
564 *
565 * @param data HTML string to be parsed
566 * @param context DOM element to serve as the context in which the HTML fragment will be created
567 * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string
568 */
569 parseHTML(data: string, context?: HTMLElement, keepScripts?: boolean): any[];
570
571 /**
572 * Parses a string into an array of DOM nodes.
573 *
574 * @param data HTML string to be parsed
575 * @param context DOM element to serve as the context in which the HTML fragment will be created
576 * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string
577 */
578 parseHTML(data: string, context?: Document, keepScripts?: boolean): any[];
579}
580
581/**
582 * The chai-jquery instance members
583 */
584interface ChaiJQuery {
585 /**
586 * Register a handler to be called when Ajax requests complete. This is an AjaxEvent.
587 *
588 * @param handler The function to be invoked.
589 */
590 ajaxComplete(
591 handler: (event: JQueryEventObject, XMLHttpRequest: XMLHttpRequest, ajaxOptions: any) => any,
592 ): ChaiJQuery;
593 /**
594 * Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event.
595 *
596 * @param handler The function to be invoked.
597 */
598 ajaxError(
599 handler: (
600 event: JQueryEventObject,
601 jqXHR: JQueryXHR,
602 ajaxSettings: JQueryAjaxSettings,
603 thrownError: any,
604 ) => any,
605 ): ChaiJQuery;
606 /**
607 * Attach a function to be executed before an Ajax request is sent. This is an Ajax Event.
608 *
609 * @param handler The function to be invoked.
610 */
611 ajaxSend(handler: (event: JQueryEventObject, jqXHR: JQueryXHR, ajaxOptions: JQueryAjaxSettings) => any): ChaiJQuery;
612 /**
613 * Register a handler to be called when the first Ajax request begins. This is an Ajax Event.
614 *
615 * @param handler The function to be invoked.
616 */
617 ajaxStart(handler: () => any): ChaiJQuery;
618 /**
619 * Register a handler to be called when all Ajax requests have completed. This is an Ajax Event.
620 *
621 * @param handler The function to be invoked.
622 */
623 ajaxStop(handler: () => any): ChaiJQuery;
624 /**
625 * Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event.
626 *
627 * @param handler The function to be invoked.
628 */
629 ajaxSuccess(
630 handler: (event: JQueryEventObject, XMLHttpRequest: XMLHttpRequest, ajaxOptions: JQueryAjaxSettings) => any,
631 ): ChaiJQuery;
632
633 /**
634 * Load data from the server and place the returned HTML into the matched element.
635 *
636 * @param url A string containing the URL to which the request is sent.
637 * @param data A plain object or string that is sent to the server with the request.
638 * @param complete A callback function that is executed when the request completes.
639 */
640 load(
641 url: string,
642 data?: string | Object,
643 complete?: (responseText: string, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any,
644 ): ChaiJQuery;
645
646 /**
647 * Encode a set of form elements as a string for submission.
648 */
649 serialize(): string;
650 /**
651 * Encode a set of form elements as an array of names and values.
652 */
653 serializeArray(): JQuerySerializeArrayElement[];
654
655 /**
656 * Adds the specified class(es) to each of the set of matched elements.
657 *
658 * @param className One or more space-separated classes to be added to the class attribute of each matched element.
659 */
660 addClass(className: string): ChaiJQuery;
661 /**
662 * Adds the specified class(es) to each of the set of matched elements.
663 *
664 * @param function A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set.
665 */
666 addClass(func: (index: number, className: string) => string): ChaiJQuery;
667
668 /**
669 * Add the previous set of elements on the stack to the current set, optionally filtered by a selector.
670 */
671 addBack(selector?: string): ChaiJQuery;
672
673 /**
674 * Get the value of an attribute for the first element in the set of matched elements.
675 *
676 * @param attributeName The name of the attribute to get.
677 */
678 attr(attributeName: string): string;
679 /**
680 * Set one or more attributes for the set of matched elements.
681 *
682 * @param attributeName The name of the attribute to set.
683 * @param value A value to set for the attribute.
684 */
685 attr(attributeName: string, value: string | number): ChaiJQuery;
686 /**
687 * Set one or more attributes for the set of matched elements.
688 *
689 * @param attributeName The name of the attribute to set.
690 * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old attribute value as arguments.
691 */
692 attr(attributeName: string, func: (index: number, attr: string) => string | number): ChaiJQuery;
693 /**
694 * Set one or more attributes for the set of matched elements.
695 *
696 * @param attributes An object of attribute-value pairs to set.
697 */
698 attr(attributes: Object): ChaiJQuery;
699
700 /**
701 * Determine whether any of the matched elements are assigned the given class.
702 *
703 * @param className The class name to search for.
704 */
705 hasClass(className: string): boolean;
706
707 /**
708 * Get the HTML contents of the first element in the set of matched elements.
709 */
710 html(): string;
711 /**
712 * Set the HTML contents of each element in the set of matched elements.
713 *
714 * @param htmlString A string of HTML to set as the content of each matched element.
715 */
716 html(htmlString: string): ChaiJQuery;
717 /**
718 * Set the HTML contents of each element in the set of matched elements.
719 *
720 * @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set.
721 */
722 html(func: (index: number, oldhtml: string) => string): ChaiJQuery;
723 /**
724 * Set the HTML contents of each element in the set of matched elements.
725 *
726 * @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set.
727 */
728
729 /**
730 * Get the value of a property for the first element in the set of matched elements.
731 *
732 * @param propertyName The name of the property to get.
733 */
734 prop(propertyName: string): any;
735 /**
736 * Set one or more properties for the set of matched elements.
737 *
738 * @param propertyName The name of the property to set.
739 * @param value A value to set for the property.
740 */
741 prop(propertyName: string, value: string | number | boolean): ChaiJQuery;
742 /**
743 * Set one or more properties for the set of matched elements.
744 *
745 * @param properties An object of property-value pairs to set.
746 */
747 prop(properties: Object): ChaiJQuery;
748 /**
749 * Set one or more properties for the set of matched elements.
750 *
751 * @param propertyName The name of the property to set.
752 * @param func A function returning the value to set. Receives the index position of the element in the set and the old property value as arguments. Within the function, the keyword this refers to the current element.
753 */
754 prop(propertyName: string, func: (index: number, oldPropertyValue: any) => any): ChaiJQuery;
755
756 /**
757 * Remove an attribute from each element in the set of matched elements.
758 *
759 * @param attributeName An attribute to remove; as of version 1.7, it can be a space-separated list of attributes.
760 */
761 removeAttr(attributeName: string): ChaiJQuery;
762
763 /**
764 * Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
765 *
766 * @param className One or more space-separated classes to be removed from the class attribute of each matched element.
767 */
768 removeClass(className?: string): ChaiJQuery;
769 /**
770 * Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
771 *
772 * @param function A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments.
773 */
774 removeClass(func: (index: number, className: string) => string): ChaiJQuery;
775
776 /**
777 * Remove a property for the set of matched elements.
778 *
779 * @param propertyName The name of the property to remove.
780 */
781 removeProp(propertyName: string): ChaiJQuery;
782
783 /**
784 * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
785 *
786 * @param className One or more class names (separated by spaces) to be toggled for each element in the matched set.
787 * @param swtch A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed.
788 */
789 toggleClass(className: string, swtch?: boolean): ChaiJQuery;
790 /**
791 * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
792 *
793 * @param swtch A boolean value to determine whether the class should be added or removed.
794 */
795 toggleClass(swtch?: boolean): ChaiJQuery;
796 /**
797 * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
798 *
799 * @param func A function that returns class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the switch as arguments.
800 * @param swtch A boolean value to determine whether the class should be added or removed.
801 */
802 toggleClass(func: (index: number, className: string, swtch: boolean) => string, swtch?: boolean): ChaiJQuery;
803
804 /**
805 * Get the current value of the first element in the set of matched elements.
806 */
807 val(): any;
808 /**
809 * Set the value of each element in the set of matched elements.
810 *
811 * @param value A string of text or an array of strings corresponding to the value of each matched element to set as selected/checked.
812 */
813 val(value: string | string[]): ChaiJQuery;
814 /**
815 * Set the value of each element in the set of matched elements.
816 *
817 * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments.
818 */
819 val(func: (index: number, value: string) => string): ChaiJQuery;
820
821 /**
822 * Get the value of style properties for the first element in the set of matched elements.
823 *
824 * @param propertyName A CSS property.
825 */
826 css(propertyName: string): string;
827 /**
828 * Set one or more CSS properties for the set of matched elements.
829 *
830 * @param propertyName A CSS property name.
831 * @param value A value to set for the property.
832 */
833 css(propertyName: string, value: string | number): ChaiJQuery;
834 /**
835 * Set one or more CSS properties for the set of matched elements.
836 *
837 * @param propertyName A CSS property name.
838 * @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments.
839 */
840 css(propertyName: string, value: (index: number, value: string) => string | number): ChaiJQuery;
841 /**
842 * Set one or more CSS properties for the set of matched elements.
843 *
844 * @param properties An object of property-value pairs to set.
845 */
846 css(properties: Object): ChaiJQuery;
847
848 /**
849 * Get the current computed height for the first element in the set of matched elements.
850 */
851 height(): number;
852 /**
853 * Set the CSS height of every matched element.
854 *
855 * @param value An integer representing the number of pixels, or an integer with an optional unit of measure appended (as a string).
856 */
857 height(value: number | string): ChaiJQuery;
858 /**
859 * Set the CSS height of every matched element.
860 *
861 * @param func A function returning the height to set. Receives the index position of the element in the set and the old height as arguments. Within the function, this refers to the current element in the set.
862 */
863 height(func: (index: number, height: number) => number | string): ChaiJQuery;
864
865 /**
866 * Get the current computed height for the first element in the set of matched elements, including padding but not border.
867 */
868 innerHeight(): number;
869
870 /**
871 * Sets the inner height on elements in the set of matched elements, including padding but not border.
872 *
873 * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
874 */
875 innerHeight(height: number | string): ChaiJQuery;
876
877 /**
878 * Get the current computed width for the first element in the set of matched elements, including padding but not border.
879 */
880 innerWidth(): number;
881
882 /**
883 * Sets the inner width on elements in the set of matched elements, including padding but not border.
884 *
885 * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
886 */
887 innerWidth(width: number | string): ChaiJQuery;
888
889 /**
890 * Get the current coordinates of the first element in the set of matched elements, relative to the document.
891 */
892 offset(): JQueryCoordinates;
893 /**
894 * An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements.
895 *
896 * @param coordinates An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements.
897 */
898 offset(coordinates: JQueryCoordinates): ChaiJQuery;
899 /**
900 * An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements.
901 *
902 * @param func A function to return the coordinates to set. Receives the index of the element in the collection as the first argument and the current coordinates as the second argument. The function should return an object with the new top and left properties.
903 */
904 offset(func: (index: number, coords: JQueryCoordinates) => JQueryCoordinates): ChaiJQuery;
905
906 /**
907 * Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements.
908 *
909 * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation.
910 */
911 outerHeight(includeMargin?: boolean): number;
912
913 /**
914 * Sets the outer height on elements in the set of matched elements, including padding and border.
915 *
916 * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
917 */
918 outerHeight(height: number | string): ChaiJQuery;
919
920 /**
921 * Get the current computed width for the first element in the set of matched elements, including padding and border.
922 *
923 * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation.
924 */
925 outerWidth(includeMargin?: boolean): number;
926
927 /**
928 * Sets the outer width on elements in the set of matched elements, including padding and border.
929 *
930 * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
931 */
932 outerWidth(width: number | string): ChaiJQuery;
933
934 /**
935 * Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.
936 */
937 position(): JQueryCoordinates;
938
939 /**
940 * Get the current horizontal position of the scroll bar for the first element in the set of matched elements or set the horizontal position of the scroll bar for every matched element.
941 */
942 scrollLeft(): number;
943 /**
944 * Set the current horizontal position of the scroll bar for each of the set of matched elements.
945 *
946 * @param value An integer indicating the new position to set the scroll bar to.
947 */
948 scrollLeft(value: number): ChaiJQuery;
949
950 /**
951 * Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element.
952 */
953 scrollTop(): number;
954 /**
955 * Set the current vertical position of the scroll bar for each of the set of matched elements.
956 *
957 * @param value An integer indicating the new position to set the scroll bar to.
958 */
959 scrollTop(value: number): ChaiJQuery;
960
961 /**
962 * Get the current computed width for the first element in the set of matched elements.
963 */
964 width(): number;
965 /**
966 * Set the CSS width of each element in the set of matched elements.
967 *
968 * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
969 */
970 width(value: number | string): ChaiJQuery;
971 /**
972 * Set the CSS width of each element in the set of matched elements.
973 *
974 * @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set.
975 */
976 width(func: (index: number, width: number) => number | string): ChaiJQuery;
977
978 /**
979 * Remove from the queue all items that have not yet been run.
980 *
981 * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
982 */
983 clearQueue(queueName?: string): ChaiJQuery;
984
985 /**
986 * Store arbitrary data associated with the matched elements.
987 *
988 * @param key A string naming the piece of data to set.
989 * @param value The new data value; it can be any Javascript type including Array or Object.
990 */
991 data(key: string, value: any): ChaiJQuery;
992 /**
993 * Store arbitrary data associated with the matched elements.
994 *
995 * @param obj An object of key-value pairs of data to update.
996 */
997 data(obj: { [key: string]: any }): ChaiJQuery;
998 /**
999 * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
1000 *
1001 * @param key Name of the data stored.
1002 */
1003 data(key: string): any;
1004 /**
1005 * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
1006 */
1007 data(): any;
1008
1009 /**
1010 * Execute the next function on the queue for the matched elements.
1011 *
1012 * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
1013 */
1014 dequeue(queueName?: string): ChaiJQuery;
1015
1016 /**
1017 * Remove a previously-stored piece of data.
1018 *
1019 * @param name A string naming the piece of data to delete or space-separated string naming the pieces of data to delete.
1020 */
1021 removeData(name: string): ChaiJQuery;
1022 /**
1023 * Remove a previously-stored piece of data.
1024 *
1025 * @param list An array of strings naming the pieces of data to delete.
1026 */
1027 removeData(list: string[]): ChaiJQuery;
1028
1029 /**
1030 * Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished.
1031 *
1032 * @param type The type of queue that needs to be observed. (default: fx)
1033 * @param target Object onto which the promise methods have to be attached
1034 */
1035 promise(type?: string, target?: Object): JQueryPromise<any>;
1036
1037 /**
1038 * Perform a custom animation of a set of CSS properties.
1039 *
1040 * @param properties An object of CSS properties and values that the animation will move toward.
1041 * @param duration A string or number determining how long the animation will run.
1042 * @param complete A function to call once the animation is complete.
1043 */
1044 animate(properties: Object, duration?: string | number, complete?: Function): ChaiJQuery;
1045 /**
1046 * Perform a custom animation of a set of CSS properties.
1047 *
1048 * @param properties An object of CSS properties and values that the animation will move toward.
1049 * @param duration A string or number determining how long the animation will run.
1050 * @param easing A string indicating which easing function to use for the transition. (default: swing)
1051 * @param complete A function to call once the animation is complete.
1052 */
1053 animate(properties: Object, duration?: string | number, easing?: string, complete?: Function): ChaiJQuery;
1054 /**
1055 * Perform a custom animation of a set of CSS properties.
1056 *
1057 * @param properties An object of CSS properties and values that the animation will move toward.
1058 * @param options A map of additional options to pass to the method.
1059 */
1060 animate(properties: Object, options: JQueryAnimationOptions): ChaiJQuery;
1061
1062 /**
1063 * Set a timer to delay execution of subsequent items in the queue.
1064 *
1065 * @param duration An integer indicating the number of milliseconds to delay execution of the next item in the queue.
1066 * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
1067 */
1068 delay(duration: number, queueName?: string): ChaiJQuery;
1069
1070 /**
1071 * Display the matched elements by fading them to opaque.
1072 *
1073 * @param duration A string or number determining how long the animation will run.
1074 * @param complete A function to call once the animation is complete.
1075 */
1076 fadeIn(duration?: number | string, complete?: Function): ChaiJQuery;
1077 /**
1078 * Display the matched elements by fading them to opaque.
1079 *
1080 * @param duration A string or number determining how long the animation will run.
1081 * @param easing A string indicating which easing function to use for the transition.
1082 * @param complete A function to call once the animation is complete.
1083 */
1084 fadeIn(duration?: number | string, easing?: string, complete?: Function): ChaiJQuery;
1085 /**
1086 * Display the matched elements by fading them to opaque.
1087 *
1088 * @param options A map of additional options to pass to the method.
1089 */
1090 fadeIn(options: JQueryAnimationOptions): ChaiJQuery;
1091
1092 /**
1093 * Hide the matched elements by fading them to transparent.
1094 *
1095 * @param duration A string or number determining how long the animation will run.
1096 * @param complete A function to call once the animation is complete.
1097 */
1098 fadeOut(duration?: number | string, complete?: Function): ChaiJQuery;
1099 /**
1100 * Hide the matched elements by fading them to transparent.
1101 *
1102 * @param duration A string or number determining how long the animation will run.
1103 * @param easing A string indicating which easing function to use for the transition.
1104 * @param complete A function to call once the animation is complete.
1105 */
1106 fadeOut(duration?: number | string, easing?: string, complete?: Function): ChaiJQuery;
1107 /**
1108 * Hide the matched elements by fading them to transparent.
1109 *
1110 * @param options A map of additional options to pass to the method.
1111 */
1112 fadeOut(options: JQueryAnimationOptions): ChaiJQuery;
1113
1114 /**
1115 * Adjust the opacity of the matched elements.
1116 *
1117 * @param duration A string or number determining how long the animation will run.
1118 * @param opacity A number between 0 and 1 denoting the target opacity.
1119 * @param complete A function to call once the animation is complete.
1120 */
1121 fadeTo(duration: string | number, opacity: number, complete?: Function): ChaiJQuery;
1122 /**
1123 * Adjust the opacity of the matched elements.
1124 *
1125 * @param duration A string or number determining how long the animation will run.
1126 * @param opacity A number between 0 and 1 denoting the target opacity.
1127 * @param easing A string indicating which easing function to use for the transition.
1128 * @param complete A function to call once the animation is complete.
1129 */
1130 fadeTo(duration: string | number, opacity: number, easing?: string, complete?: Function): ChaiJQuery;
1131
1132 /**
1133 * Display or hide the matched elements by animating their opacity.
1134 *
1135 * @param duration A string or number determining how long the animation will run.
1136 * @param complete A function to call once the animation is