Skip to main content

Bug Tracker

Side navigation

#10967 closed bug (fixed)

Opened December 07, 2011 02:37AM UTC

Closed February 14, 2012 02:55AM UTC

Last modified March 02, 2012 04:21PM UTC

.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:
Description

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);
foo.done(function(){alert("hello");});

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

Attachments (0)
Change History (4)

Changed December 09, 2011 05:44PM UTC by gibson042 comment:1

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

https://github.com/jquery/jquery/pull/629

Changed December 14, 2011 03:27PM UTC by timmywil comment:2

component: unfiledqueue
owner: → gibson042
priority: undecidedhigh
status: newassigned

Changed February 14, 2012 02:55AM UTC by Richard Gibson comment:3

resolution: → fixed
status: assignedclosed

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

Changeset: 6c2b64dfa5e1d6f90c74f0f1719e9f11f52de7a4

Changed March 02, 2012 04:21PM UTC by dmethvin comment:4

milestone: None1.7.2