less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17k stars 3.41k forks source link

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

Closed iChenLei closed 2 years ago

iChenLei commented 2 years ago

What:

add support for case-insensitive attribute selectors try to fix https://github.com/less/less.js/issues/3027 https://github.com/less/less.js/issues/3670 https://github.com/go-gitea/gitea/pull/15520 https://github.com/go-gitea/gitea/issues/15565

Why:

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

2021-12-07 21 08 33

How:

https://github.com/less/less.js/issues/3027#issuecomment-828223873

Checklist:

cc @matthew-dean

matthew-dean commented 2 years ago

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 commented 2 years ago

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

iChenLei commented 2 years ago

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 commented 2 years ago

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

iChenLei commented 2 years ago

@matthew-dean puppeteer e2e test often fail. 😢 https://github.com/less/less.js/runs/4619921788?check_suite_focus=true