Bug Tracker

Opened 17 years ago

Closed 16 years ago

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

Description (last modified by davidserduke)

$('<!-- 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 (1)

1039.diff (13.4 KB) - added by davidserduke 16 years ago.
patch

Download all attachments as: .zip

Change History (6)

comment:1 Changed 17 years ago by john

need: Test Case

comment:2 Changed 17 years ago by joern

need: Test CaseReview

What is the expected behaviour here?

$('<!-- comment -->') -> []? 
$('<div></div><!-- comment --><div></div>') => [div, div]?

comment:3 Changed 16 years ago by davidserduke

Description: modified (diff)
Owner: set to davidserduke
Status: newassigned

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.

comment:4 Changed 16 years ago by davidserduke

Milestone: 1.1.31.2.2

Changed 16 years ago by davidserduke

Attachment: 1039.diff added

patch

comment:5 Changed 16 years ago by davidserduke

Resolution: fixed
Status: assignedclosed

Fixed in [4062] such that the comment node will be included if the browser allows it, but the rest of jQuery will not break having a comment node in the jQuery object.

Note: See TracTickets for help on using tickets.