From f7cfda9f1a6d4de9953f23db03fd5095ac216d41 Mon Sep 17 00:00:00 2001 From: Robert Dennis Date: Mon, 20 Apr 2015 13:59:13 -0400 Subject: [PATCH 1/7] Add optional jQueryAlias to $(callback) and $().ready(callback). --- DefinitelyTyped.sln | 16 ++++++++++++++++ jquery/jquery.d.ts | 22 ++++++++++++++-------- 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 DefinitelyTyped.sln diff --git a/DefinitelyTyped.sln b/DefinitelyTyped.sln new file mode 100644 index 0000000000..98daf5f12a --- /dev/null +++ b/DefinitelyTyped.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "jquery", "jquery", "{0F6EC0BB-B970-4DA2-84BD-E851D33A4EE7}" + ProjectSection(SolutionItems) = preProject + jquery\jquery-tests.ts = jquery\jquery-tests.ts + jquery\jquery.d.ts = jquery\jquery.d.ts + EndProjectSection +EndProject +Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 61fd624422..6a7bc47c2e 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -725,30 +725,42 @@ interface JQueryStatic { * @param context A DOM Element, Document, or jQuery to use as context */ (selector: string, context?: Element|JQuery): JQuery; + /** * Accepts a string containing a CSS selector which is then used to match a set of elements. * * @param element A DOM element to wrap in a jQuery object. */ (element: Element): JQuery; + /** * Accepts a string containing a CSS selector which is then used to match a set of elements. * * @param elementArray An array containing a set of DOM elements to wrap in a jQuery object. */ (elementArray: Element[]): JQuery; + + /** + * Binds a function to be executed when the DOM has finished loading. + * + * @param callback A function to execute after the DOM is ready. + */ + (callback: (jQueryAlias?: JQueryStatic) => any): JQuery; + /** * Accepts a string containing a CSS selector which is then used to match a set of elements. * * @param object A plain object to wrap in a jQuery object. */ (object: {}): JQuery; + /** * Accepts a string containing a CSS selector which is then used to match a set of elements. * * @param object An existing jQuery object to clone. */ (object: JQuery): JQuery; + /** * Specify a function to execute when the DOM is fully loaded. */ @@ -761,6 +773,7 @@ interface JQueryStatic { * @param ownerDocument A document in which the new elements will be created. */ (html: string, ownerDocument?: Document): JQuery; + /** * Creates DOM elements on the fly from the provided string of raw HTML. * @@ -769,13 +782,6 @@ interface JQueryStatic { */ (html: string, attributes: Object): JQuery; - /** - * Binds a function to be executed when the DOM has finished loading. - * - * @param callback A function to execute after the DOM is ready. - */ - (callback: Function): JQuery; - /** * Relinquish jQuery's control of the $ variable. * @@ -2352,7 +2358,7 @@ interface JQuery { * * @param handler A function to execute after the DOM is ready. */ - ready(handler: Function): JQuery; + ready(handler: (jQueryAlias?: JQueryStatic) => any): JQuery; /** * Trigger the "resize" event on an element. From 7af9d14d44862ac66c88d9dac5649869f37ef016 Mon Sep 17 00:00:00 2001 From: Robert Dennis Date: Mon, 20 Apr 2015 14:05:34 -0400 Subject: [PATCH 2/7] Removed .sln --- DefinitelyTyped.sln | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 DefinitelyTyped.sln diff --git a/DefinitelyTyped.sln b/DefinitelyTyped.sln deleted file mode 100644 index 98daf5f12a..0000000000 --- a/DefinitelyTyped.sln +++ /dev/null @@ -1,16 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "jquery", "jquery", "{0F6EC0BB-B970-4DA2-84BD-E851D33A4EE7}" - ProjectSection(SolutionItems) = preProject - jquery\jquery-tests.ts = jquery\jquery-tests.ts - jquery\jquery.d.ts = jquery\jquery.d.ts - EndProjectSection -EndProject -Global - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal From b95c1c9d13ed785065e38ecf5b89494cabce0a1e Mon Sep 17 00:00:00 2001 From: Robert Dennis Date: Tue, 21 Apr 2015 10:15:41 -0400 Subject: [PATCH 3/7] Fix query.dataTables column.render signature --- jquery.dataTables/jquery.dataTables.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.dataTables/jquery.dataTables.d.ts b/jquery.dataTables/jquery.dataTables.d.ts index cbcb1c0257..b77dc002af 100755 --- a/jquery.dataTables/jquery.dataTables.d.ts +++ b/jquery.dataTables/jquery.dataTables.d.ts @@ -1513,7 +1513,7 @@ declare module DataTables { } interface FunctionColumnRender { - (data: Node, t: Node, row: Node, meta: Object): void; + (data: any, t: string, row: any, meta: { row: number; col: number; settings: DataTables.Settings }): any; } //#endregion "colunm-settings" From cb0871ac960e71f597271ff853e1049fe7b50e9e Mon Sep 17 00:00:00 2001 From: Robert Dennis Date: Tue, 21 Apr 2015 10:26:44 -0400 Subject: [PATCH 4/7] Revert "Removed .sln" This reverts commit 7af9d14d44862ac66c88d9dac5649869f37ef016. --- DefinitelyTyped.sln | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 DefinitelyTyped.sln diff --git a/DefinitelyTyped.sln b/DefinitelyTyped.sln new file mode 100644 index 0000000000..98daf5f12a --- /dev/null +++ b/DefinitelyTyped.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "jquery", "jquery", "{0F6EC0BB-B970-4DA2-84BD-E851D33A4EE7}" + ProjectSection(SolutionItems) = preProject + jquery\jquery-tests.ts = jquery\jquery-tests.ts + jquery\jquery.d.ts = jquery\jquery.d.ts + EndProjectSection +EndProject +Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal From d5fe00d3f5e9bbe1a8ffb18b5ea9556bf0067810 Mon Sep 17 00:00:00 2001 From: Robert Dennis Date: Tue, 21 Apr 2015 10:42:20 -0400 Subject: [PATCH 5/7] Remove .sln --- DefinitelyTyped.sln | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 DefinitelyTyped.sln diff --git a/DefinitelyTyped.sln b/DefinitelyTyped.sln deleted file mode 100644 index 98daf5f12a..0000000000 --- a/DefinitelyTyped.sln +++ /dev/null @@ -1,16 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "jquery", "jquery", "{0F6EC0BB-B970-4DA2-84BD-E851D33A4EE7}" - ProjectSection(SolutionItems) = preProject - jquery\jquery-tests.ts = jquery\jquery-tests.ts - jquery\jquery.d.ts = jquery\jquery.d.ts - EndProjectSection -EndProject -Global - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal From 554a62d829561b05fc1c0c410c04b48b9dca736a Mon Sep 17 00:00:00 2001 From: Robert Dennis Date: Tue, 21 Apr 2015 11:13:17 -0400 Subject: [PATCH 6/7] Revert "Fix query.dataTables column.render signature" This reverts commit b95c1c9d13ed785065e38ecf5b89494cabce0a1e. --- jquery.dataTables/jquery.dataTables.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.dataTables/jquery.dataTables.d.ts b/jquery.dataTables/jquery.dataTables.d.ts index b77dc002af..cbcb1c0257 100755 --- a/jquery.dataTables/jquery.dataTables.d.ts +++ b/jquery.dataTables/jquery.dataTables.d.ts @@ -1513,7 +1513,7 @@ declare module DataTables { } interface FunctionColumnRender { - (data: any, t: string, row: any, meta: { row: number; col: number; settings: DataTables.Settings }): any; + (data: Node, t: Node, row: Node, meta: Object): void; } //#endregion "colunm-settings" From dd393c9e0f182009a65e9b9ab411e39d8e5a64b8 Mon Sep 17 00:00:00 2001 From: Robert Dennis Date: Thu, 23 Apr 2015 10:12:44 -0400 Subject: [PATCH 7/7] Add tests for jQuery failsafe syntax --- jquery/jquery-tests.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 006140f2fd..3853a8d5f9 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -2511,10 +2511,10 @@ function test_jQuery() { $foo.triggerHandler('eventName'); $("div > p").css("border", "1px solid gray"); $("input:radio", document.forms[0]); - var xml: any; + var xml: any; $("div", xml.responseXML); $(document.body).css("background", "black"); - var myForm: any; + var myForm: any; $(myForm.elements).hide(); $('

My new text

').appendTo('body'); $(''); @@ -2537,6 +2537,10 @@ function test_jQuery() { } }).appendTo("body"); jQuery(function ($) { + // Your code using failsafe $ alias here... + }); + jQuery(document).ready(function ($) { + // Your code using failsafe $ alias here... }); }