Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
selector-anb-no-unmatchable
performance (#6925)
* Fix `selector-anb-no-unmatchable` performance * Update lib/utils/hasANPlusBNotationPseudoClasses.js Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> * Create modern-numbers-impress.md --------- Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
- Loading branch information
1 parent
f72a6a9
commit 4e3abf7
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"stylelint": patch | ||
--- | ||
|
||
Fixed: `selector-anb-no-unmatchable` performance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
const { | ||
aNPlusBNotationPseudoClasses, | ||
aNPlusBOfSNotationPseudoClasses, | ||
} = require('../reference/selectors'); | ||
|
||
const classes = [ | ||
...aNPlusBNotationPseudoClasses.values(), | ||
...aNPlusBOfSNotationPseudoClasses.values(), | ||
].join('|'); | ||
const HAS_A_N_PLUS_B_NOTATION_PSEUDO_CLASSES = new RegExp(`\\b:(?:${classes})\\(`, 'i'); | ||
|
||
/** | ||
* Check if a selector contains any pseudo class function that might contain an An+B notation | ||
* | ||
* @param {string} selector | ||
* @returns {boolean} | ||
*/ | ||
module.exports = function hasANPlusBNotationPseudoClasses(selector) { | ||
return HAS_A_N_PLUS_B_NOTATION_PSEUDO_CLASSES.test(selector); | ||
}; |