Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#9910 closed enhancement (fixed)

Generally document behavior of setters when passed function returns undefined

Reported by: [email protected] Owned by:
Priority: low Milestone: None
Component: attributes Version: 1.6.2
Keywords: neededdocs Cc:
Blocked by: Blocking:

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

comment:1 Changed 10 years ago by timmywil

Component: unfiledattributes
Keywords: neededdocs added
Priority: undecidedlow
Resolution: fixed
Status: newclosed

comment:2 in reply to:  1 Changed 10 years ago by [email protected]

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 Changed 10 years ago by timmywil

comment:4 in reply to:  3 Changed 10 years ago by [email protected]

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

Note: See TracTickets for help on using tickets.