Skip to main content

Bug Tracker

Side navigation

#10051 closed bug (fixed)

Opened August 14, 2011 09:27PM UTC

Closed August 16, 2011 02:58PM UTC

Last modified August 16, 2011 11:35PM UTC

Documentation bug: Inconsistent description of the "thisArg" value among methods that accept a function argument

Reported by: anonymous Owned by: kswedberg
Priority: undecided Milestone: None
Component: unfiled Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

The documentation for the attr() method http://api.jquery.com/attr/ states:

>function(index, attr) A function returning the value to set. ''this is the current element.'' ...


The documentation for the addClass() method http://api.jquery.com/addClass/ doesn't give any such statement, but shows a code example using this as an apparent reference to the current element.

$("ul li:last").addClass(function() {
  return "item-" + $(this).index();
});


The docs for other methods such as append() and prepend() that allow a function passed to determine the value set, have no mention whatsoever of this as a reference to the current DOM element.

If it is jQuery's intention to provide this as a means of referencing the current DOM element in such functions, then please update the documentation for such methods in order to make it officially supported behavior.

Attachments (0)
Change History (3)

Changed August 15, 2011 04:42PM UTC by kswedberg comment:1

owner: → kswedberg
status: newassigned

Changed August 16, 2011 02:58PM UTC by kswedberg comment:2

resolution: → fixed
status: assignedclosed

Thanks for the ticket. I've updated the documentation. Let me know if there is anything I've missed.

Changed August 16, 2011 11:35PM UTC by anonymous comment:3

Replying to [comment:2 kswedberg]:

Thanks for the ticket. I've updated the documentation. Let me know if there is anything I've missed.

Thank you kswedberg. I'll take a quick look, but I'd guess you have it covered.

I don't have time to do another bug report right now, so I'm just going to mention it here.

With respect to the jQuery() function's context parameter, a ''selector string'' is not listed as a valid option. I don't really care about this one, but it was just mentioned on StackOverflow, so I thought I'd let you know.

http://api.jquery.com/jquery/

Thanks again for the quick updates in response to this and the other report 10053.

patrick