Skip to main content

Bug Tracker

Side navigation

#2604 closed bug ()

Opened March 27, 2008 08:41PM UTC

Closed November 11, 2010 11:09PM UTC

Last modified March 15, 2012 09:18AM UTC

jQuery(html) breaks with HTML comments in Firefox 2

Reported by: scottgonzalez Owned by: scottgonzalez
Priority: low Milestone: 1.2.4
Component: core Version: 1.2.3
Keywords: html comments Cc:
Blocked by: Blocking:
Description
var html = '<div>foo</div><!-- bar -->';

// throws an error
$(html).hide();

// works fine
$('<div/>').html(html).children().hide();
Attachments (1)
  • clean-comments.diff (1.0 KB) - added by flesler May 15, 2008 01:50PM UTC.

    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 (9)

Changed March 28, 2008 05:53AM UTC by davidserduke comment:1

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 May 14, 2008 10:43PM UTC by flesler comment:2

resolution: → wontfix
status: newclosed

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 May 15, 2008 01:35PM UTC by scott.gonzal comment:3

resolution: wontfix
status: closedreopened

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 May 16, 2008 06:58PM UTC by flesler comment:4

owner: → flesler
status: reopenednew

Changed October 21, 2010 04:55AM UTC by anonymous comment:5

hello

Changed October 21, 2010 08:20PM UTC by SlexAxton comment:6

keywords: → html comments
owner: fleslerscott.gonzalez
priority: majorlow
status: newpending

Is this still something anyone cares about?

Changed November 11, 2010 11:09PM UTC by trac-o-bot comment:7

status: pendingclosed

Automatically closed due to 14 days of inactivity.

Changed November 12, 2010 09:32PM UTC by anonymous comment:8

This is causing problems for me. Please fix.

Changed November 19, 2010 07:06AM UTC by snover comment:9

_comment0: We don’t support Firefox 2 any more.1290150382621607

We don’t support Firefox 2 any more. This will never be fixed.