File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -86,11 +86,7 @@ impl Preprocessor {
8686 GLOBALS . set ( & Default :: default ( ) , || {
8787 let parsed_module = parser. parse_module ( ) ?;
8888
89- let mut visitor = locate:: LocateContentTagVisitor {
90- occurrences : Default :: default ( ) ,
91- is_ascii : src. is_ascii ( ) ,
92- src : src. to_string ( ) ,
93- } ;
89+ let mut visitor = locate:: LocateContentTagVisitor :: new ( src. to_string ( ) ) ;
9490
9591 parsed_module. visit_with ( & mut visitor) ;
9692
Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ use swc_ecma_visit::{Visit, VisitWith};
99#[ derive( Default , Debug ) ]
1010pub struct LocateContentTagVisitor {
1111 pub occurrences : Vec < Occurrence > ,
12- pub src : String ,
13- pub is_ascii : bool ,
12+ src : String ,
13+ is_ascii : bool ,
1414}
1515
1616#[ derive( Eq , PartialEq , Debug , Serialize ) ]
@@ -21,6 +21,15 @@ enum ContentTagKind {
2121}
2222
2323impl LocateContentTagVisitor {
24+ pub fn new ( src : String ) -> Self {
25+ let is_ascii = src. is_ascii ( ) ;
26+ Self {
27+ occurrences : Default :: default ( ) ,
28+ src,
29+ is_ascii,
30+ }
31+ }
32+
2433 fn add_occurrence (
2534 & mut self ,
2635 kind : ContentTagKind ,
You can’t perform that action at this time.
0 commit comments