#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: |
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/).)
Change History (4)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → queue |
---|---|
Owner: | set to gibson042 |
Priority: | undecided → high |
Status: | new → assigned |
comment:3 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fix #10967: jQuery.fn.promise returns provided object
Changeset: 6c2b64dfa5e1d6f90c74f0f1719e9f11f52de7a4
comment:4 Changed 12 years ago by
Milestone: | None → 1.7.2 |
---|
Confirmed.
jQuery.fn.promise
should be returningdefer.promise( object )
instead ofdefer.promise()
https://github.com/jquery/jquery/pull/629