Bug Tracker

Opened 8 years ago

Closed 8 years ago

#3548 closed bug (invalid)

$(this) breaks chainability when this is a jQuery object

Reported by: dlikhten Owned by:
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: Cc: dlikhten, flesler
Blocked by: Blocking:


When chaining and using a custom function that uses and returns $(this) the $(this) call will break the chainability as it will not transfer the pre-destructive states.

Is this behavior valid, and my use case is an invalid use of jQuery extensions or should this behavior be supported?

Change History (2)

comment:1 Changed 8 years ago by flesler

  • Cc dlikhten flesler added
  • need changed from Review to Test Case

$(this) is a new jQuery object, with no previous states.

The "stack of states" goes with a specific object. You simply need to keep a reference to the original jQuery object.

Why do you pass a jQuery object to jQuery ? simply use 'this'. If you want to save a jQuery object to a var, you simply assing 'this' not $(this).

If you really have a justified reason, you can do:

var $copy = $(this);
$copy.prevObject = this.prevObject;

I'll let you provide a valid use for this before closing. Let me know if I can simply close this.

comment:2 Changed 8 years ago by dmethvin

  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.