1
1
//! CSS selectors.
2
2
3
- use std:: cell:: RefCell ;
4
3
use std:: convert:: TryFrom ;
5
4
use std:: fmt;
6
5
@@ -10,7 +9,6 @@ use html5ever::{LocalName, Namespace};
10
9
use selectors:: {
11
10
matching,
12
11
parser:: { self , ParseRelative , SelectorParseErrorKind } ,
13
- NthIndexCache ,
14
12
} ;
15
13
16
14
use crate :: error:: SelectorErrorKind ;
@@ -46,25 +44,19 @@ impl Selector {
46
44
/// The optional `scope` argument is used to specify which element has `:scope` pseudo-class.
47
45
/// When it is `None`, `:scope` will match the root element.
48
46
pub fn matches_with_scope ( & self , element : & ElementRef , scope : Option < ElementRef > ) -> bool {
49
- thread_local ! {
50
- static NTH_INDEX_CACHE : RefCell <NthIndexCache > = Default :: default ( ) ;
51
- }
52
-
53
- NTH_INDEX_CACHE . with ( |nth_index_cache| {
54
- let mut nth_index_cache = nth_index_cache. borrow_mut ( ) ;
55
- let mut context = matching:: MatchingContext :: new (
56
- matching:: MatchingMode :: Normal ,
57
- None ,
58
- & mut nth_index_cache,
59
- matching:: QuirksMode :: NoQuirks ,
60
- matching:: NeedsSelectorFlags :: No ,
61
- matching:: IgnoreNthChildForInvalidation :: No ,
62
- ) ;
63
- context. scope_element = scope. map ( |x| selectors:: Element :: opaque ( & x) ) ;
64
- self . selectors
65
- . iter ( )
66
- . any ( |s| matching:: matches_selector ( s, 0 , None , element, & mut context) )
67
- } )
47
+ let mut nth_index_cache = Default :: default ( ) ;
48
+ let mut context = matching:: MatchingContext :: new (
49
+ matching:: MatchingMode :: Normal ,
50
+ None ,
51
+ & mut nth_index_cache,
52
+ matching:: QuirksMode :: NoQuirks ,
53
+ matching:: NeedsSelectorFlags :: No ,
54
+ matching:: IgnoreNthChildForInvalidation :: No ,
55
+ ) ;
56
+ context. scope_element = scope. map ( |x| selectors:: Element :: opaque ( & x) ) ;
57
+ self . selectors
58
+ . iter ( )
59
+ . any ( |s| matching:: matches_selector ( s, 0 , None , element, & mut context) )
68
60
}
69
61
}
70
62
0 commit comments