#9910 closed enhancement (fixed)
Generally document behavior of setters when passed function returns undefined
Reported by: | 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 follow-up: 2 Changed 12 years ago by
Component: | unfiled → attributes |
---|---|
Keywords: | neededdocs added |
Priority: | undecided → low |
Resolution: | → fixed |
Status: | new → closed |
comment:2 Changed 12 years ago by
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 12 years ago by
I went ahead and updated http://api.jquery.com/css and http://api.jquery.com/prop
comment:4 Changed 12 years ago by
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).
Docs updated: http://api.jquery.com/attr