mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
[jquery] Fix issue with unbinding event handlers for specific event types.
This commit is contained in:
Vendored
+19
-13
@@ -7304,10 +7304,12 @@ $( "body" ).on( "click", "p", foo );
|
||||
$( "body" ).off( "click", "p", foo );
|
||||
```
|
||||
*/
|
||||
off(events: string,
|
||||
off<TType extends string>(
|
||||
events: TType,
|
||||
selector: JQuery.Selector,
|
||||
handler: JQuery.TypeEventHandler<TElement, any, any, any, string> |
|
||||
false): this;
|
||||
handler: JQuery.TypeEventHandler<TElement, any, any, any, TType> |
|
||||
false
|
||||
): this;
|
||||
/**
|
||||
* Remove an event handler.
|
||||
* @param events One or more space-separated event types and optional namespaces, or just namespaces, such as
|
||||
@@ -7337,10 +7339,12 @@ $( "form" ).on( "keypress.validator", "input[type='text']", validate );
|
||||
$( "form" ).off( ".validator" );
|
||||
```
|
||||
*/
|
||||
off(events: string,
|
||||
off<TType extends string>(
|
||||
events: TType,
|
||||
selector_handler?: JQuery.Selector |
|
||||
JQuery.TypeEventHandler<TElement, any, any, any, string> |
|
||||
false): this;
|
||||
JQuery.TypeEventHandler<TElement, any, any, any, TType> |
|
||||
false
|
||||
): this;
|
||||
/**
|
||||
* Remove an event handler.
|
||||
* @param events An object where the string keys represent one or more space-separated event types and optional
|
||||
@@ -11968,9 +11972,10 @@ $( "p" ).bind( "click", foo ); // ... Now foo will be called when paragraphs are
|
||||
$( "p" ).unbind( "click", foo ); // ... foo will no longer be called.
|
||||
```
|
||||
*/
|
||||
unbind(event: string,
|
||||
handler: JQuery.TypeEventHandler<TElement, any, TElement, TElement, string> |
|
||||
false
|
||||
unbind<TType extends string>(
|
||||
event: TType,
|
||||
handler: JQuery.TypeEventHandler<TElement, any, TElement, TElement, TType> |
|
||||
false
|
||||
): this;
|
||||
/**
|
||||
* Remove a previously-attached event handler from the elements.
|
||||
@@ -12062,10 +12067,11 @@ $( "body" ).delegate( "p", "click", foo );
|
||||
$( "body" ).undelegate( "p", "click", foo );
|
||||
```
|
||||
*/
|
||||
undelegate(selector: JQuery.Selector,
|
||||
eventType: string,
|
||||
handler: JQuery.TypeEventHandler<TElement, any, any, any, string> |
|
||||
false
|
||||
undelegate<TType extends string>(
|
||||
selector: JQuery.Selector,
|
||||
eventType: TType,
|
||||
handler: JQuery.TypeEventHandler<TElement, any, any, any, TType> |
|
||||
false
|
||||
): this;
|
||||
/**
|
||||
* Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.
|
||||
|
||||
@@ -3969,12 +3969,17 @@ function JQuery() {
|
||||
|
||||
function customData(this: HTMLElement, event: JQuery.TriggeredEvent<HTMLElement, string>) { }
|
||||
|
||||
function specificEventType(this: HTMLElement, event: JQuery.MouseDownEvent<HTMLElement>) { }
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', 'td', defaultData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', 'td', customData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('mousedown', 'td', specificEventType);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', 'td', false);
|
||||
|
||||
@@ -3987,6 +3992,9 @@ function JQuery() {
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', customData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('mousedown', specificEventType);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').off('myEvent', false);
|
||||
|
||||
@@ -4473,12 +4481,17 @@ function JQuery() {
|
||||
|
||||
function customData(this: HTMLElement, event: JQuery.TriggeredEvent<HTMLElement, string>) { }
|
||||
|
||||
function specificEventType(this: HTMLElement, event: JQuery.MouseDownEvent<HTMLElement>) { }
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').unbind('myEvent', defaultData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').unbind('myEvent', customData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').unbind('mousedown', specificEventType);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('p').unbind('myEvent', false);
|
||||
|
||||
@@ -4498,12 +4511,17 @@ function JQuery() {
|
||||
|
||||
function customData(this: HTMLElement, event: JQuery.TriggeredEvent<HTMLElement, string>) { }
|
||||
|
||||
function specificEventType(this: HTMLElement, event: JQuery.MouseDownEvent<HTMLElement>) { }
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').undelegate('td', 'click', defaultData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').undelegate('td', 'click', customData);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').undelegate('td', 'mousedown', specificEventType);
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$('table').undelegate('td', 'click', false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user