Bug Tracker

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#10967 closed bug (fixed)

.promise() does not attach methods onto target

Reported by: fastfasterfastest Owned by: gibson042
Priority: high Milestone: 1.7.2
Component: queue Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:


Documentation for .promise() (http://api.jquery.com/promise/) states "If target is provided, .promise() will attach the methods onto it and then return this object rather than create a new one."

This is not what is happening in 1.7.1.

I am not sure what a good use-case for this is, but the following http://jsfiddle.net/AjXTp/ demonstrates the issue:

var foo = {};

$(document.body).promise("foo", foo);

If 1.7.1. did what the documentation states then "hello" would be alerted. Instead, there is a javascript error.

Looking at the sources, one can also see that the parameter named 'object' is never used in .promise().

I believe it is either an implementation bug, or a documentation bug.

(Note, this is a report about .promise() (documented at http://api.jquery.com/promise/), not about deferred.promise() (documented at http://api.jquery.com/deferred.promise/).)

Change History (4)

comment:1 Changed 5 years ago by gibson042

Confirmed. jQuery.fn.promise should be returning defer.promise( object ) instead of defer.promise()


comment:2 Changed 5 years ago by timmywil

Component: unfiledqueue
Owner: set to gibson042
Priority: undecidedhigh
Status: newassigned

comment:3 Changed 5 years ago by Richard Gibson

Resolution: fixed
Status: assignedclosed

Fix #10967: jQuery.fn.promise returns provided object

Changeset: 6c2b64dfa5e1d6f90c74f0f1719e9f11f52de7a4

comment:4 Changed 5 years ago by dmethvin

Milestone: None1.7.2
Note: See TracTickets for help on using tickets.