Bug Tracker

Modify

Ticket #9910 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

Generally document behavior of setters when passed function returns undefined

Reported by: tj@… Owned by:
Priority: low Milestone: None
Component: attributes Version: 1.6.2
Keywords: neededdocs Cc:
Blocking: Blocked by:

Description

In ticket #8770, the attr function's behavior was clarified for when it's passed a callback function to use to set the value and the function returns undefined.

This applies generally to setters, though, like css, prop, presumably others. Recommend documenting the behavior consistently and clearly (the current attr wording is technically accurate, but convoluted). Something along the lines of:

Note: If the setter callback doesn't return a value or returns undefined, the current value is not changed. This can be useful for selectively setting values only when certain criteria are met.

Change History

comment:1 follow-up: ↓ 2 Changed 2 years ago by timmywil

  • Keywords neededdocs added
  • Priority changed from undecided to low
  • Status changed from new to closed
  • Component changed from unfiled to attributes
  • Resolution set to fixed

comment:2 in reply to: ↑ 1 Changed 2 years ago by tj@…

Replying to timmywil:

Docs updated:  http://api.jquery.com/attr

Wow, fast! But this was logged primarily to get css, prop, and others that behave the same way changed, not about attr's wording. (But it's great to see it updated.)

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

comment:4 in reply to: ↑ 3 Changed 2 years ago by tj@…

Replying to timmywil:

I went ahead and updated  http://api.jquery.com/css and  http://api.jquery.com/prop

That's great! Nice one (and fast).

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

View

Add a comment

Modify Ticket

Action
as closed
Author


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

 
Note: See TracTickets for help on using tickets.