Ticket #11734 (closed enhancement: fixed)
Deprecate Boolean attrHooks such as checked, selected
| Reported by: | dmethvin | Owned by: | dmethvin |
|---|---|---|---|
| Priority: | low | Milestone: | 1.8 |
| Component: | attributes | Version: | 1.7.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
In jQuery 1.6.1 we put in some hooks to continue the queasy automagical relationship between certain attributes and properties that pre-1.6 versions of jQuery used.
We should deprecate the special hooks that allow things like .attr("checked", true) and continue the education that .prop("checked", true) is the correct method.
Change History
comment:1 Changed 14 months ago by dmethvin
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to attributes
- Milestone changed from None to 1.8
comment:2 Changed 13 months ago by dmethvin
One issue with deprecating these is that there is the sneaky use of the attrHooks in the $(html, props) signature. So if we removed the hooks, this would break:
$("<input type=checkbox>", {
"checked": true,
click: function(){ alert("checked "+this.checked); }
});
Everything in that signature is a horrible rats nest of special cases, since it recognizes a small subset of event names and passes everything else through to .attr(). gibson042 pointed out that we could have another list of special cases for things that really should go through .prop() instead, or we can just deprecate the use of attrHooks here as well and intercourse the consequences, or we can deprecate the $(html, props) signature (in my dreams).
comment:3 Changed 13 months ago by timmywil
I think we can deprecate this, but not remove until 1.9 or even 2.0. The most likely solution, which I am fine with, is to add prop() to the html shortcuts.
comment:4 Changed 12 months ago by dmethvin
- Owner set to dmethvin
- Status changed from open to assigned
Just need a docs change for 1.8
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
