Ticket #5999 (closed bug: wontfix)
Firefox wraps an additional <a> tag around script-generated content
| Reported by: | Pete Morris | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.4.2 |
| Component: | core | Version: | 1.4.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
When running the attached test case script against jQuery 1.4 and 1.4.1, HTML block elements within an <a> tag that have their content changed via html() have that new content wrapped within an additional <a> tag. This behaviour did not occur within 1.3.2, and only occurs within Firefox. IE and Chrome do not exhibit the same behaviour. Inline elements such as <span> are not wrapped in this way. I realise it is probably considered 'bad' practice to wrap block elements within an inline <a> in terms of HTML, however the fact that it doesn't occur across browsers and was not present in 1.3.2 implies it is nonetheless unintentional. I have attached a test-case HTML file which when run on Firefox 3.5 produces two different result sets; IE and Chrome produce identical result sets.
Attachments
Change History
Changed 3 years ago by Pete Morris
-
attachment
testcase.zip
added
comment:1 Changed 3 years ago by Pete Morris
Same test case uploaded to: http://www.careers.manchester.ac.uk/dynamic/sandbox/jQuery/testcase/testcase.html
comment:2 Changed 3 years ago by john
- Status changed from new to closed
- Resolution set to wontfix
All we're doing in this case is using the standard .innerHTML provided by the browser.
For example, I adapted your test case to only use native browser methods and the bug is still happening: http://ejohn.org/files/jquery/ticket/5999/
Considering that the element is injected automatically I'm not sure that there's a way that we can reasonably work around it. I think we have to simply remove either: 1) Keep using your invalid markup and doing .empty().append(yourHTML) or 2) Use valid markup and don't encounter any weird cross-browser issues.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

ZIP file containing test case HTML file and the associated jQuery 1.4.1 needed to run it