Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10051 closed bug (fixed)

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:


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.

Change History (3)

comment:1 Changed 11 years ago by kswedberg

Owner: set to kswedberg
Status: newassigned

comment:2 Changed 11 years ago by kswedberg

Resolution: fixed
Status: assignedclosed

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

comment:3 in reply to:  2 Changed 11 years ago by anonymous

Replying to 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.


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


Note: See TracTickets for help on using tickets.