mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
[jquery] Clean up misc-related methods on JQuery.
Add tests for misc-related methods on JQuery.
This commit is contained in:
Vendored
+2
-2
@@ -620,7 +620,7 @@ interface JQuery<TElement extends Node = HTMLElement> {
|
||||
* @see {@link https://api.jquery.com/each/}
|
||||
* @since 1.0
|
||||
*/
|
||||
each(fn: (this: TElement, index: number, element: Element) => void | false): this;
|
||||
each(fn: (this: TElement, index: number, element: TElement) => void | false): this;
|
||||
/**
|
||||
* Remove all child nodes of the set of matched elements from the DOM.
|
||||
*
|
||||
@@ -985,7 +985,7 @@ interface JQuery<TElement extends Node = HTMLElement> {
|
||||
* @since 1.0
|
||||
* @since 1.4
|
||||
*/
|
||||
index(element?: Element | JQuery | JQuery.Selector): number;
|
||||
index(element?: JQuery.Selector | Element | JQuery): number;
|
||||
/**
|
||||
* Set the CSS inner height of each element in the set of matched elements.
|
||||
*
|
||||
|
||||
@@ -3387,6 +3387,82 @@ function JQuery() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').slice(0);
|
||||
}
|
||||
|
||||
function pushStack() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').pushStack([new HTMLElement()], 'name', ['arg']);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').pushStack([new HTMLElement()]);
|
||||
}
|
||||
}
|
||||
|
||||
function misc() {
|
||||
function serialize() {
|
||||
// $ExpectType string
|
||||
$('p').serialize();
|
||||
}
|
||||
|
||||
function serializeArray() {
|
||||
// $ExpectType NameValuePair[]
|
||||
$('p').serializeArray();
|
||||
}
|
||||
|
||||
function each() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').each(function(index, element) {
|
||||
// $ExpectType HTMLElement
|
||||
this;
|
||||
// $ExpectType number
|
||||
index;
|
||||
// $ExpectType HTMLElement
|
||||
element;
|
||||
});
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').each(function(index, element) {
|
||||
// $ExpectType HTMLElement
|
||||
this;
|
||||
// $ExpectType number
|
||||
index;
|
||||
// $ExpectType HTMLElement
|
||||
element;
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function extend() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$.fn.extend({ myPlugin: {} });
|
||||
}
|
||||
|
||||
function get() {
|
||||
// $ExpectType HTMLElement
|
||||
$('p').get(0);
|
||||
|
||||
// $ExpectType HTMLElement[]
|
||||
$('p').get();
|
||||
}
|
||||
|
||||
function index() {
|
||||
// $ExpectType number
|
||||
$('p').index('span');
|
||||
|
||||
// $ExpectType number
|
||||
$('p').index(new HTMLElement());
|
||||
|
||||
// $ExpectType number
|
||||
$('p').index($('span'));
|
||||
|
||||
// $ExpectType number
|
||||
$('p').index();
|
||||
}
|
||||
|
||||
function toArray() {
|
||||
// $ExpectType HTMLElement[]
|
||||
$('p').toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user