Postcss: Parse and stringify lose semicolon in custom property set

Created on 29 Jun 2017  路  3Comments  路  Source: postcss/postcss

Example:

"use strict";

const postcss = require("postcss");
const css = ":root { --foo: { color: red };; --bar: { color: blue }; --bar-foo: { color: red }; }";

console.log(postcss.parse(css).toString());

Output (no extra semicolon after --foo):

:root { --foo: { color: red }; --bar: { color: blue }; --bar-foo: { color: red }; }

Seems (:root { --foo: { color: red };; --bar: { color: blue }; --bar-foo: { color: red }; }) --bar node doesn't contain this extra semicolon in raws.before:

Rule {
      raws: 
       { before: ' ',
         between: ' ',
         semicolon: false,
         after: ' ',
         ownSemicolon: ';' },
      type: 'rule',
      nodes: 
       [ Declaration {
           raws: [Object],
           type: 'decl',
           parent: [Circular],
           source: [Object],
           prop: 'color',
           value: 'blue' } ],
      parent: 
       Rule {
         raws: { before: '', between: ' ', semicolon: false, after: ' ' },
         type: 'rule',
         nodes: [ [Object], [Circular], [Object] ],
         parent: 
          Root {
            raws: [Object],
            type: 'root',
            nodes: [Object],
            source: [Object],
            lastEach: 4,
            indexes: [Object] },
         source: { start: [Object], input: [Object], end: [Object] },
         selector: ':root',
         lastEach: 4,
         indexes: { '4': 1 } },
      source: 
       { start: { line: 1, column: 33 },
         input: 
          Input {
            css: ':root { --foo: { color: red };; --bar: { color: blue }; --bar-foo: { color: red }; }',
            id: '<input css 1>' },
         end: { line: 1, column: 54 } },
      selector: '--bar:',
      lastEach: 3,
      indexes: {} }

Based on https://github.com/stylelint/stylelint/pull/2561

Most helpful comment

Fixed 771724c

All 3 comments

Also a { color: red; };; after stringify lose semicolon a { color: red; }; (seems it is related to Rule)

Fixed 771724c

Released in 6.0.4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AdeSupriyadi picture AdeSupriyadi  路  3Comments

StephenEsser picture StephenEsser  路  9Comments

hudochenkov picture hudochenkov  路  12Comments

sydneyitguy picture sydneyitguy  路  5Comments

danielbachhuber picture danielbachhuber  路  11Comments