From 44eb8f38a3f020f317f5b765142e49d0aa23dda8 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 5 Dec 2013 17:08:05 +0000 Subject: [PATCH] jQuery: added data JSDoc + a little generic love --- jquery/jquery-tests.ts | 2 ++ jquery/jquery.d.ts | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index a77de77d7..434cf2554 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -889,6 +889,8 @@ function test_data() { jQuery.data(div, "test", { first: 16, last: "pizza!" }); $("span:first").text(jQuery.data(div, "test").first); $("span:last").text(jQuery.data(div, "test").last); + $.data(document.getElementById("id"), "", 8).toFixed(2); + $.data(document.getElementById("id"), "", "8").toUpperCase(); } function test_dblclick() { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index a8d6be7d6..4b8e9f49c 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -529,9 +529,26 @@ interface JQueryStatic { cssHooks: { [key: string]: any; }; cssNumber: any; - // Data - data(element: Element, key: string, value: any): any; + /** + * Store arbitrary data associated with the specified element. Returns the value that was set. + * + * @param element The DOM element to associate with the data. + * @param key A string naming the piece of data to set. + * @param value The new data value. + */ + data(element: Element, key: string, value: T): T; + /** + * 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. + * + * @param element The DOM element to associate with the data. + * @param key A string naming the piece of data to set. + */ data(element: Element, key: string): any; + /** + * 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. + * + * @param element The DOM element to associate with the data. + */ data(element: Element): any; dequeue(element: Element, queueName?: string): any;