postcss / postcss-mixins

PostCSS plugin for mixins
MIT License
466 stars 47 forks source link

Issue when using the @mixin-content several times in the mixin definition. #72

Closed lone-star closed 7 years ago

lone-star commented 7 years ago

I added the following test:

it('supports mixins with multiple content', () => {
    return run('@define-mixin m { @media { @mixin-content; } @media { @mixin-content; } } ' +
               '@mixin m { a {} }',
               '@media { a {} } @media { a {} }');
});

This is the result from the test suite:

$ jest --coverage && eslint *.js test/**/*.js
 FAIL  test/test.test.js
  ● supports mixins with multiple content

    expect(received).toEqual(expected)

    Expected value to equal:
      "@media { a {} } @media { a {} }"
    Received:
      "@media { a {} } @media { }"

      at postcss.process.then.result (test/test.test.js:9:28)
      at process._tickCallback (internal/process/next_tick.js:103:7)

Seems like replaceWith is emptying rule.nodes: https://github.com/postcss/postcss-mixins/blob/master/index.js#L69

ai commented 7 years ago

Yeap. It is a bug, thanks for report. I will look on it in Friday.

ai commented 7 years ago

Fixed https://github.com/postcss/postcss-mixins/commit/bde277619e1af297554cd5853e1752053a26a1ec

ai commented 7 years ago

Released in 6.0.1