Opened 15 years ago
Closed 12 years ago
#2773 closed enhancement (fixed)
$.fn.is and $.fn.not should accept DOMelements and jQuery collections
Reported by: | paul | Owned by: | Timmy Willison |
---|---|---|---|
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 (11)
Changed 15 years ago by
comment:1 Changed 13 years ago by
Status: | new → open |
---|
comment:2 Changed 13 years ago by
$.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?
comment:3 Changed 12 years ago by
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.
comment:4 Changed 12 years ago by
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.
comment:7 Changed 12 years ago by
Component: | core → traversing |
---|---|
Milestone: | 1.2.4 → 1.next |
Owner: | set to Timmy Willison |
Priority: | major → low |
Status: | open → assigned |
Version: | 1.2.3 → 1.4.4 |
3rd party pull request
comment:8 Changed 12 years ago by
Updated pull request Switched to follow jQuery bug patching guidelines.
comment:9 Changed 12 years ago by
Milestone: | 1.next → 1.6 |
---|
Patch still seems to be okay for 1.4.4 and it's been requested a few times.