Skip to main content

Bug Tracker

Side navigation

#9910 closed enhancement (fixed)

Opened July 26, 2011 12:51PM UTC

Closed July 26, 2011 02:13PM UTC

Last modified July 26, 2011 03:09PM UTC

Generally document behavior of setters when passed function returns undefined

Reported by: tj@crowdersoftware.com 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.
Attachments (0)
Change History (4)

Changed July 26, 2011 02:13PM UTC by timmywil comment:1

component: unfiledattributes
keywords: → neededdocs
priority: undecidedlow
resolution: → fixed
status: newclosed

Changed July 26, 2011 02:39PM UTC by tj@crowdersoftware.com comment:2

Replying to [comment:1 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.)

Changed July 26, 2011 03:04PM UTC by timmywil comment:3

Changed July 26, 2011 03:09PM UTC by tj@crowdersoftware.com comment:4

Replying to [comment:3 timmywil]:

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

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