question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mixins with Pseudo Elements Incorrectly Namespaced

See original GitHub issue

This SCSS:

@mixin do-a-thing-with-pseudo-elements() {
  position: relative;
  &::before {
    content: '';
    // whatever else in here
  }
}

.some-class {
  @include do-a-thing-with-pseudo-elements();
}

… produces this CSS:

.___namespace_1234 .some-class {
  position: relative;
}
.___namespace_1234 .some-class ___namespace_1234::before {
  content: '';
  // whatever else in here
}

… but should produce:

.___namespace_1234 .some-class {
  position: relative;
}
.___namespace_1234 .some-class::before {
  content: '';
  // whatever else in here
}

cc/ @oligriffiths

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
davearelcommented, Feb 27, 2017

@webark probably the best temporary fix. Or use something like & {} and just wrap everything inside it.

0reactions
webarkcommented, Feb 21, 2017

@davearel hmm… That one is tricky. We namespace before we preprocess the style files. In your case, that would be somewhere you’d have to preprocess it before adding the namespaces, which opens up a whole other can of worms. I’d say, giving you access to some kine of :--component css property that refers to the component would be better. But maybe not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pseudo Namespacing · Issue #440 · sass/sass - GitHub
Now I've written a mixin that targets certain contexts -- media queries, namespace classes on the root element, etc. @mixin contextify($media-query ...
Read more >
Can a CSS pseudo-class be namespaced? - Stack Overflow
1 Answer 1 ... Namespaces, as part of the document language, do not apply directly to pseudo-classes or pseudo-elements, as they're defined in...
Read more >
Less.js Mixins Namespaces - GeeksforGeeks
Less.js Mixins Namespaces helps to stack up several ids or classes to mixin properties inside a more complex selector.
Read more >
Enter Sass namespacing - Joseph Rex
To solve maintainance problem in CSS we've seen OOCSS, RSCSS, SMACSS, and BEM. With BEM being the most adopted, we opt-in to create...
Read more >
Add your own LESS namespace when mixins collections have ...
It's nice as long, as your own mixins' names don't collide with names in a chosen mixins collection.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found