Skip to content

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

Closed
@lydell

Description

@lydell
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions