Ticket #1039 (closed bug: fixed)
$(html) fails with html comment
| Reported by: | arrix | Owned by: | davidserduke |
|---|---|---|---|
| Priority: | major | Milestone: | 1.2.2 |
| Component: | core | Version: | 1.1.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description (last modified by davidserduke) (diff)
$('<!-- comment -->') -> [[undefined, undefined]]
$('<div></div><!-- comment --><div></div>') -> [div, [undefined, undefined, undefined, 6 more...], div]
Although it seems absurd to pass in html comment when hand coding, sometimes the argument is generated from a design html page. So there are chances that the html string passed to $ contains comments.
Attachments
Change History
comment:2 Changed 6 years ago by joern
- need changed from Test Case to Review
What is the expected behaviour here?
$('<!-- comment -->') -> []?
$('<div></div><!-- comment --><div></div>') => [div, div]?
comment:3 Changed 6 years ago by davidserduke
- Owner set to davidserduke
- Status changed from new to assigned
- Description modified (diff)
Is this a bad thing? From what I can tell it is a comment node and works fine when inserted. Then the question would be can jQuery handle it and might be a similar ticket to #1733 which discusses the problems with text nodes. the [undefined, undefined, undefined, 6 more...] part is just FireBugs representation of the node as an array because it has a length property and not a problem in itself that I can see.
I don't see a problem with leaving the comments in as long as jQuery is robust enough to handle it correctly.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

