postcss / sugarss

Indent-based CSS syntax for PostCSS
MIT License
707 stars 39 forks source link

Parsing bug with nested rules #16

Closed pvalentim closed 8 years ago

pvalentim commented 8 years ago

When using nested rules there's a parsing even though the output is correct. The problem is that it breaks when using a plugin like postcss-nested. Example bellow:

Input:

.phone
  width: 100px
  &_title
    width: 500px

The output is correct if no plugins are used, if postcss-nested is used this is the output:

width: 100px
  .phone_title {
  width: 500px
}

This is parsed tree without plugins, notice the selector property is including the width declaration:

"nodes": [
  {
    "raws": {
      "before": "\n  "
    },
    "type": "rule",
    "nodes": [
    ],
    "source": {
      "start": {
        "line": 2,
        "column": 3
      },
      "input": {
        "css": ".phone\n  width: 100px\n  &_title\n    width: 500px\n",
        "file": "bug.sss"
      },
      "end": {
        "line": 3,
        "column": 9
      }
    },
    "selector": "width: 100px\n  &_title",
    "lastEach": 5,
    "indexes": {}
  }
],

Thanks

ai commented 8 years ago

Fixed dde5c45

ai commented 8 years ago

Released in 0.1.2.