Bug Tracker

Modify

Ticket #12024 (closed bug: duplicate)

Opened 11 months ago

Last modified 10 months ago

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

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

comment:1 Changed 11 months ago by timmywil

  • Status changed from new to assigned
  • Component changed from unfiled to selector
  • Summary changed from :not selector doesn't work within certain combinations of selectors to Certain attributes should be treated as case-insensitive when comparing them in Sizzle
  • Priority changed from undecided to low
  • Milestone changed from None to 1.8
  • Owner set to timmywil

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 months 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 months ago by timmywil

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

Version 0, edited 11 months ago by timmywil (next)

comment:4 Changed 11 months 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 months ago by timmywil

@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 months 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 10 months ago by timmywil

  • Status changed from assigned to closed
  • Resolution set to duplicate

@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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.