Skip to main content

Bug Tracker

Side navigation

#2773 closed enhancement (fixed)

Opened May 02, 2008 12:24PM UTC

Closed April 10, 2011 08:41PM UTC

$.fn.is and $.fn.not should accept DOMelements and jQuery collections

Reported by: paul Owned by: timmywil
Priority: low Milestone: 1.6
Component: traversing Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

This is basically an addition to #2579.

I have had this usecase in almost any UI plugin: The simple task, that I want to see if my DOMelement is within the current jQuery set.

Right now, I have to do something like this:

var inset = false;

$(..).each(function() {

if(this == myElement) inset = true;

});

This would be /much/ easier and logical if I could simply do

$(..).is(myElement)

Attachments (1)
  • is.diff (0.4 KB) - added by flesler May 11, 2008 11:20PM UTC.
Change History (10)

Changed November 13, 2010 07:09PM UTC by dmethvin comment:1

status: newopen

Patch still seems to be okay for 1.4.4 and it's been requested a few times.

Changed November 13, 2010 08:34PM UTC by ajpiano comment:2

$.fn.not already does accept a DOM element (as does $.fn.filter). +1 on $.fn.is. What *really* needs to take a DOM element that doesn't now is $.fn.find and $.fn.closest, IMO. Thoughts?

Changed January 15, 2011 08:55PM UTC by timmywil comment:3

Made a fiddle for this ticket. http://jsfiddle.net/timmywil/xWNJe/ $.fn.not works properly, $.fn.is does not. .find() and .closest() fail, but .children() and .parent() pass.

Changed January 20, 2011 03:34PM UTC by timmywil comment:4

Something like this might be a start. I'm sure it could be optimized and included in is rather than a new function, but just to use fiddle, here is a newIs that can check objects and raw elements, then passes off to .is() for strings.

http://jsfiddle.net/timmywil/xWNJe/9/. However, I am using indexOf for an array and I don't think ie6 or ie7 support javascript 1.6. There may be something more clever to use, or a fallback should be written for those browsers.

Changed January 22, 2011 09:13PM UTC by timmywil comment:5

Scratch all that. See pull request.

Changed January 22, 2011 10:50PM UTC by rwaldron comment:6

Can you post a link to the pull request?

Changed January 23, 2011 03:20PM UTC by jitter comment:7

component: coretraversing
milestone: 1.2.41.next
owner: → timmywil
priority: majorlow
status: openassigned
version: 1.2.31.4.4

3rd party pull request

Changed January 24, 2011 09:25PM UTC by timmywil comment:8

Updated pull request

Switched to follow jQuery bug patching guidelines.

Changed March 14, 2011 08:16PM UTC by ajpiano comment:9

milestone: 1.next1.6

Changed April 10, 2011 08:41PM UTC by john comment:10

resolution: → fixed
status: assignedclosed

Landed.