shellscape / postcss-less

PostCSS Syntax for parsing LESS
MIT License
122 stars 39 forks source link

Space in merge declaration causes CssSyntaxError #160

Open bnickel opened 3 years ago

bnickel commented 3 years ago

Less allows (or gracefully handles) spaces in merge declarations, like filter +_: blur(2px); but throws an exception in postcss. This happens inside after tokenization inside decl so it looks like the tokens could be sanitized before passing it to super.decl but I'm a bit out of my depths with whether or not that'll break something else.

LESS

.test1
 {
   rule +_: 'value';
 }

JavaScript

const test = require('ava');
const { parse } = require('../../lib');

test('should not fail when spaces are in merge rules', (t) => {
  const less = `.test1
  {
    rule +_: 'value';
  }
`;

  parse(less);
});

Errors

CssSyntaxError

<css input>:3:11: Unknown word

Expected Behavior

The Less should parse maybe with prop: "rule+_" to match match the existing. Or both should have something like prop: "rule", merge: true. I'm just using stylelint so I'm unopinionated.

Actual Behavior

Exception thrown.

How can we reproduce the behavior?

Add the test to the repo or try it in stylelint.

shellscape commented 3 years ago

I'd welcome a pull request to resolve this.