postcss / postcss-selector-parser

A CSS selector parser, integrates with postcss but does not require it.
MIT License
206 stars 49 forks source link

`lossless: true` option does not preserve trailing spaces in selectors #298

Open ryo-manba opened 3 weeks ago

ryo-manba commented 3 weeks ago

When using the loseless: true option trailing spaces are removed unexpectedly, even though should be preserved.

Related to https://github.com/stylelint/stylelint/pull/8074#discussion_r1817680694

Code to Reproduce

const parser = require('postcss-selector-parser');
const selector = ':not(a, )';

console.log('selector:', selector);
parser((selectors) => {
  console.log('parsed:', selectors.toString());
})
  .process(selector, { lossless: true })

Expected

selector: :not(a, )
parsed: :not(a, )

Actual

selector: :not(a, )
parsed: :not(a,)
alexander-akait commented 3 weeks ago

@ryo-manba pr welcome