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

feat: add support for case-insensitive attribute selectors #3673

Merged
merged 3 commits into from
Dec 23, 2021
Merged

feat: add support for case-insensitive attribute selectors #3673

merged 3 commits into from
Dec 23, 2021

Conversation

iChenLei
Copy link
Member

@iChenLei iChenLei commented Dec 7, 2021

What:

add support for case-insensitive attribute selectors
try to fix #3027 #3670 go-gitea/gitea#15520 go-gitea/gitea#15565

Why:

CSS spec -> https://www.w3.org/TR/selectors-4/#attribute-case

2021-12-07 21 08 33

How:

#3027 (comment)

Checklist:

  • Documentation
  • Added/updated unit tests
  • Code complete

cc @matthew-dean

@matthew-dean
Copy link
Member

matthew-dean commented Dec 7, 2021

Looks great! Thanks so much! One thing I'm thinking of -- IIRC, I believe there are tests somewhere that test attribute equality. Essentially there are tests like:

.foo when ([attr=value] = [attr="value"]) { }

So we may want to add this attribute selector to the equality check as well. IMO I feel like these equality checks are an overly-specific feature of Less, but since they exist, we want to make sure they don't break or that equality isn't true when the additional cif is present on one side of the comparison (and is true when, for example, one side side has a different casing than the other).

.foo when ([attr="value" i] = [attr="value" I]) { } // should be true and output .foo {}

In other words, the flag should probably serialize to the lower-case variant. Probably? What do you think? I don't want to over-engineer / over-think this, but I thought I should at least make you aware of it.

@iChenLei
Copy link
Member Author

iChenLei commented Dec 8, 2021

@matthew-dean Thanks for review, will add more unit test soon. 😄

@iChenLei
Copy link
Member Author

2021-12-14 10 56 25

@matthew-dean Sir, looks like current not support use when to compare attrbuite selectors(without case-insensitive flag) ?

@matthew-dean
Copy link
Member

@iChenLei Oh, no? Then never mind! Thanks for checking it out!

@matthew-dean matthew-dean merged commit 2431015 into less:master Dec 23, 2021
@bedax bedax mentioned this pull request Dec 23, 2021
@iChenLei iChenLei deleted the case-insensitive branch December 23, 2021 16:20
@iChenLei
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for case-insensitive attribute selectors
2 participants