Bug Tracker

Modify

Ticket #6475 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

Description

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/">

Example:

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

comment:1 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

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 3 years ago by jitter

  • Priority set to undecided

Doesn't happen for me  test case

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.