Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuery function filter with attribute name contains square bracket is not working #4170

Closed
colandchan opened this Issue Sep 3, 2018 · 4 comments

Comments

Projects
None yet
4 participants
@colandchan
Copy link

colandchan commented Sep 3, 2018

Description

Select elements by name attribute, then use filter with selector. If the selector contains square bracket, sometimes the filter did not work as expected.

In the test case, the first console.log returns 2 as expected.
The second console.log returns 0 which expected to be 1.

Link to test case

http://jsfiddle.net/Lqv9yjn3/1/

@colandchan colandchan changed the title jQuery function filter with attribute name contains bracket is not working jQuery function filter with attribute name contains square bracket is not working Sep 3, 2018

@timmywil

This comment has been minimized.

Copy link
Member

timmywil commented Sep 3, 2018

This seems valid. However, the easy workaround is to wrap your value in quotes. https://jsfiddle.net/Lqv9yjn3/10/

@timmywil timmywil added this to the 3.4.0 milestone Sep 3, 2018

@dmethvin

This comment has been minimized.

Copy link
Member

dmethvin commented Sep 3, 2018

I know we've seen these reports before but I'm too lazy to look it up in closed issues. The CSS spec says:

Attribute values must be identifiers or strings. - https://drafts.csswg.org/css2/selector.html#attribute-selectors

Identifiers don't have ] in them but quoted strings can.

@timmywil

This comment has been minimized.

Copy link
Member

timmywil commented Sep 3, 2018

Identifiers can have escaped characters. In this case, escaping the ] should work.

@timmywil

This comment has been minimized.

Copy link
Member

timmywil commented Sep 3, 2018

Actually, this is fixed in Sizzle master (jquery/sizzle#408), but we need to update Sizzle in jQuery.

@timmywil timmywil modified the milestones: 3.4.0, 4.0.0 Apr 2, 2019

@mgol mgol modified the milestones: 4.0.0, 3.4.0 Apr 8, 2019

mgol added a commit to mgol/jquery that referenced this issue Apr 9, 2019

@mgol mgol referenced this issue Apr 9, 2019

Merged

Build: Update Sizzle from 2.3.3 to 2.3.4 #4345

2 of 2 tasks complete

@mgol mgol closed this in #4345 Apr 9, 2019

mgol added a commit that referenced this issue Apr 9, 2019

mgol added a commit that referenced this issue Apr 9, 2019

Build: Update Sizzle from 2.3.3 to 2.3.4
(cherry-picked from 0b2c36a)

Fixes gh-1756
Fixes gh-4170
Fixes gh-4249
Closes gh-4345
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.