Bug Tracker

Modify

Ticket #940 (closed bug: invalid)

Opened 6 years ago

Last modified 6 years ago

FireFox and $(exp, context)

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

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

comment:1 Changed 6 years ago by john

  • Status changed from new to closed
  • Resolution set to invalid

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.