File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -6,18 +6,25 @@ const docFixer = require("./parse-style");
66const htmlParser = require ( "./html-parser" ) ;
77
88function parser ( source , opts ) {
9+ function filenameMatch ( reg ) {
10+ return opts . from && reg . test ( opts . from ) ;
11+ }
912 // Skip known style sheet and script files.
10- if ( opts . from && / \. (?: (?: \w * c | w x | l e | s a | s ) s s | s t y l (?: u s ) ? | m ? [ j t ] s x ? | e s \d * | p a c ) (?: \? .* ) ? $ / i. test ( opts . from ) ) {
13+ if ( filenameMatch ( / \. (?: (?: \w * c | w x | l e | s a | s ) s s | s t y l (?: u s ) ? | m ? [ j t ] s x ? | e s \d * | p a c ) (?: \? .* ) ? $ / i) ) {
1114 return ;
1215 }
1316
1417 source = source && source . toString ( ) ;
1518
1619 const styleHtm = htmlParser ( source , opts ) ;
20+ if ( ! styleHtm && ! filenameMatch ( / \. (?: [ s x ] ? h t m l ? | [ s x ] h t | v u e | u x | p h p ) (?: \? .* ) ? $ / i) ) {
21+ return ;
22+ }
1723 const document = new Document ( ) ;
18- const parseStyle = docFixer ( source , opts ) ;
24+
1925 let index = 0 ;
2026 if ( styleHtm ) {
27+ const parseStyle = docFixer ( source , opts ) ;
2128 styleHtm . sort ( ( a , b ) => {
2229 return a . startIndex - b . startIndex ;
2330 } ) . forEach ( style => {
Original file line number Diff line number Diff line change 11{
22 "name" : " postcss-html" ,
3- "version" : " 0.20.0 " ,
3+ "version" : " 0.20.1 " ,
44 "description" : " PostCSS syntax for parsing HTML (and HTML-like)" ,
55 "main" : " lib/index.js" ,
66 "scripts" : {
Original file line number Diff line number Diff line change @@ -420,7 +420,8 @@ describe("html tests", () => {
420420 from : undefined ,
421421 }
422422 ) . then ( result => {
423- expect ( result . root . nodes ) . to . have . lengthOf ( 0 ) ;
423+ expect ( result . root . nodes ) . to . have . lengthOf ( 1 ) ;
424+ expect ( result . root . nodes [ 0 ] ) . to . have . property ( "type" ) . to . equal ( "comment" ) ;
424425 } ) ;
425426 } ) ;
426427} ) ;
You can’t perform that action at this time.
0 commit comments