Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#6475 closed bug (invalid)

jQuery adds new HTML tags when calling manipulation methods

Reported by: danielfranz Owned by:
Priority: undecided Milestone: 1.4.3
Component: unfiled Version: 1.4.2
Keywords: Manipulation HTML xmlns Cc:
Blocked by: Blocking:


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.

Change History (2)

comment:1 Changed 13 years ago by dmethvin

Resolution: invalid
Status: newclosed

Can you reopen this with a complete test case? Please run the document through the XHTML validator, and check in Firebug that the markup is as you expect before using jQuery to set the attribute.

comment:2 Changed 13 years ago by jitter

Priority: undecided

Doesn't happen for me test case

Note: See TracTickets for help on using tickets.