Skip to main content

Bug Tracker

Side navigation

#11734 closed enhancement (fixed)

Opened May 08, 2012 07:49PM UTC

Closed August 10, 2012 05:51PM UTC

Last modified October 15, 2012 10:19PM UTC

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:

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.

Attachments (0)
Change History (6)

Changed May 08, 2012 07:49PM UTC by dmethvin comment:1

component: unfiledattributes
milestone: None1.8
priority: undecidedlow
status: newopen

Changed May 18, 2012 02:24AM UTC by dmethvin comment:2

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

Changed June 04, 2012 05:29PM UTC by timmywil comment:3

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.

Changed June 25, 2012 04:27PM UTC by dmethvin comment:4

owner: → dmethvin
status: openassigned

Just need a docs change for 1.8

Changed August 10, 2012 05:51PM UTC by dmethvin comment:5

keywords: → needsdocs
resolution: → fixed
status: assignedclosed

Changed October 15, 2012 10:19PM UTC by mikesherov comment:6

keywords: needsdocs