Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jun 8, 2022
1 parent 521a4cb commit 11e1ce7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions crates/swc_ecma_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,27 @@ impl VisitMut for IdentReplacer<'_> {

visit_mut_obj_and_computed!();

fn visit_mut_prop(&mut self, node: &mut Prop) {
match node {
Prop::Shorthand(i) => {
let cloned = i.clone();
i.visit_mut_with(self);
if i.sym != cloned.sym || i.span.ctxt != cloned.span.ctxt {
*node = Prop::KeyValue(KeyValueProp {
key: PropName::Ident(Ident::new(
cloned.sym,
cloned.span.with_ctxt(SyntaxContext::empty()),
)),
value: Box::new(Expr::Ident(i.clone())),
});
}
}
_ => {
node.visit_mut_children_with(self);
}
}
}

fn visit_mut_ident(&mut self, node: &mut Ident) {
if node.sym == self.from.0 && node.span.ctxt == self.from.1 {
*node = self.to.clone();
Expand Down

0 comments on commit 11e1ce7

Please sign in to comment.