Skip to content

Commit

Permalink
refactor(transformer/object-reset-spread): make plugin initialization…
Browse files Browse the repository at this point in the history
… unconditional (#5319)

Align with other plugins
  • Loading branch information
Dunqing committed Aug 29, 2024
1 parent 9c22ce9 commit 1645115
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/oxc_transformer/src/es2018/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ pub struct ES2018<'a> {
options: ES2018Options,

// Plugins
object_rest_spread: Option<ObjectRestSpread<'a>>,
object_rest_spread: ObjectRestSpread<'a>,
}

impl<'a> ES2018<'a> {
pub fn new(options: ES2018Options, ctx: Ctx<'a>) -> Self {
Self {
object_rest_spread: options
.object_rest_spread
.map(|options| ObjectRestSpread::new(options, Rc::clone(&ctx))),
object_rest_spread: ObjectRestSpread::new(
options.object_rest_spread.unwrap_or_default(),
Rc::clone(&ctx),
),
ctx,
options,
}
Expand All @@ -34,8 +35,8 @@ impl<'a> ES2018<'a> {

impl<'a> Traverse<'a> for ES2018<'a> {
fn enter_expression(&mut self, expr: &mut Expression<'a>, ctx: &mut TraverseCtx<'a>) {
if let Some(object_rest_spread) = &mut self.object_rest_spread {
object_rest_spread.enter_expression(expr, ctx);
if self.options.object_rest_spread.is_some() {
self.object_rest_spread.enter_expression(expr, ctx);
}
}
}

0 comments on commit 1645115

Please sign in to comment.