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)
Change History (10)
Changed November 13, 2010 07:09PM UTC by comment:1
status: | new → open |
---|
Changed November 13, 2010 08:34PM UTC by 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 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 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 comment:5
Scratch all that. See pull request.
Changed January 22, 2011 10:50PM UTC by comment:6
Can you post a link to the pull request?
Changed January 23, 2011 03:20PM UTC by comment:7
component: | core → traversing |
---|---|
milestone: | 1.2.4 → 1.next |
owner: | → timmywil |
priority: | major → low |
status: | open → assigned |
version: | 1.2.3 → 1.4.4 |
3rd party pull request
Changed January 24, 2011 09:25PM UTC by comment:8
Switched to follow jQuery bug patching guidelines.
Changed March 14, 2011 08:16PM UTC by comment:9
milestone: | 1.next → 1.6 |
---|
Changed April 10, 2011 08:41PM UTC by comment:10
resolution: | → fixed |
---|---|
status: | assigned → closed |
Landed.
Patch still seems to be okay for 1.4.4 and it's been requested a few times.