File tree Expand file tree Collapse file tree 2 files changed +64
-1
lines changed
Expand file tree Collapse file tree 2 files changed +64
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,13 @@ import cloneNodes from '../../util/cloneNodes'
66let env = sharedState . env
77let contentMatchCache = sharedState . contentMatchCache
88
9- const BROAD_MATCH_GLOBAL_REGEXP = / ( [ ^ < > " ' ` \s ] * \[ [ ^ < > \s ] + \] ) | ( [ ^ < > " ' ` \s ] * [ ^ < > " ' ` \s : ] ) / g
9+ const PATTERNS = [
10+ "([^<>\"'`\\s]*\\['[^<>\"'`\\s]*'\\])" , // `content-['hello']` but not `content-['hello']']`
11+ '([^<>"\'`\\s]*\\["[^<>"\'`\\s]*"\\])' , // `content-["hello"]` but not `content-["hello"]"]`
12+ '([^<>"\'`\\s]*\\[[^<>"\'`\\s]+\\])' , // `fill-[#bada55]`
13+ '([^<>"\'`\\s]*[^<>"\'`\\s:])' , // `px-1.5`, `uppercase` but not `uppercase:`
14+ ] . join ( '|' )
15+ const BROAD_MATCH_GLOBAL_REGEXP = new RegExp ( PATTERNS , 'g' )
1016const INNER_MATCH_GLOBAL_REGEXP = / [ ^ < > " ' ` \s . ( ) { } [ \] # = % ] * [ ^ < > " ' ` \s . ( ) { } [ \] # = % : ] / g
1117
1218const builtInExtractors = {
Original file line number Diff line number Diff line change 1+ import postcss from 'postcss'
2+ import path from 'path'
3+ import tailwind from '../../src/jit/index.js'
4+
5+ function run ( input , config = { } ) {
6+ const { currentTestName } = expect . getState ( )
7+
8+ return postcss ( tailwind ( config ) ) . process ( input , {
9+ from : `${ path . resolve ( __filename ) } ?test=${ currentTestName } ` ,
10+ } )
11+ }
12+
13+ test ( 'PHP arrays' , async ( ) => {
14+ let config = {
15+ mode : 'jit' ,
16+ purge : [
17+ {
18+ raw : `<h1 class="<?php echo wrap(['class' => "max-w-[16rem]"]); ?>">Hello world</h1>` ,
19+ } ,
20+ ] ,
21+ theme : { } ,
22+ plugins : [ ] ,
23+ }
24+
25+ let css = `@tailwind utilities`
26+
27+ return run ( css , config ) . then ( ( result ) => {
28+ expect ( result . css ) . toMatchFormattedCss ( `
29+ .max-w-\\[16rem\\] {
30+ max-width: 16rem;
31+ }
32+ ` )
33+ } )
34+ } )
35+
36+ test ( 'arbitrary values with quotes' , async ( ) => {
37+ let config = {
38+ mode : 'jit' ,
39+ purge : [
40+ {
41+ raw : `<div class="content-['hello]']"></div>` ,
42+ } ,
43+ ] ,
44+ theme : { } ,
45+ plugins : [ ] ,
46+ }
47+
48+ let css = `@tailwind utilities`
49+
50+ return run ( css , config ) . then ( ( result ) => {
51+ expect ( result . css ) . toMatchFormattedCss ( `
52+ .content-\\[\\'hello\\]\\'\\] {
53+ content: 'hello]';
54+ }
55+ ` )
56+ } )
57+ } )
You can’t perform that action at this time.
0 commit comments