Bug Tracker

Ticket #1039 (closed bug: fixed)

Opened 1 year ago

Last modified 9 months ago

$(html) fails with html comment

Reported by: arrix Assigned to: davidserduke
Type: bug Priority: major
Milestone: 1.2.2 Component: core
Version: 1.1.2 Keywords:
Cc: Needs: Review

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 (13.4 kB) - added by davidserduke 9 months ago.
patch

Change History

Changed 1 year ago by john

  • need set to Test Case

Changed 1 year ago by joern

  • need changed from Test Case to Review

What is the expected behaviour here?

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

Changed 9 months ago by davidserduke

  • owner set to davidserduke
  • status changed from new to assigned
  • description changed from {{{ $('<!-- 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. to {{{ $('<!-- 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.

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.

Changed 9 months ago by davidserduke

  • milestone changed from 1.1.3 to 1.2.2

Changed 9 months ago by davidserduke

patch

Changed 9 months 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.

Note: See TracTickets for help on using tickets.