Side navigation
#7456 closed bug (invalid)
Opened November 10, 2010 08:45AM UTC
Closed November 10, 2010 03:24PM UTC
Last modified May 04, 2011 06:19AM UTC
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));
Attachments (0)
Change History (7)
Changed November 10, 2010 08:49AM UTC by comment:1
Changed November 10, 2010 03:24PM UTC by comment:2
_comment0: | There is no signature of {{{jQuery()}} that accepts an xml string. → 1289402678494317 |
---|---|
resolution: | → invalid |
status: | new → closed |
There is no signature of
jQuery()that accepts an xml string.
Changed November 10, 2010 03:35PM UTC by comment:3
_comment0: | Replying to [comment:2 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? → 1289403676883550 |
---|
Replying to [comment:2 dmethvin]:
There is no signature ofjQuery()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?
Edit: Also it's removing the html-element. What if you would want to access the attributes of these elements?
Changed November 10, 2010 04:18PM UTC by comment:4
component: | unfiled → manipulation |
---|---|
keywords: | → needsdocs |
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/
Changed February 03, 2011 04:05PM UTC by comment:5
When using a CUSTOM tag Instead of DIV the content still includes HTML, HEAD and BODY tags.
Cheers
Florian
Changed February 03, 2011 04:30PM UTC by comment:6
Forget about what I said... :/
Changed May 04, 2011 06:19AM UTC by comment:7
keywords: | needsdocs |
---|
Updated: http://api.jquery.com/jQuery/
For the lazy, jsfiddle test case here: http://jsfiddle.net/mekwall/xKEqa/