mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(transformer/object-reset-spread): make plugin initialization unconditional (#5319)
Align with other plugins
This commit is contained in:
parent
9c22ce9c99
commit
164511549f
1 changed files with 7 additions and 6 deletions
|
|
@ -17,15 +17,16 @@ pub struct ES2018<'a> {
|
||||||
options: ES2018Options,
|
options: ES2018Options,
|
||||||
|
|
||||||
// Plugins
|
// Plugins
|
||||||
object_rest_spread: Option<ObjectRestSpread<'a>>,
|
object_rest_spread: ObjectRestSpread<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ES2018<'a> {
|
impl<'a> ES2018<'a> {
|
||||||
pub fn new(options: ES2018Options, ctx: Ctx<'a>) -> Self {
|
pub fn new(options: ES2018Options, ctx: Ctx<'a>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
object_rest_spread: options
|
object_rest_spread: ObjectRestSpread::new(
|
||||||
.object_rest_spread
|
options.object_rest_spread.unwrap_or_default(),
|
||||||
.map(|options| ObjectRestSpread::new(options, Rc::clone(&ctx))),
|
Rc::clone(&ctx),
|
||||||
|
),
|
||||||
ctx,
|
ctx,
|
||||||
options,
|
options,
|
||||||
}
|
}
|
||||||
|
|
@ -34,8 +35,8 @@ impl<'a> ES2018<'a> {
|
||||||
|
|
||||||
impl<'a> Traverse<'a> for ES2018<'a> {
|
impl<'a> Traverse<'a> for ES2018<'a> {
|
||||||
fn enter_expression(&mut self, expr: &mut Expression<'a>, ctx: &mut TraverseCtx<'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 {
|
if self.options.object_rest_spread.is_some() {
|
||||||
object_rest_spread.enter_expression(expr, ctx);
|
self.object_rest_spread.enter_expression(expr, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue