feat(codegen): keep shorthand in ObjectPattern and ObjectProperty (#2265)

close: #2262

Do I need to add a test for this?
This commit is contained in:
Dunqing 2024-02-02 16:32:51 +08:00 committed by GitHub
parent d6ba058f77
commit 8ac0202c9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1371,11 +1371,15 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for ObjectProperty<'a> {
if self.computed {
p.print(b'[');
}
self.key.gen(p, ctx);
if !self.shorthand {
self.key.gen(p, ctx);
}
if self.computed {
p.print(b']');
}
p.print_colon();
if !self.shorthand {
p.print_colon();
}
self.value.gen_expr(p, Precedence::Assign, Context::default());
}
}
@ -2180,11 +2184,15 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for BindingProperty<'a> {
if self.computed {
p.print(b'[');
}
self.key.gen(p, ctx);
if !self.shorthand {
self.key.gen(p, ctx);
}
if self.computed {
p.print(b']');
}
p.print(b':');
if !self.shorthand {
p.print_colon();
}
self.value.gen(p, ctx);
}
}