File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -382,8 +382,17 @@ where
382382
383383 fn visit_unary_expression ( & mut self , it : & UnaryExpression < ' data > ) {
384384 if matches ! ( it. operator, UnaryOperator :: Typeof ) {
385- // don't walk to identifier rewrites since it won't matter
386- return ;
385+ match it. argument {
386+ Expression :: Identifier ( _) =>{
387+ // `typeof location` -> `typeof $wrap(location)` seems like a sane rewrite but it's incorrect
388+ // typeof has the special property of not caring whether the identifier is undefined
389+ return ;
390+ }
391+ _=>{
392+ // `typeof (location)` / `typeof location.href` / `typeof function()`
393+ // this is safe to rewrite
394+ }
395+ }
387396 }
388397 walk:: walk_unary_expression ( self , it) ;
389398 }
@@ -517,5 +526,6 @@ where
517526 }
518527 _ => { }
519528 }
529+ walk:: walk_expression ( self , & it. right ) ;
520530 }
521531}
You can’t perform that action at this time.
0 commit comments