File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,27 @@ function processApply(root, context) {
122122 // Fill up some caches!
123123 let applyClassCache = buildApplyCache ( applyCandidates , context )
124124
125+ // Collect all classes for @apply rules.
126+ root . walk ( ( node ) => {
127+ if ( node . selector && node . selector [ 0 ] === '.' ) {
128+ const name = node . selector . substring ( 1 )
129+
130+ // Ignore unused candidates.
131+ if ( applyCandidates . has ( name ) && ! applyClassCache . has ( name ) ) {
132+ applyClassCache . set ( name , [
133+ [
134+ {
135+ sort : BigInt ( context . layerOrder . user ) ,
136+ layer : 'user' ,
137+ options : { } ,
138+ } ,
139+ node ,
140+ ] ,
141+ ] )
142+ }
143+ }
144+ } )
145+
125146 /**
126147 * When we have an apply like this:
127148 *
Original file line number Diff line number Diff line change @@ -616,3 +616,42 @@ it('rules with vendor prefixes are still separate when optimizing defaults rules
616616 ` )
617617 } )
618618} )
619+
620+ it ( 'should pickup all classes' , ( ) => {
621+ let config = {
622+ content : [ { raw : html `<div class= "foo" > </ div> ` } ] ,
623+ plugins : [ ] ,
624+ }
625+
626+ let input = css `
627+ @tailwind components;
628+ @tailwind utilities;
629+
630+ .bop {
631+ color : red;
632+ }
633+
634+ @layer components {
635+ .bar {
636+ background-color : blue;
637+ }
638+
639+ .foo {
640+ @apply absolute bar bop;
641+ }
642+ }
643+ `
644+
645+ return run ( input , config ) . then ( ( result ) => {
646+ return expect ( result . css ) . toMatchFormattedCss ( css `
647+ .foo {
648+ background-color : blue;
649+ position : absolute;
650+ color : red;
651+ }
652+ .bop {
653+ color : red;
654+ }
655+ ` )
656+ } )
657+ } )
You can’t perform that action at this time.
0 commit comments