Ticket #6475 (closed bug: invalid)
jQuery adds new HTML tags when calling manipulation methods
|Reported by:||danielfranz||Owned by:|
|Keywords:||Manipulation HTML xmlns||Cc:|
Not sure if this should be considered a bug.
It happens i.e. in Moz Firefox 3.6.3 (WIN) with the following doctype def: <!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 TransitionalEN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=" http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:meebo="http://www.meebo.com/">
I have this code: <a id="anchor"> <div> <p>Text</p> </div> </a>
I do this: <script> $('#anchor').attr('href','test.php'); </script>
Then I end up with this: <a href="test.php" id="anchor"> <div> <p> <a xmlns=" http://www.w3.org/1999/xhtml">Text</a> </p> </div> </a>
Question: Is it necessary for jQuery to add the extra <a> tag between the <div> and the <p>? I know that nesting all that stuff in the outer <a/> is not really lean in the first place but browsers have no problems interpreting it right. So if the extra <a/> is not really mandatory for some future strict xmlns I would generally prefer to keep the code like it is. Limiting methods like attr() or html() to execute what they are asked to.
Thanks guys, you re doing a great job there.