From 9cd2d6f51ab340559f647ca2ef911cf074934f7a Mon Sep 17 00:00:00 2001 From: Terry Mun Date: Tue, 11 Sep 2018 13:29:18 +0200 Subject: [PATCH 1/4] .appendTo() should accept a document fragment as an argument (not just Element) --- types/jquery/index.d.ts | 2 +- types/jquery/jquery-tests.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index b03a48dc6f..5183ffd2ba 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -3487,7 +3487,7 @@ interface JQuery extends Iterable { * @see \`{@link https://api.jquery.com/appendTo/ }\` * @since 1.0 */ - appendTo(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; + appendTo(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; /** * Set one or more attributes for the set of matched elements. * diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 417d2e7941..72d23a2e8b 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -5670,6 +5670,9 @@ function JQuery() { // $ExpectType JQuery $('span').appendTo($('p')); + + // $ExpectType JQuery + $('span').appendTo(document.createDocumentFragment()); } function insertAfter() { From 2faff4872de70dd89e1d903a7403e264f8a1a455 Mon Sep 17 00:00:00 2001 From: Terry Mun Date: Tue, 11 Sep 2018 13:38:05 +0200 Subject: [PATCH 2/4] Added author credits --- types/jquery/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 5183ffd2ba..b9582cfba1 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -21,6 +21,7 @@ // John Reilly // Dick van den Brink // Thomas Schulz +// Terry Mun // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 8d250ffcd896bad1b4708c1b34925403eab7ded5 Mon Sep 17 00:00:00 2001 From: Terry Mun Date: Sat, 15 Sep 2018 11:43:11 +0200 Subject: [PATCH 3/4] `prependTo()` and `appendTo()` should work with `Element` or `DocumentFragment` --- types/jquery/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index b9582cfba1..0cd4c27b89 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -3488,7 +3488,7 @@ interface JQuery extends Iterable { * @see \`{@link https://api.jquery.com/appendTo/ }\` * @since 1.0 */ - appendTo(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; + appendTo(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; /** * Set one or more attributes for the set of matched elements. * @@ -5079,7 +5079,7 @@ interface JQuery extends Iterable { * @see \`{@link https://api.jquery.com/prependTo/ }\` * @since 1.0 */ - prependTo(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; + prependTo(target: JQuery.Selector | JQuery.htmlString | JQuery.TypeOrArray | JQuery): this; /** * Get the immediately preceding sibling of each element in the set of matched elements. If a selector * is provided, it retrieves the previous sibling only if it matches that selector. From bf4b60d283291f57a15f2da543694a4dc6e25694 Mon Sep 17 00:00:00 2001 From: Terry Mun Date: Sat, 15 Sep 2018 11:51:22 +0200 Subject: [PATCH 4/4] Updated tests to include prepending to document fragment --- types/jquery/jquery-tests.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 72d23a2e8b..3d04dca165 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -5736,6 +5736,9 @@ function JQuery() { // $ExpectType JQuery $('span').prependTo($('p')); + + // $ExpectType JQuery + $('span').prependTo(document.createDocumentFragment()); } function clone() {