Bug Tracker

Modify

Ticket #10967 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

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

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

comment:1 Changed 2 years ago by gibson042

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

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

comment:2 Changed 2 years ago by timmywil

  • Owner set to gibson042
  • Priority changed from undecided to high
  • Status changed from new to assigned
  • Component changed from unfiled to queue

comment:3 Changed 2 years ago by Richard Gibson

  • Status changed from assigned to closed
  • Resolution set to fixed

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

Changeset: 6c2b64dfa5e1d6f90c74f0f1719e9f11f52de7a4

comment:4 Changed 2 years ago by dmethvin

  • Milestone changed from None to 1.7.2

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.