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.

Wrap / Prepend All Selectors

See original GitHub issue

It would be really handy with a “wrap/prepend” all selectors feature for apps that lives inside a global website. Adding a unique prefix for each individual element isn’t enough all time depending of the CSS complexity of your app.

Adding a namespace like below doesn’t work because the “context” class will be generated infront of the #ns which is not the result we want. Desired output would be “#ns .context .block”.

#ns {
    .block {
        prop: val;
        .context & {
            prop: val
        }
    }
}

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:11
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
nex3commented, Oct 15, 2019

@thedamon In the new module system, you can use the meta.load-css() mixin to include a stylesheet’s CSS nested within a parent selector. This won’t affect the way parent selectors in the loaded module’s CSS are resolved, so it should work how you want it to.

4reactions
sambakercommented, Oct 13, 2014

This feature is exactly what I need. I have App A that embeds another app, App B. App B can be stand-alone or embedded in App A. I have one App B sass file that wraps all of the App B imports in a class selector so that App A can embed a chunk of App B with that class wrapped around it.

When App B is compiled to run independently it generates:

    .block {
        prop: val;
        .context & {
            prop: val
        }
    }

When it’s compiled to be embedded in App A, it generates:

#ns {
    .block {
        prop: val;
        .context & {
            prop: val
        }
    }
}

via

#ns {
  @import "appBstyles1.scss"
  @import "appBstyles2.scss"
}

But of course this breaks the ampersand operator as @tomahl mentioned.

I don’t see how to allow this with the selector functions, however if I was able to add a rule saying to add a #ns wrapper to everything from App B then every other rule in appBstyles*.scss could stay as is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prepend all CSS selectors - Stack Overflow
All I want, is to be able to prepend an ID "#content" to every selector in a css file. javascript · jquery ·...
Read more >
.wrapAll() | jQuery API Documentation
A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. version added: 1.4.wrapAll( function ).
Read more >
CSS selectors - CSS: Cascading Style Sheets - MDN Web Docs
The , selector is a grouping method that selects all the matching nodes. Syntax: A, B. Example: div, span will match both <span>...
Read more >
.wrap() - jQuery - W3cubDocs
Description: Wrap an HTML structure around each element in the set of matched ... A selector, element, HTML string, or jQuery object specifying...
Read more >
jQuery wrap() Method - W3Schools
The wrap() method wraps specified HTML element(s) around each selected element. Syntax. $(selector).wrap(wrappingElement,function(index)). Parameter ...
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