Bug Tracker

Modify

Ticket #1039 (closed bug: fixed)

Opened 6 years ago

Last modified 5 years ago

$(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

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

Change History

comment:1 Changed 6 years ago by john

  • need set to Test Case

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.

comment:4 Changed 5 years ago by davidserduke

  • Milestone changed from 1.1.3 to 1.2.2

Changed 5 years ago by davidserduke

patch

comment:5 Changed 5 years ago by davidserduke

  • Status changed from assigned to closed
  • Resolution set to fixed

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.

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.