Ticket #7215 (closed bug: invalid)
.not() on contents() has problems with selector
| Reported by: | leo | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.5 |
| Component: | traversing | Version: | 1.5 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
there's seems to be a problem using not() with selectors:
I have a div ($foo) with textnodes and buttons.
$foo.contents().not($j('button')) works (returns all textnodes) $foo.contents().not('button') does not work (returns empty)
Change History
comment:2 Changed 3 years ago by snover
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to traversing
This is because the winnow function filters out nodes that are not of type NODE_ELEMENT when the qualifier passed is a string.
comment:3 Changed 3 years ago by snover
- Milestone changed from 1.4.4 to 1.4.5
Retargeting due to severity of regressions in 1.4.3.
comment:4 Changed 2 years ago by dmethvin
- Status changed from open to closed
- Resolution set to invalid
After retrieving text nodes, any function that filters using a selector string will remove text nodes. To avoid that, you can use .filter(function) and remove anything that isn't a text node, rather than using the button selector.
comment:5 Changed 2 years ago by john
- Version changed from 1.4.3 to 1.5
There wasn't a 1.4.5 release, was actually 1.5.
comment:6 Changed 2 years ago by john
- Milestone changed from 1.4.5 to 1.5
There was no 1.4.5 release, was actually 1.5.
comment:7 Changed 16 months ago by anonymous
I believe there's still an issue here.
if($('div').not('.foo,.bar')) returns what looks to be empty objects for the filtered selectors instead of completely removing them
on the other hand if(!$('div').is('.foo,.bar')) works just fine, shouldn't it be the same?
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Please see this fiddle: http://jsfiddle.net/DJkVx/6/