Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 9 years ago

#12024 closed bug (duplicate)

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

Reported by: ClarkeyBoy1987 Owned by: Timmy Willison
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

Change History (8)

comment:1 Changed 11 years ago by Timmy Willison

Component: unfiledselector
Milestone: None1.8
Owner: set to Timmy Willison
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/

comment:2 Changed 11 years ago by ClarkeyBoy1987

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

comment:3 Changed 11 years ago by Timmy Willison

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

Version 0, edited 11 years ago by Timmy Willison (next)

comment:4 Changed 11 years ago by ClarkeyBoy1987

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

comment:5 Changed 11 years ago by Timmy Willison

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

comment:6 Changed 11 years ago by ClarkeyBoy1987

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?

comment:7 Changed 11 years ago by Timmy Willison

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

comment:8 Changed 9 years ago by Timmy Willison

#14584 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.