Skip to main content

Bug Tracker

Side navigation

#940 closed bug (invalid)

Opened February 11, 2007 07:28PM UTC

Closed February 25, 2007 06:35PM UTC

Last modified June 20, 2007 01:56AM UTC

FireFox and $(exp, context)

Reported by: ProjectAtomic Owned by:
Priority: minor Milestone:
Component: core Version:
Keywords: Cc:
Blocked by: Blocking:
Description

Ran this test page in FireFox 2.0.0.1:

<head>

<title>Test</title>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

(function($) {

$.fn.test = function(){

return this.each(function(){

var g = $('a', this);

$(g).click(function(){

var i = $(g).index($(this)[0]);

alert(i+' '+g.length);

return false;

});

});

};

})(jQuery);

$(function(){

$('div#mydiv').test();

});

</script>

</head>

<body>

<div id="mydiv">

<a href="http://google.com">Google</a>

<a href="http://msn.com">MSN</a>

<a href="http://yahoo.com">Yahoo</a>

</div>

</body>

Clicked on MSN and got expected result: '1 3' (index, length)

I added <a id="myanchor" /> ' BEFORE '<div id="mydiv">' and ran test again.

<a id="myanchor" />

<div id="mydiv">

<a href="http://google.com">Google</a>

<a href="http://msn.com">MSN</a>

<a href="http://yahoo.com">Yahoo</a>

</div>

Clicked on MSN and got: '2 4'

<a id="myanchor"></a>

<div id="mydiv">

<a href="http://google.com">Google</a>

<a href="http://msn.com">MSN</a>

<a href="http://yahoo.com">Yahoo</a>

</div>

Clicked on MSN and got: '1 3' again

IE7 returned expected result of '1 3' in all cases.

This only seems to happen with self closing tags which are valid XHTML

Attachments (0)
Change History (1)

Changed February 25, 2007 06:35PM UTC by john comment:1

resolution: → invalid
status: newclosed

This has to do with how browsers close tags in XHTML. IE is very bad at this in all cases. The issue is that you're attempting to perform these XML/XHTML actions on a page that isn't even XHTML (or served with the right mimetype). Until that is rectified, it's really not possible to test this.