Skip to content

Commit 4c15e38

Browse files
committed
feat: 完善组件返回值包裹用于层叠的函数
1 parent 15b425f commit 4c15e38

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/constants.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub const CONVERT_STYLE_PX_FN: &'static str = "convertNumber2VP";
33
pub const INNER_STYLE: &'static str = "__inner_style__";
44
pub const INNER_STYLE_DATA: &'static str = "__inner_style_data__";
55
pub const NESTING_STYLE: &'static str = "__nesting_style__";
6+
pub const COMBINE_NESTING_STYLE: &'static str = "__combine_nesting_style__";
67
pub const NESTINT_STYLE_DATA: &'static str = "__nesting_style_data__";
78
pub const CALC_DYMAMIC_STYLE: &'static str = "calcDynamicStyle";
89

src/visitor.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use swc_ecma_visit::{
2323
};
2424

2525
use crate::{
26-
constants::{CALC_DYMAMIC_STYLE, CONVERT_STYLE_PX_FN, INNER_STYLE, INNER_STYLE_DATA, NESTING_STYLE, NESTINT_STYLE_DATA, RN_CONVERT_STYLE_PX_FN, RN_CONVERT_STYLE_VU_FN}, parse_style_properties::parse_style_properties, scraper::Element, style_parser::StyleValue, style_propetries::{style_value_type::StyleValueType, traits::ToStyleValue, unit::{Platform, PropertyTuple}}, utils::{
26+
constants::{CALC_DYMAMIC_STYLE, COMBINE_NESTING_STYLE, CONVERT_STYLE_PX_FN, INNER_STYLE, INNER_STYLE_DATA, NESTING_STYLE, NESTINT_STYLE_DATA, RN_CONVERT_STYLE_PX_FN, RN_CONVERT_STYLE_VU_FN}, parse_style_properties::parse_style_properties, scraper::Element, style_parser::StyleValue, style_propetries::{style_value_type::StyleValueType, traits::ToStyleValue, unit::{Platform, PropertyTuple}}, utils::{
2727
create_qualname, get_callee_attributes, prefix_style_key, recursion_jsx_member, split_selector, to_camel_case, to_kebab_case
2828
}
2929
};
@@ -409,6 +409,12 @@ pub fn insert_import_module_decl(module: &mut Module, last_import_index: usize,
409409
// ))),
410410
imported: None,
411411
is_type_only: false,
412+
}),
413+
ImportSpecifier::Named(ImportNamedSpecifier {
414+
span: DUMMY_SP,
415+
local: Ident::new(COMBINE_NESTING_STYLE.into(), DUMMY_SP),
416+
imported: None,
417+
is_type_only: false,
412418
})
413419
],
414420
src: Box::new(Str::from("@tarojs/runtime")),
@@ -445,8 +451,16 @@ impl ModuleMutVisitor {
445451
let expr = arg.take().unwrap();
446452
*arg = Some(Box::new(Expr::Call(CallExpr {
447453
span: DUMMY_SP,
448-
callee: Callee::Expr(Box::new(Expr::Ident(quote_ident!("MyMethod")))),
449-
args: vec![ExprOrSpread { expr, spread: None }],
454+
callee: Callee::Expr(Box::new(Expr::Ident(quote_ident!(COMBINE_NESTING_STYLE)))),
455+
args: vec![
456+
ExprOrSpread { expr, spread: None },
457+
ExprOrSpread { expr: Box::new(Expr::Call(CallExpr {
458+
span: DUMMY_SP,
459+
callee: Callee::Expr(Box::new(Expr::Ident(quote_ident!(NESTING_STYLE)))),
460+
args: vec![],
461+
type_args: None
462+
})), spread: None }
463+
],
450464
type_args: None,
451465
})))
452466
}

0 commit comments

Comments
 (0)