diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 0fed71bf4..440a56707 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -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.'); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 9bc102ca0..f21670ba7 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -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;