node-sass icon indicating copy to clipboard operation
node-sass copied to clipboard

Strange behavior while using @extend multiple times

Open NikFlip opened this issue 10 years ago • 1 comments

To avoid multiple lines of CSS, I'm using the foundations exports mixin (short description here).

But if I use @import to include my module multiple times, the @extend-functions blows up my css. I also tried a @mixin instead of @extend and asserted that there is no problem.

Code does say more than thousand words, so I made a gist that shows the problem: https://gist.github.com/NikFlip/5418438ef0da2dd1c694

Just run:

$ npm install
$ node .

and watch the result in the console

should:

.selector-with-extend {
  background: red; }

.selector-without-extend {
  color: green; }

is:

.selector-with-extend {
  background: red; }

.selector-without-extend {
  color: green; }

.selector-with-extend {
  background: red; }

.selector-with-extend {
  background: red; }

.selector-with-extend {
  background: red; }

NikFlip avatar Dec 22 '15 14:12 NikFlip

@NikFlip how are defining should?

Node Sass should do what Ruby Sass does.

Ruby Sass 3.4.18

/**
 * List of already exported style blocks. Used by mixin `exports(name)`.
 */
/**
 * Exports the given @content once. Uses the name, passed as first parameter to
 * evaluate if the content was already exported. We use this to prevent styles
 * from being loaded multiple times for components that rely on other components.
 *
 * @param {name} name
 */
/**
 * Import the same module four times
 */
.selector-with-extend {
  background: red; }

.selector-without-extend {
  color: green; }

.selector-with-extend {
  background: red; }

.selector-with-extend {
  background: red; }

.selector-with-extend {
  background: red; }

Node Sass 3.4.2

/**
 * List of already exported style blocks. Used by mixin `exports(name)`.
 */
/**
 * Exports the given @content once. Uses the name, passed as first parameter to
 * evaluate if the content was already exported. We use this to prevent styles
 * from being loaded multiple times for components that rely on other components.
 *
 * @param {name} name
 */
/**
 * Import the same module four times
 */
.selector-with-extend {
  background: red; }

.selector-without-extend {
  color: green; }

.selector-with-extend {
  background: red; }

.selector-with-extend {
  background: red; }

.selector-with-extend {
  background: red; }

xzyfer avatar Dec 27 '15 05:12 xzyfer