@@ -44,10 +44,11 @@ const reVar = /^-?(?:@.+|(?:(?:[a-zA-Z_-]|[^\x00-\x7F])+(?:[a-zA-Z0-9_-]|[^\x00-
44
44
* @default
45
45
*/
46
46
const reFunc = / ^ (? ! v a r \( \s * - - ) [ \s \S ] + \( [ \s \S ] * \) $ /
47
- const isRegexString = ( value ) => value . charAt ( 0 ) === '/' && value . slice ( - 1 ) === '/'
48
- const getRegexString = ( value ) => value . slice ( 1 , - 1 )
49
- const stringToRegex = ( value ) => new RegExp ( getRegexString ( value ) )
50
- const mapIgnoreValue = ( ignoreValue ) => ( isRegexString ( ignoreValue ) ? getRegexString ( ignoreValue ) : `^${ ignoreValue } $` )
47
+ const reRegex = / ^ \/ ( .* ) \/ ( [ a - z A - Z ] * ) $ /
48
+ const isRegexString = ( value ) => reRegex . test ( value )
49
+ const getRegexString = ( value ) => value . match ( reRegex ) . slice ( 1 )
50
+ const stringToRegex = ( value ) => new RegExp ( ...getRegexString ( value ) )
51
+ const mapIgnoreValue = ( ignoreValue ) => ( isRegexString ( ignoreValue ) ? stringToRegex ( ignoreValue ) : new RegExp ( `^${ ignoreValue } $` ) )
51
52
52
53
/**
53
54
* A rule function essentially returns a little PostCSS plugin.
@@ -163,19 +164,19 @@ const ruleFunction = (properties, options, context = {}) => (root, result) => {
163
164
}
164
165
165
166
if ( ignoreValues && ( ! validVar || ! validFunc || ! validKeyword ) ) {
166
- let reValue = reValues [ property ]
167
+ let reValueList = reValues [ property ]
167
168
168
- if ( ! reValue ) {
169
- const ignoreKeyword = getIgnoredValues ( ignoreValues , property )
169
+ if ( ! reValueList ) {
170
+ const ignoreValue = getIgnoredValues ( ignoreValues , property )
170
171
171
- if ( ignoreKeyword ) {
172
- reValue = new RegExp ( ignoreValues . map ( mapIgnoreValue ) . join ( '|' ) )
173
- reValues [ property ] = reValue
172
+ if ( ignoreValue ) {
173
+ reValueList = ignoreValue . map ( mapIgnoreValue )
174
+ reValues [ property ] = reValueList
174
175
}
175
176
}
176
177
177
- if ( reValue ) {
178
- validValue = reValue . test ( value )
178
+ if ( reValueList ) {
179
+ validValue = reValueList . filter ( ( reValue ) => reValue . test ( value ) ) . length > 0
179
180
}
180
181
}
181
182
0 commit comments