Bug Tracker

Ticket #10051 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

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.

Change History

comment:1 Changed 3 years ago by kswedberg

  • Owner set to kswedberg
  • Status changed from new to assigned

comment:2 follow-up: ↓ 3 Changed 3 years ago by kswedberg

  • Status changed from assigned to closed
  • Resolution set to fixed

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 3 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.

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

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

patrick

Note: See TracTickets for help on using tickets.