File tree Expand file tree Collapse file tree 5 files changed +48
-13
lines changed
Expand file tree Collapse file tree 5 files changed +48
-13
lines changed Original file line number Diff line number Diff line change @@ -82,15 +82,13 @@ export const tests = (isLightningCSS: boolean) => {
8282 await untilUpdated ( ( ) => getColor ( imported ) , 'red' )
8383 } )
8484
85- if ( ! isLightningCSS ) {
86- test ( 'postcss plugin that injects url()' , async ( ) => {
87- const imported = await page . $ ( '.postcss-inject-url' )
88- // alias should be resolved
89- expect ( await getBg ( imported ) ) . toMatch (
90- / l o c a l h o s t (?: : \d + ) ? \/ (?: a s s e t s \/ ) ? o k .* \. p n g / ,
91- )
92- } )
93- }
85+ test ( 'postcss plugin that injects url()' , async ( ) => {
86+ const imported = await page . $ ( '.inject-url' )
87+ // alias should be resolved
88+ expect ( await getBg ( imported ) ) . toMatch (
89+ / l o c a l h o s t (?: : \d + ) ? \/ (?: a s s e t s \/ ) ? o k .* \. p n g / ,
90+ )
91+ } )
9492
9593 sassTest ( )
9694
Original file line number Diff line number Diff line change @@ -23,9 +23,7 @@ <h1>CSS</h1>
2323 < p class ="postcss ">
2424 < span class ="nesting "> PostCSS nesting plugin: this should be pink</ span >
2525 </ p >
26- < p class ="postcss-inject-url ">
27- PostCSS plugin: this should have a background image
28- </ p >
26+ < p class ="inject-url "> PostCSS plugin: this should have a background image</ p >
2927
3028 < p class ="sass "> SASS: This should be orange</ p >
3129 < p class ="sass-at-import ">
Original file line number Diff line number Diff line change @@ -171,3 +171,40 @@ export function nestedLikePlugin() {
171171 } ,
172172 }
173173}
174+
175+ /** @returns {import('lightningcss').Visitor } */
176+ export function testInjectUrl ( ) {
177+ return {
178+ Rule : {
179+ unknown : {
180+ 'inject-url' : ( rule ) => {
181+ return [
182+ {
183+ type : 'style' ,
184+ value : {
185+ selectors : [ [ { type : 'class' , name : 'inject-url' } ] ] ,
186+ declarations : {
187+ declarations : [
188+ {
189+ property : 'background-image' ,
190+ value : [
191+ {
192+ type : 'url' ,
193+ value : {
194+ url : '=/ok.png' ,
195+ loc : rule . loc ,
196+ } ,
197+ } ,
198+ ] ,
199+ } ,
200+ ] ,
201+ } ,
202+ loc : rule . loc ,
203+ } ,
204+ } ,
205+ ]
206+ } ,
207+ } ,
208+ } ,
209+ }
210+ }
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ function testInjectUrl() {
6868 Once ( root , { Rule } ) {
6969 root . walkAtRules ( 'inject-url' , ( atRule ) => {
7070 const rule = new Rule ( {
71- selector : '.postcss- inject-url' ,
71+ selector : '.inject-url' ,
7272 source : atRule . source ,
7373 } )
7474 rule . append ( {
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import baseConfig from './vite.config.js'
44import {
55 nestedLikePlugin ,
66 testDirDep ,
7+ testInjectUrl ,
78 testSourceInput ,
89} from './lightningcss-plugins'
910
@@ -20,6 +21,7 @@ export default defineConfig({
2021 nestedLikePlugin ( ) ,
2122 testDirDep ( ) ,
2223 testSourceInput ( ) ,
24+ testInjectUrl ( ) ,
2325 ] ) ,
2426 } ,
2527 } ,
You can’t perform that action at this time.
0 commit comments