Skip to main content

Bug Tracker

Side navigation

#7711 closed bug (invalid)

Opened December 06, 2010 01:06PM UTC

Closed December 06, 2010 02:28PM UTC

last, first bad cached

Reported by: anonymous Owned by:
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

var questor = $("td");

var obj = questor.last(".class1");

var objRet2 = questor.last(".class2"); /*bug return cached result obj*/

//same with selector first;

Attachments (0)
Change History (1)

Changed December 06, 2010 02:28PM UTC by jitter comment:1

_comment0: Thanks for taking the time to contribute to the jQuery project by writing a bug report. This is no bug in jQuery but rather a misunderstanding on what `.last()` does. The [http://api.jquery.com/last/ documentation for last()] says: \ > Reduce the set of matched elements to the final one in the set. \ Also the api is specified as `.last()` (note how there is no parameter to this method). \ \ So as you can see from the documentation the `last()` method doesn't accept any parameters it just returns a new jQuery object containing exactly one element (the last from the set of the jQuery object you call it on). \ \ [http://jsfiddle.net/jitter/5WMYf/ live test case]1291645765674400
_comment1: Thanks for taking the time to contribute to the jQuery project by writing a bug report. After checking your report I come to the conclusion that this is no bug in jQuery but rather a misunderstanding on what `.last()` does. The [http://api.jquery.com/last/ documentation for last()] says: \ > Reduce the set of matched elements to the final one in the set. \ Also the api is specified as `.last()` (note how there is no parameter to this method). \ \ So as you can see from the documentation the `last()` method doesn't accept any parameters it just returns a new jQuery object containing exactly one element (the last from the set of the jQuery object you call it on). \ \ [http://jsfiddle.net/jitter/5WMYf/ live test case]1291645822710795
_comment2: Thanks for taking the time to contribute to the jQuery project by writing a bug report. After checking your report I come to the conclusion that this is no bug in jQuery but rather a misunderstanding on what `.last()` does.\\\\The [http://api.jquery.com/last/ documentation for last()] says: \ > Reduce the set of matched elements to the final one in the set. \ Also the api is specified as `.last()` (note how there is no parameter to this method, the same holds for `.first()`). \ \ So as you can see from the documentation the `last()` method doesn't accept any parameters it just returns a new jQuery object containing exactly one element (the last one from the set of the jQuery object you call it on). \ \ [http://jsfiddle.net/jitter/5WMYf/ live test case]1291645910064183
resolution: → invalid
status: newclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug report. After checking your report I come to the conclusion that this is no bug in jQuery but rather a misunderstanding on what .last() does.\\\\The documentation for last() says:

Reduce the set of matched elements to the final one in the set.

Also the api is specified as .last() (note how there is no parameter to this method, the same holds for .first()).

So as you can see from the documentation the last() method doesn't accept any parameters it just returns a new jQuery object containing exactly one element (the last one from the set of the jQuery object you call it on). This is way you get the same result twice, the two calls are identical as the parameter gets ignored.

live test case