#7456 closed bug (invalid)
jQuery removes body-element when parsing string with html or xml
Reported by: | mekwall | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.5 |
Component: | manipulation | Version: | 1.4.4rc |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When passing a string with well formed xml or html jQuery will remove any body-element, but leave all children nodes intact.
This can easily be reproduced by doing the following:
var xml = "<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Why is it not hitting this?</body></note>";
console.log($('to, from, heading, body', xml));
Change History (7)
comment:1 Changed 13 years ago by
comment:2 follow-up: 3 Changed 13 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
There is no signature of jQuery()
that accepts an xml string.
comment:3 Changed 13 years ago by
Replying to dmethvin:
There is no signature of
jQuery()
that accepts an xml string.
Well I also stated normal html, not only xml. I've also noticed that it removes head as well as seen here: http://jsfiddle.net/mekwall/s2K2x/
Is there a reason for this behavior?
comment:4 Changed 13 years ago by
Component: | unfiled → manipulation |
---|---|
Keywords: | needsdocs added |
Priority: | undecided → low |
I've marked this ticket needsdocs to have this paragraph from .load()
converted to an "Additional Notes" entry and added to all applicable methods.
jQuery uses the browser's .innerHTML property to parse the retrieved document and insert it into the current document. During this process, browsers often filter elements from the document such as <html>, <title>, or <head> elements. As a result, the elements retrieved by .load() may not be exactly the same as if the document were retrieved directly by the browser. -- http://api.jquery.com/load/
comment:5 follow-up: 6 Changed 12 years ago by
When using a CUSTOM tag Instead of DIV the content still includes HTML, HEAD and BODY tags. Cheers Florian
comment:7 Changed 12 years ago by
Keywords: | needsdocs removed |
---|
Updated: http://api.jquery.com/jQuery/
For the lazy, jsfiddle test case here: http://jsfiddle.net/mekwall/xKEqa/