@@ -4,7 +4,7 @@ use lightningcss::{properties::{custom::TokenOrValue, Property}, stylesheet::Pri
4
4
use swc_core:: { common:: DUMMY_SP , ecma:: { ast:: { self } , utils:: quote_ident} } ;
5
5
use swc_core:: ecma:: ast:: * ;
6
6
7
- use crate :: { generate_expr_lit_str, style_parser:: KeyFrameItem , style_propetries:: { animation:: Animation , aspect_ratio:: AspectRatio , background:: Background , background_image:: BackgroundImage , background_position:: BackgroundPosition , background_repeat:: BackgroundRepeat , background_size:: BackgroundSize , border:: Border , border_color:: BorderColor , border_radius:: BorderRadius , border_style:: BorderStyle , border_width:: BorderWidth , box_shadow:: BoxShadow , color:: ColorProperty , display:: Display , expr:: Expr , flex:: Flex , flex_align:: FlexAlign , flex_basis:: FlexBasis , flex_direction:: FlexDirection , flex_wrap:: FlexWrap , font_size:: FontSize , font_style:: FontStyle , font_weight:: FontWeight , gap:: Gap , item_align:: ItemAlign , length_value:: LengthValueProperty , letter_spacing:: LetterSpacing , line_height:: LineHeight , marin_padding:: MarginPadding , max_size:: MaxSizeProperty , normal:: Normal , number:: NumberProperty , opacity:: Opacity , overflow:: Overflow , position:: Position , size:: SizeProperty , style_property_type:: { string_to_css_property_type, CSSPropertyType } , style_value_type:: StyleValueType , text_align:: TextAlign , text_decoration:: TextDecoration , text_overflow:: TextOverflow , text_shadow:: TextShadow , text_transform:: TextTransform , transform:: Transform , transform_origin:: TransformOrigin , transition:: Transition , unit:: { generate_expr_by_length_value, Platform } , vertical_align:: VerticalAlign , visibility:: Visibility , white_space:: WhiteSpace , word_break:: WordBreak } } ;
7
+ use crate :: { generate_expr_lit_str, style_parser:: KeyFrameItem , style_propetries:: { animation:: Animation , aspect_ratio:: AspectRatio , background:: Background , background_image:: BackgroundImage , background_position:: BackgroundPosition , background_repeat:: BackgroundRepeat , background_size:: BackgroundSize , border:: Border , border_color:: BorderColor , border_radius:: BorderRadius , border_style:: BorderStyle , border_width:: BorderWidth , box_shadow:: BoxShadow , color:: ColorProperty , display:: Display , expr:: Expr , flex:: Flex , flex_align:: FlexAlign , flex_basis:: FlexBasis , flex_direction:: FlexDirection , flex_wrap:: FlexWrap , font_size:: FontSize , font_style:: FontStyle , font_weight:: FontWeight , gap:: Gap , item_align:: ItemAlign , length_value:: LengthValueProperty , letter_spacing:: LetterSpacing , line_height:: LineHeight , marin_padding:: MarginPadding , max_size:: MaxSizeProperty , normal:: Normal , number:: NumberProperty , opacity:: Opacity , overflow:: Overflow , position:: Position , size:: SizeProperty , style_property_type:: { string_to_css_property_type, CSSPropertyType } , style_value_type:: StyleValueType , text_align:: TextAlign , text_decoration:: TextDecoration , text_overflow:: TextOverflow , text_shadow:: TextShadow , text_transform:: TextTransform , transform:: Transform , transform_origin:: TransformOrigin , transition:: Transition , unit:: { generate_expr_by_length_value, Platform } , vertical_align:: VerticalAlign , visibility:: Visibility , white_space:: WhiteSpace , word_break:: WordBreak } , utils:: lowercase_first} ;
8
8
9
9
pub fn parse_style_properties ( properties : & Vec < ( String , Property ) > , keyframes_map : Option < Rc < RefCell < HashMap < String , Vec < KeyFrameItem > > > > > ) -> Vec < StyleValueType > {
10
10
let mut final_properties = vec ! [ ] ;
@@ -32,9 +32,21 @@ pub fn parse_style_properties(properties: &Vec<(String, Property)>, keyframes_ma
32
32
continue ;
33
33
}
34
34
35
-
36
- let property_name = id. as_str ( ) ;
37
- match property_name {
35
+ let mut property_name = id. as_str ( ) ;
36
+
37
+ // 移除部分厂商前缀: Webkit, Moz, 并且把首字母小写
38
+ if property_name. starts_with ( "Webkit" ) {
39
+ property_name = & property_name[ 6 ..] ;
40
+ } else if property_name. starts_with ( "Moz" ) {
41
+ property_name = & property_name[ 3 ..] ;
42
+ }
43
+
44
+ // 将property_name首字母小写
45
+ let mut property_name = property_name. to_string ( ) ;
46
+ lowercase_first ( & mut property_name) ;
47
+
48
+
49
+ match property_name. as_str ( ) {
38
50
// 基础样式
39
51
"alignContent" => {
40
52
final_properties. push ( StyleValueType :: FlexAlign ( FlexAlign :: from ( ( id. to_string ( ) , value) ) ) ) ;
@@ -226,7 +238,7 @@ pub fn parse_style_properties(properties: &Vec<(String, Property)>, keyframes_ma
226
238
"zIndex" => {
227
239
final_properties. push ( StyleValueType :: Normal ( Normal :: new ( CSSPropertyType :: ZIndex , value. value_to_css_string ( PrinterOptions :: default ( ) ) . unwrap ( ) ) ) ) ;
228
240
}
229
- "WebkitLineClamp " => {
241
+ "lineClamp " => {
230
242
final_properties. push ( StyleValueType :: Normal ( Normal :: new ( CSSPropertyType :: WebkitLineClamp , value. value_to_css_string ( PrinterOptions :: default ( ) ) . unwrap ( ) ) ) ) ;
231
243
}
232
244
"wordBreak" => {
0 commit comments