Side navigation
#6626 closed bug (invalid)
Opened June 02, 2010 06:36PM UTC
Closed June 03, 2010 01:02AM UTC
not() and filter() not behaving correctly when used with $(array)
Reported by: | tafandi | Owned by: | |
---|---|---|---|
Priority: | Milestone: | 1.4.3 | |
Component: | traversing | Version: | 1.4.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If we create a jQuery object from an array, and then apply not() and filter() on that object, the result won't be correct.
The following code is used for testing. The top part (using selector, ie. $('tr') is the control showing the correct result as a comparison). The bottom part (creating an array and then creating a jQuery object based on them) is the incorrect result demonstrating this bug.
The test is done on:
- FF 3.6.3
- IE 8.0.6001.18702
- Chrome 4.1.249.1064 unknown (45376)
<html> <head> <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ var logstr = ''; function log(s) { logstr += s + '\\n'; } function test(s, o) { with (o) { log(s + ' length: ' + length); log(s + ' not(".bottom"): ' + not('.bottom').length); log(s + ' filter(".bottom"): ' + filter('.bottom').length); log(s + ' not("tr.bottom"): ' + not('tr.bottom').length); log(s + ' filter("tr.bottom"): ' + filter('tr.bottom').length); } } var tr = $('tr'); test('selector', tr); log(''); var rows = new Array(), i = 0; tr.each(function() { rows[i] = $(this); i++; }); test('array', $(rows)); alert(logstr); }); </script> </head> <body> <table> <tbody> <tr><td>1</td></tr> <tr class="bottom"><td>x</td></tr> <tr><td>2</td></tr> <tr class="bottom"><td>y</td></tr> <tr><td>3</td></tr> <tr class="bottom"><td>z</td></tr> <tr><td>4</td></tr> </tbody> </table> </body> </html>
Attachments (1)
Change History (1)
Changed June 03, 2010 01:02AM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |