Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#940 closed bug (invalid)

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

Change History (1)

comment:1 Changed 15 years ago by john

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.

Note: See TracTickets for help on using tickets.