Skip to content

CSS spec compliance: !IMPORTANT is valid – should be case insensitive #89

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

Closed
lydell opened this issue Sep 3, 2017 · 5 comments · Fixed by #113
Closed

CSS spec compliance: !IMPORTANT is valid – should be case insensitive #89

lydell opened this issue Sep 3, 2017 · 5 comments · Fixed by #113

Comments

@lydell
Copy link

lydell commented Sep 3, 2017

  • Node Version: 8.3.0
  • NPM Version: 5.3.0
  • postcss-less Version: 1.1.0

LESS

a{k: v !IMPORTANT;}

JavaScript

console.dir(require("postcss-less").parse('a{k: v !IMPORTANT;}'), {colors: true, depth: null})

Expected Behavior

The declaration should be parsed as:

Declaration {
  prop: 'k',
  important: true,
  value: 'v'
}

Just like for a{k: v !important;}.

Actual Behavior

The declaration is parsed as:

Declaration {
  prop: 'k',
  value: 'v !IMPORTANT' }
}

How can we reproduce the behavior?

console.dir(require("postcss-less").parse('a{k: v !IMPORTANT;}'), {colors: true, depth: null})

Spec

CSS is actually mostly case insensitive. Here is the spec mentioning how !important should be parsed case insensitively: https://www.w3.org/TR/css-syntax-3/#consume-a-declaration

If the last two non-<whitespace-token>s in the declaration’s value are a <delim-token> with the value "!" followed by an <ident-token> with a value that is an ASCII case-insensitive match for "important", remove them from the declaration’s value and set the declaration’s important flag to true.

Related

postcss/postcss#1065

@shellscape
Copy link
Owner

Fix should go here, should be a simple regex instead of straight string compare.

@orottier
Copy link
Contributor

orottier commented Sep 26, 2017

I've fixed this for less mixins, but I think the issue should be migrated to shellscape/postcss

edit: oops just noticed the related bug in that repo

shellscape pushed a commit that referenced this issue Oct 2, 2017
* Add failing test for #90

* Fix #90, whitespace between mixin and !important is optional

* Make test for !important case insensitive, #89

* Use test() instead of match() as we dont care about the actual matches
@shellscape
Copy link
Owner

@lydell @orottier has this one been resolved by #91?

@lydell
Copy link
Author

lydell commented Oct 9, 2017

@shellscape I asked myself the same question when I saw #91 and tried it – but, no, this is still an issue.

@orottier
Copy link
Contributor

orottier commented Oct 9, 2017

I've made the check for mixins case-insensitive, see related test: https://github.com/shellscape/postcss-less/pull/91/files#diff-d7e2ac4acbb2c79fd1039710696f1cefR139

the postcss bug postcss/postcss#1065 is also fixed, it landed in 6.0.11. Should we update package.json?

@shellscape shellscape mentioned this issue Sep 17, 2018
16 tasks
shellscape added a commit that referenced this issue Sep 21, 2018
* chore: fix linting errors

* chore: de-esm

* chore: de-esm, start move to ava

* chore: move to circle

* chore: gulp to npm scripts, housekeeping

* chore: unfuck prev de-esm

* test: get root tests passing

* test: better integration tests

* test: finish ava migration

* chore: clean up package, add code coverage

* chore(ci): fix lint script

* test: ignore postcss-parser-tests until after 7.x update

* chore(ci): add node 6 to circle config

* fix: fixes #88, malformed filenames and missing semicolons in imports

* fix: fixes #89, case insensitive !important

* chore: keep the old parsers around for reference temporarily

* refactor: leverage postcss 7.0

* refactor: enable mixins

* chore: improve linting, fix variable parse, enable sanity check tests

* chore: get stringifying working

* chore: re-implement stringifying, update tests, remove old /lib

* test: add test for #110

* test: add test for #108

* chore: implement interpolation, update tests

* fix: fixes #102 and #86

* chore: code cleanup
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 a pull request may close this issue.

3 participants