This repository was archived by the owner on Feb 17, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import TestMultiplySrcImport from './src-import/TestMultiplySrcImport.vue'
33import TestBlockSrcImport from ' ./src-import/TestBlockSrcImport.vue'
44import TestScopedCss from ' ./css/TestScopedCss.vue'
55import TestCssModules from ' ./css/TestCssModules.vue'
6+ import TestEmptyCss from ' ./css/TestEmptyCss.vue'
67import TestCustomBlock from ' ./custom/TestCustomBlock.vue'
78import TestHmr from ' ./hmr/TestHmr.vue'
89import TestAssets from ' ./test-assets/TestAssets.vue'
@@ -18,6 +19,7 @@ export default {
1819 TestScopedCss,
1920 TestBlockSrcImport,
2021 TestCssModules,
22+ TestEmptyCss,
2123 TestCustomBlock,
2224 TestHmr,
2325 TestAssets,
@@ -37,6 +39,7 @@ export default {
3739 <TestScopedCss />
3840 <TestCssModules />
3941 <TestCustomBlock />
42+ <TestEmptyCss />
4043 <TestHmr />
4144 <TestAssets />
4245 <TestJsx />
Original file line number Diff line number Diff line change 1+ <template >
2+ <div >
3+ <h2 >Empty CSS</h2 >
4+ <div >
5+ < ; style> ; : empty style
6+ </div >
7+ </div >
8+ </template >
9+
10+ <style scoped></style >
11+ <style module></style >
Original file line number Diff line number Diff line change @@ -283,6 +283,8 @@ async function genStyleRequest(
283283 let stylesCode = ''
284284 for ( let i = 0 ; i < descriptor . styles . length ; i ++ ) {
285285 const style = descriptor . styles [ i ]
286+ if ( ! style . src && ( ! style . content || ! style . content . trim ( ) ) )
287+ continue
286288 const src = style . src || filename
287289 const attrsQuery = attrsToQuery ( style . attrs , 'css' )
288290 const srcQuery = style . src ? '&src' : ''
Original file line number Diff line number Diff line change @@ -100,6 +100,17 @@ export function declareTests(isBuild: boolean) {
100100 }
101101 } )
102102
103+ test ( 'SFC empty style' , async ( ) => {
104+ const el = await page . $$eval ( 'style' , ( elements ) => {
105+ return elements . map ( ( e ) => {
106+ return e . innerHTML ?. trim ( )
107+ } ) . filter ( ( e ) => {
108+ return ! e
109+ } )
110+ } )
111+ expect ( el ) . toHaveLength ( 0 )
112+ } )
113+
103114 test ( 'SFC <custom>' , async ( ) => {
104115 expect ( await getText ( '.custom-block' ) ) . toMatch ( 'Custom Block' )
105116 expect ( await getText ( '.custom-block-lang' ) ) . toMatch ( 'Custom Block' )
You can’t perform that action at this time.
0 commit comments