Skip to main content

Bug Tracker

Side navigation

#12024 closed bug (duplicate)

Opened July 05, 2012 05:25PM UTC

Closed July 10, 2012 03:16AM UTC

Last modified December 02, 2013 04:02PM UTC

Certain attributes should be treated as case-insensitive when comparing them in Sizzle

Reported by: ClarkeyBoy1987 Owned by: timmywil
Priority: low Milestone: 1.8
Component: selector Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

Hi,

Please see http://stackoverflow.com/questions/11316015/bug-in-jquery-not-selector, https://forum.jquery.com/topic/not-selector-not-working-as-expected and the http://jsfiddle.net/n8zDu/10/. Everything we've found is documented on SO or the jQuery forum.

Long story short, it seems that when using the :not selector with multiple selectors inside it and at least one other selector before it, the wrong number of elements is returned.

Example broken selector:

$("input[type=text][id], select[id]:not(#bob, #fred)");

Example working selector:

$("input[type=text][id], select[id]").not("#bob, #fred");

The JS fiddle contains multiple text inputs and selects and the results of this selector using :not and .not are output in the console. This issue first arose in 1.5.2.

Note that the docs do suggest that this selector should work.

Regards,

Clarkey

Attachments (0)
Change History (8)

Changed July 05, 2012 06:47PM UTC by timmywil comment:1

component: unfiledselector
milestone: None1.8
owner: → timmywil
priority: undecidedlow
status: newassigned
summary: :not selector doesn't work within certain combinations of selectorsCertain attributes should be treated as case-insensitive when comparing them in Sizzle

This is not an issue with the :not selector, but there is an issue. The inputs in the example all have uppercase values for their attributes while the value in the selector is lowercase. When :not contains a complex selector, querySelectorAll fails and Sizzle handles the attribute comparisons but does not account for these attributes being case-insensitive. We can fix that, but it will probably require a list within Sizzle specifying which attributes are case-insensitive in both HTML and XML.

http://jsfiddle.net/timmywil/n8zDu/14/

Changed July 05, 2012 10:17PM UTC by ClarkeyBoy1987 comment:2

Hi timmywil,

I am not sure what you mean. In my example, all the attribute names are lower case and the 2 select ids which are referenced in the :not() are exactly the same as the id attribute of the actual selects.

The id and class attributes should be case-sensitive as it will otherwise just lead to confusion due to being case-sensitive in standard CSS.

Regards,

Clarkey

Changed July 06, 2012 03:24PM UTC by timmywil comment:3

_comment0: It's not about attribute names. It's about attribute values and some should be treated case-insensitive, such as`type`.1341588277142976

It's not about attribute names. It's about attribute values and some should be treated case-insensitive, such as type.

Changed July 06, 2012 06:33PM UTC by ClarkeyBoy1987 comment:4

Ok I see what you mean, but that isn't the bug I am talking about. If you look at the example I provided, you will see that the markup is the same for both methods and the only difference is the use of .not in the 2nd method instead of :not in the first method, yet :not returns less elements than .not. These should both be the same as they are in effect the same selector just done in a different way.

Regards,

Richard

Changed July 06, 2012 07:24PM UTC by timmywil comment:5

@ClarkeyBoy1987: I don't think you understand. As I said, although it seems this is an issue with the :not selector, it is not.

Changed July 06, 2012 07:29PM UTC by ClarkeyBoy1987 comment:6

Hi timmywil,

Ok can you explain to me exactly why this is not a bug then? Because to me, logically, they're both just a different way of achieving the same effect. Also if it is not a bug, why is it the docs say that the selector I am using is valid? And why is it both methods return the same (correct) number of elements in 1.4.4 but then from 1.5.2 onwards they return a different number?

Changed July 10, 2012 03:16AM UTC by timmywil comment:7

resolution: → duplicate
status: assignedclosed

@ClarkeyBoy1987: This is absolutely a bug, just not in the implementation of the :not selector.

Ported to Sizzle issue: https://github.com/jquery/sizzle/issues/122

Changed December 02, 2013 04:02PM UTC by timmywil comment:8

#14584 is a duplicate of this ticket.