From 83993bac9533e17f7a469aae02f79f7e68decb7a Mon Sep 17 00:00:00 2001 From: kimamula Date: Wed, 30 Sep 2015 00:26:52 +0900 Subject: [PATCH] update jQuery.append, prepend, before and after --- jquery/jquery-tests.ts | 17 ++++++++++++++--- jquery/jquery.d.ts | 16 ++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 1f723fde32..b9e835ebc7 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -41,7 +41,7 @@ function test_addClass() { function test_after() { $('.inner').after('

Test

'); - $('
').after('

'); + $('
').after('

').after(document.createDocumentFragment()); $('
').after('

').addClass('foo') .filter('p').attr('id', 'bar').html('hello') .end() @@ -504,7 +504,7 @@ function test_toggle() { function test_append() { $('.inner').append('

Test

'); - $('.container').append($('h2')); + $('.container').append($('h2')).append(document.createDocumentFragment()); var $newdiv1 = $('
'), newdiv2 = document.createElement('div'), @@ -554,7 +554,7 @@ function test_attributeSelectors() { function test_before() { $('.inner').before('

Test

'); - $('.container').before($('h2')); + $('.container').before($('h2')).before(document.createDocumentFragment()); $("
").before("

"); var $newdiv1 = $('
'), newdiv2 = document.createElement('div'), @@ -941,6 +941,17 @@ function test_clone() { .clone()); } +function test_prepend() { + $('.inner').prepend('

Test

'); + $('.container').prepend($('h2')).prepend(document.createDocumentFragment()); + + var $newdiv1 = $('
'), + newdiv2 = document.createElement('div'), + existingdiv1 = document.getElementById('foo'); + + $('body').prepend($newdiv1, [newdiv2, existingdiv1]); +} + function test_prependTo() { $("

Test

").prependTo(".inner"); $("h2").prependTo($(".container")); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 3641af8503..8f99ce3d5d 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2579,10 +2579,10 @@ interface JQuery { /** * Insert content, specified by the parameter, after each element in the set of matched elements. * - * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert after each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. */ - after(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + after(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, after each element in the set of matched elements. * @@ -2593,10 +2593,10 @@ interface JQuery { /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. * - * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. */ - append(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + append(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. * @@ -2614,10 +2614,10 @@ interface JQuery { /** * Insert content, specified by the parameter, before each element in the set of matched elements. * - * param content1 HTML string, DOM element, array of elements, or jQuery object to insert before each element in the set of matched elements. + * param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert before each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. */ - before(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + before(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, before each element in the set of matched elements. * @@ -2662,10 +2662,10 @@ interface JQuery { /** * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. * - * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + * param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. */ - prepend(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + prepend(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. *