File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -27,9 +27,10 @@ function memoize(fn) {
27
27
* @return {string }
28
28
*/
29
29
const reduceCSSSelector = memoize ( ( selector ) => {
30
- return selector . split (
31
- / : (? = ( [ ^ " ' \\ ] * ( \\ .| [ " ' ] ( [ ^ " ' \\ ] * \\ .) * [ ^ " ' \\ ] * [ ' " ] ) ) * [ ^ " ' ] * $ ) / g
32
- ) [ 0 ] ;
30
+ selector = selector . replace ( '\\:' , '_ESCAPED_COLON_' ) ;
31
+ return selector
32
+ . split ( / : (? = ( [ ^ " ' \\ ] * ( \\ .| [ " ' ] ( [ ^ " ' \\ ] * \\ .) * [ ^ " ' \\ ] * [ ' " ] ) ) * [ ^ " ' ] * $ ) / g) [ 0 ]
33
+ . replace ( '_ESCAPED_COLON_' , '\\:' ) ;
33
34
} ) ;
34
35
35
36
/**
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ test('Test reduceCSSSelector', async () => {
20
20
expect ( f ( "a[href^='javascript:']:after" ) ) . toEqual ( "a[href^='javascript:']" ) ;
21
21
} ) ;
22
22
23
+ test ( 'Test backslash selectors' , async ( ) => {
24
+ expect ( utils . reduceCSSSelector ( 'foo\\:hover' ) ) . toEqual ( 'foo\\:hover' ) ;
25
+ } ) ;
26
+
23
27
test ( 'Test parentSelectors' , async ( ) => {
24
28
const f = utils . getParentSelectors ;
25
29
// Simplest possible
You can’t perform that action at this time.
0 commit comments