Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#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:
Blocked by: Blocking:

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

comment:1 Changed 7 years ago by dmethvin

Component: unfiledattributes
Milestone: None1.8
Priority: undecidedlow
Status: newopen

comment:2 Changed 7 years 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 7 years 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 7 years ago by dmethvin

Owner: set to dmethvin
Status: openassigned

Just need a docs change for 1.8

comment:5 Changed 7 years ago by dmethvin

Keywords: needsdocs added
Resolution: fixed
Status: assignedclosed

comment:6 Changed 6 years ago by mikesherov

Keywords: needsdocs removed
Note: See TracTickets for help on using tickets.