Confusing `raws` behaviour #933

Open
ben-eb opened this Issue Dec 23, 2016 · 10 comments

Projects

None yet

2 participants

@ben-eb
Member
ben-eb commented Dec 23, 2016

Ref: December 23, 2016 10:11 AM

    --layout-around-aligned: {
      -ms-flex-line-pack: distribute;  /* IE10 */
      -ms-align-content: space-around;
      -webkit-align-content: space-around;
      align-content: space-around;
    };

    /*******************************
              Other Layout
    *******************************/

    --layout-block: {
      display: block;
    };

I looked into the AST produced by PostCSS and what ends up happening is that the semicolon from (logically) the first rule is in fact tacked on to the before raw value of the comment node. Because cssnano removes the comment nodes then the semicolon is lost, but I don't think that the semicolon being part of the comment node is correct.

@ai
Member
ai commented Dec 23, 2016

Is it correct CSS? I thought that ; could not be in rules context

@ben-eb
Member
ben-eb commented Dec 23, 2016

Yeah, it's correct, there's a nice blog post on CSS mixins here https://blog.hospodarets.com/css_apply_rule. 😄

e.g.

:root {
  --zero-size: {
    width: 0;
    height: 0;
  };
  
  --triangle-to-bottom-size: 50px;
  --triangle-to-bottom-color: #007bff;
  
  --triangle-to-bottom: {
    @apply --zero-size;
    border-style: solid;
    border-width: var(--triangle-to-bottom-size) var(--triangle-to-bottom-size) 0 var(--triangle-to-bottom-size);
    border-color: var(--triangle-to-bottom-color) transparent transparent transparent;
  };
}

.triangle-to-bottom {
  @apply --triangle-to-bottom;
}
@ai
Member
ai commented Dec 23, 2016

Main problem that current parser was not designed for this spec :D.

We could add raws.ownSemicolon to the Rule.

@ben-eb
Member
ben-eb commented Dec 23, 2016

Changing the parser behaviour could be problematic. 😕

Do we want to wait for a major version?

@ai
Member
ai commented Dec 23, 2016

It could be do in minor, because I'll paying this was not part of public API

@ben-eb
Member
ben-eb commented Dec 23, 2016

OK, fair enough. 👍

@ai
Member
ai commented Dec 23, 2016

But we could make it major to clean deprecated API 😉

@ben-eb
Member
ben-eb commented Dec 23, 2016

Do you have a date for when you'd like to release a new major?

@ai
Member
ai commented Dec 24, 2016

Hm. In the middle of January?

@ben-eb
Member
ben-eb commented Dec 24, 2016

Alright, that seems OK. Going to have to start this monorepo transition! 😀

@ben-eb ben-eb referenced this issue in ben-eb/cssnano Dec 30, 2016
Open

escaped CSS #322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment