Wrap / Prepend All Selectors
See original GitHub issueIt 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:
- Created 9 years ago
- Reactions:11
- Comments:7 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.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:
When it’s compiled to be embedded in App A, it generates:
via
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.