Bug Tracker

Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 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:

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 (3)

comment:1 Changed 6 years ago by kswedberg

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

comment:2 follow-up: Changed 6 years ago by kswedberg

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

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 6 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

Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Modify Ticket

Change Properties
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.