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

Add support for case-insensitive attribute selectors #3027

Closed
murrayju opened this issue Feb 9, 2017 · 24 comments · Fixed by #3673
Closed

Add support for case-insensitive attribute selectors #3027

murrayju opened this issue Feb 9, 2017 · 24 comments · Fixed by #3673

Comments

@murrayju
Copy link

murrayju commented Feb 9, 2017

According to Mozilla:

[attr operator value i]
Adding an i (or I) before the closing bracket causes the value to be compared case-insensitively (for characters within the ASCII range).

This appears not to be supported by Less currently, and results in a compiler error.

expected ']' got 'i'

@seven-phases-max
Copy link
Member

seven-phases-max commented Feb 9, 2017

Oh, no: changing labels since it's not in CSS3 (just a CSS4 draft).

@murrayju
Copy link
Author

murrayju commented Feb 9, 2017

Yep, it is in working draft, but browsers seem to support it already (tested in Chrome 55 and Firefox 51).

@stale
Copy link

stale bot commented Nov 14, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@demaier
Copy link

demaier commented May 25, 2018

Was there any resolution for this? Haven't found a way to use case-insensitive with LESS yet.

a[href$=".pdf" i] { ... }

Thanks!

@calvinjuarez
Copy link
Member

For reference: https://caniuse.com/#feat=css-case-insensitive

@stale
Copy link

stale bot commented Nov 8, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 8, 2018
@ccoenen
Copy link

ccoenen commented Nov 8, 2018

activity!

@stale stale bot removed the stale label Nov 8, 2018
@demaier
Copy link

demaier commented Nov 8, 2018

Activity 2!

@stale
Copy link

stale bot commented Mar 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 8, 2019
@ccoenen
Copy link

ccoenen commented Mar 9, 2019

yeah... well... this is still missing as far as i can tell.

@stale stale bot removed the stale label Mar 9, 2019
@stale
Copy link

stale bot commented Jul 7, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@matthew-dean
Copy link
Member

@ccoenen @demaier Feel free to open a PR! ^_^

@seanCodes
Copy link

@matthew-dean I’d be happy to take a shot at this but I’ve never touched the codebase before so I’d need a little guidance. Would you be able to point me some files that might handle this?

@matthew-dean
Copy link
Member

@seanCodes Let me know a time you might be on Gitter chat? https://gitter.im/less/less.js

@seanCodes
Copy link

@matthew-dean you free around 5 PM PST?

@parasg1999
Copy link

Hey, is it still up for grabs?

@matthew-dean
Copy link
Member

@parasg1999 Currently, yes, unless @seanCodes is still into looking at it.

@seanCodes
Copy link

@parasg1999 @matthew-dean Yeah, sorry to say life got busy and I wasn’t able to make much progress on this one. ☹️ If you’re interested it’s all yours! 👍

@silverwind
Copy link

This should probably be classified as a bug, it breaks compatibility with CSS.

@jf-zens
Copy link

jf-zens commented Apr 26, 2021

I’d be happy to take a shot at this but I’ve never touched the codebase before so I’d need a little guidance. Would you be able to point me some files that might handle this?

@seanCodes
Copy link

@jf-zens Based on my conversation with @matthew-dean the steps are pretty straight-forward:

  1. Start with parser.js, and adjust the attribute parser:
    attribute: function () {
    if (!parserInput.$char('[')) { return; }
    const entities = this.entities;
    let key;
    let val;
    let op;
    if (!(key = entities.variableCurly())) {
    key = expect(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/);
    }
    op = parserInput.$re(/^[|~*$^]?=/);
    if (op) {
    val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\w-]+/) || entities.variableCurly();
    }
    expectChar(']');
    return new(tree.Attribute)(key, op, val);
    },
  2. Update the tree node (attribute.js) to to handle the value and output it correctly
  3. Add tests to verify that the case-sensitivity modifiers parse correctly

Just take care to follow the CSS attribute-case spec in your implementation and you’ll be good to go. 👍🏽

@bharathks005
Copy link

Hi Team, I want to contribute this project. Shall I start to fix this issue?

@iChenLei
Copy link
Member

iChenLei commented Dec 7, 2021

@bharathks005 PRs welcome

@bharathks005
Copy link

If I'm wrong correct me! I guess, This is the replicate issue no #3027. need to fix the case insensitively issue [I / i]

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

Successfully merging a pull request may close this issue.