Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#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:
Blocked by: Blocking:


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 (7)

comment:1 Changed 12 years ago by anonymous

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

comment:2 Changed 12 years ago by snover

Component: unfiledtraversing
Priority: undecidedlow
Status: newopen

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 12 years ago by snover


Retargeting due to severity of regressions in 1.4.3.

comment:4 Changed 12 years ago by dmethvin

Resolution: invalid
Status: openclosed

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 12 years ago by john


There wasn't a 1.4.5 release, was actually 1.5.

comment:6 Changed 12 years ago by john


There was no 1.4.5 release, was actually 1.5.

comment:7 Changed 11 years 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?

Note: See TracTickets for help on using tickets.