@@ -18,6 +18,7 @@ import { env } from './sharedState'
1818import { toPath } from '../util/toPath'
1919import log from '../util/log'
2020import negateValue from '../util/negateValue'
21+ import isValidArbitraryValue from '../util/isValidArbitraryValue'
2122
2223function parseVariantFormatString ( input ) {
2324 if ( input . includes ( '{' ) ) {
@@ -130,64 +131,6 @@ function withIdentifiers(styles) {
130131 } )
131132}
132133
133- let matchingBrackets = new Map ( [
134- [ '{' , '}' ] ,
135- [ '[' , ']' ] ,
136- [ '(' , ')' ] ,
137- ] )
138- let inverseMatchingBrackets = new Map (
139- Array . from ( matchingBrackets . entries ( ) ) . map ( ( [ k , v ] ) => [ v , k ] )
140- )
141-
142- let quotes = new Set ( [ '"' , "'" , '`' ] )
143-
144- // Arbitrary values must contain balanced brackets (), [] and {}. Escaped
145- // values don't count, and brackets inside quotes also don't count.
146- //
147- // E.g.: w-[this-is]w-[weird-and-invalid]
148- // E.g.: w-[this-is\\]w-\\[weird-but-valid]
149- // E.g.: content-['this-is-also-valid]-weirdly-enough']
150- function isValidArbitraryValue ( value ) {
151- let stack = [ ]
152- let inQuotes = false
153-
154- for ( let i = 0 ; i < value . length ; i ++ ) {
155- let char = value [ i ]
156-
157- // Non-escaped quotes allow us to "allow" anything in between
158- if ( quotes . has ( char ) && value [ i - 1 ] !== '\\' ) {
159- inQuotes = ! inQuotes
160- }
161-
162- if ( inQuotes ) continue
163- if ( value [ i - 1 ] === '\\' ) continue // Escaped
164-
165- if ( matchingBrackets . has ( char ) ) {
166- stack . push ( char )
167- } else if ( inverseMatchingBrackets . has ( char ) ) {
168- let inverse = inverseMatchingBrackets . get ( char )
169-
170- // Nothing to pop from, therefore it is unbalanced
171- if ( stack . length <= 0 ) {
172- return false
173- }
174-
175- // Popped value must match the inverse value, otherwise it is unbalanced
176- if ( stack . pop ( ) !== inverse ) {
177- return false
178- }
179- }
180- }
181-
182- // If there is still something on the stack, it is also unbalanced
183- if ( stack . length > 0 ) {
184- return false
185- }
186-
187- // All good, totally balanced!
188- return true
189- }
190-
191134function buildPluginApi ( tailwindConfig , context , { variantList, variantMap, offsets, classList } ) {
192135 function getConfigValue ( path , defaultValue ) {
193136 return path ? dlv ( tailwindConfig , path , defaultValue ) : tailwindConfig
@@ -617,6 +560,10 @@ function registerPlugins(plugins, context) {
617560 ] )
618561 let reservedBits = BigInt ( highestOffset . toString ( 2 ) . length )
619562
563+ // A number one less than the top range of the highest offset area
564+ // so arbitrary properties are always sorted at the end.
565+ context . arbitraryPropertiesSort = ( ( 1n << reservedBits ) << 0n ) - 1n
566+
620567 context . layerOrder = {
621568 base : ( 1n << reservedBits ) << 0n ,
622569 components : ( 1n << reservedBits ) << 1n ,
0 commit comments