id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,blocking,blockedby
1888,jQuery(string) create not valid DOM when string is html with newlines,lucifer4u,,"It is common task to get html from server and to work with it in its own context. 
I have test.html file with this content:
{{{
<html>
  <head>
    <title>
      Test page
    </title>
  </head>
  <body>
    <div>
      Some information
    </div>
  </body>
</html>
}}}
So after trying
{{{
$.get(""test.html"",function(data){alert($(data).find(""div"");}) 
}}}
i found an error. Here is more info about:

Test examples:

{{{
			var s1 = '<html><head><title>info</title></head><body><div>info</div></body></html>';
			alert($(s1).find('div')); // [object Object]
			var s2 = '<html>\n<head><title>info</title></head><body><div>info</div></body></html>';
			alert($(s2).find('div')); // [error]
}}}

Solution:

{{{
			function jquery_from_html(data) {
				return $(""<moo/>"").append(data);
			}

}}}

Example of usage:

{{{
			$.get(
				""test.html"",
				{},
				function(data){
					d = $(""div#system"", jquery_from_html(s));
					alert(d.text());		
				},
				""html""
			)
}}}

Found in jquery source in load function:

{{{
						// Create a dummy div to hold the results
						jQuery(""<div/>"")

}}}",bug,closed,major,1.2.2,ajax,1.2.1,fixed,,,,
