Skip to main content

Bug Tracker

Side navigation

#7215 closed bug (invalid)

Opened October 16, 2010 06:27PM UTC

Closed December 30, 2010 04:05AM UTC

Last modified January 28, 2012 04:42AM UTC

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

Attachments (0)
Change History (7)

Changed October 16, 2010 06:36PM UTC by anonymous comment:1

Please see this fiddle:

http://jsfiddle.net/DJkVx/6/

Changed October 16, 2010 09:50PM UTC by snover comment:2

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.

Changed October 21, 2010 10:57PM UTC by snover comment:3

milestone: 1.4.41.4.5

Retargeting due to severity of regressions in 1.4.3.

Changed December 30, 2010 04:05AM UTC by dmethvin comment:4

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.

Changed January 31, 2011 05:53PM UTC by john comment:5

version: 1.4.31.5

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

Changed January 31, 2011 05:54PM UTC by john comment:6

milestone: 1.4.51.5

There was no 1.4.5 release, was actually 1.5.

Changed January 28, 2012 04:42AM UTC by anonymous comment:7

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?