Bug Tracker

Ticket #2604 (new bug)

Opened 8 months ago

Last modified 2 months ago

jQuery(html) breaks with HTML comments in Firefox 2

Reported by: scott.gonzalez Assigned to: flesler
Type: bug Priority: major
Milestone: 1.2.4 Component: core
Version: 1.2.3 Keywords:
Cc: Needs: Review

Description

var html = '<div>foo</div><!-- bar -->';
// throws an error
$(html).hide();
// works fine
$('<div/>').html(html).children().hide();

Attachments

clean-comments.diff (1.0 kB) - added by flesler 7 months ago.
This should fix this, but breaks 3 tests. I'll postpone this for now.. we have more critical tickets and we're close to a release.

Change History

Changed 8 months ago by davidserduke

It appears that the html comment is being created as a node in the jQuery object as expected. But when the :visible call is made on it, the jQuery.css is failing. I'd guess a check to see if the node is not appropriate in jQuery.css() would fix this.

Changed 7 months ago by flesler

  • status changed from new to closed
  • resolution set to wontfix

This seems to require checks on many places like $.filter, $.multiFilter and pretty much every DOM method. Most don't do any check, or they check for textNodes.

I'm not sure it's worthy. It's probably better to advice you to do:

$(html).filter('[nodeType=1]').hide();
or
$(html).not('[nodeType=8]').hide();

I'm closing as wontfix, reopen if you have something else to say.

Changed 7 months ago by scott.gonzalez

  • status changed from closed to reopened
  • resolution deleted

There are already a few methods that specifically check for comment nodes to make sure they get skipped. I think the most relevant check is in jQuery.merge() which ensures that comment nodes don't get merged in. A similar check could be added to jQuery.clean() to make sure that comment nodes are stripped before calling jQuery.makeArray().

Changed 7 months ago by flesler

This should fix this, but breaks 3 tests. I'll postpone this for now.. we have more critical tickets and we're close to a release.

Changed 7 months ago by flesler

  • owner set to flesler
  • status changed from reopened to new
Note: See TracTickets for help on using tickets.