jQuery: data JSDoc

and removeData test suite
This commit is contained in:
John Reilly
2014-01-10 13:51:27 +00:00
parent c733d25651
commit 9d4f888a30
2 changed files with 53 additions and 3 deletions

View File

@@ -898,6 +898,16 @@ function test_data() {
$.data(document.getElementById("id"), "", "8").toUpperCase();
}
function test_removeData() {
$("span:eq(0)").text("" + $("div").data("test1"));
$("div").data("test1", "VALUE-1");
$("div").data("test2", "VALUE-2");
$("span:eq(1)").text("" + $("div").data("test1"));
$("div").removeData("test1");
$("span:eq(2)").text("" + $("div").data("test1"));
$("span:eq(3)").text("" + $("div").data("test2"));
}
function test_dblclick() {
$('#target').dblclick(function () {
alert('Handler for .dblclick() called.');

46
jquery/jquery.d.ts vendored
View File

@@ -1130,16 +1130,56 @@ interface JQuery {
*/
width(func: (index: number, width: number) => string): JQuery;
// Data
/**
* Remove from the queue all items that have not yet been run.
*
* @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
*/
clearQueue(queueName?: string): JQuery;
/**
* Store arbitrary data associated with the matched elements.
*
* @param key A string naming the piece of data to set.
* @param value The new data value; it can be any Javascript type including Array or Object.
*/
data(key: string, value: any): JQuery;
/**
* Store arbitrary data associated with the matched elements.
*
* @param obj An object of key-value pairs of data to update.
*/
data(obj: { [key: string]: any; }): JQuery;
data(key?: string): any;
/**
* 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.
*
* @param key Name of the data stored.
*/
data(key: string): any;
/**
* 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.
*/
data(): any;
/**
* Execute the next function on the queue for the matched elements.
*
* @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.
*/
dequeue(queueName?: string): JQuery;
removeData(nameOrList?: any): JQuery;
/**
* Remove a previously-stored piece of data.
*
* @param name A string naming the piece of data to delete or space-separated string naming the pieces of data to delete.
*/
removeData(name: string): JQuery;
/**
* Remove a previously-stored piece of data.
*
* @param list An array of strings naming the pieces of data to delete.
*/
removeData(list: string[]): JQuery;
// Deferred
promise(type?: any, target?: any): JQueryPromise<any>;