diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 3b7b3b225..84ac9344e 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -2257,4 +2257,26 @@ function test_addBack() { // Second Example $("div.after-addback").find("p").addBack().addClass("background"); +} + +// http://api.jquery.com/jQuery.parseHTML/ +function test_parseHTML() { + var $log = $( "#log" ), + str = "hello, my name is jQuery.", + html = $.parseHTML( str ), + nodeNames = []; + + // Append the parsed HTML + $log.append( html ); + + // Gather the parsed HTML's node names + $.each( html, function( i, el ) { + nodeNames[i] = "
  • " + el.nodeName + "
  • "; + }); + + // Insert the node names + $log.append( "

    Node Names:

    " ); + $( "
      " ) + .append( nodeNames.join( "" ) ) + .appendTo( $log ); } \ No newline at end of file diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 10575fcd4..cfde73096 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -353,6 +353,15 @@ interface JQueryStatic { type(obj: any): string; unique(arr: any[]): any[]; + + /** + * Parses a string into an array of DOM nodes. + * + * @param data HTML string to be parsed + * @param context DOM element to serve as the context in which the HTML fragment will be created + * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string + */ + parseHTML(data: string, context?: HTMLElement, keepScripts?: bool): any[]; } /*