Bug Tracker

Opened 9 years ago

Closed 8 years ago

Last modified 7 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:

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

comment:1 Changed 9 years ago by anonymous

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

comment:2 Changed 9 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 9 years ago by snover

Milestone: 1.4.41.4.5

Retargeting due to severity of regressions in 1.4.3.

comment:4 Changed 8 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 8 years ago by john

Version: 1.4.31.5

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

comment:6 Changed 8 years ago by john

Milestone: 1.4.51.5

There was no 1.4.5 release, was actually 1.5.

comment:7 Changed 7 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.