Skip to content

Commit d23ccb6

Browse files
committed
fix: 修复顺序问题
1 parent 435efef commit d23ccb6

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/json_writer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
use std::collections::HashMap;
3+
use indexmap::IndexMap;
34
use serde_json::Value;
45
use swc_core::common::DUMMY_SP;
56
use swc_core::ecma::ast::*;
@@ -12,12 +13,12 @@ use crate::utils;
1213
use crate::visitor::parse_style_values;
1314

1415
pub struct JsonWriter {
15-
styles: HashMap<String, Vec<StyleValueType>>,
16+
styles: IndexMap<String, Vec<StyleValueType>>,
1617
}
1718

1819
impl JsonWriter {
1920

20-
pub fn new(styles: HashMap<String, Vec<StyleValueType>>) -> Self {
21+
pub fn new(styles: IndexMap<String, Vec<StyleValueType>>) -> Self {
2122
Self { styles }
2223
}
2324

src/style_parser.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use std::{rc::Rc, cell::RefCell, convert::Infallible, collections::HashMap, hash::Hash};
1+
use std::{cell::RefCell, collections::HashMap, convert::Infallible, hash::Hash, rc::Rc};
22

3+
use indexmap::IndexMap;
34
use lightningcss::{declaration::DeclarationBlock, properties::Property, rules::{keyframes::KeyframeSelector, CssRule}, stylesheet::{ParserOptions, PrinterOptions, StyleSheet}, traits::ToCss, visit_types, visitor::{Visit, VisitTypes, Visitor}};
45

56
use crate::{style_propetries::{style_value_type::StyleValueType, unit::Platform}, utils::to_camel_case};
@@ -9,7 +10,7 @@ use super::parse_style_properties::parse_style_properties;
910
pub type StyleValue = Vec<StyleValueType>;
1011
#[derive(Debug)]
1112
pub struct StyleData {
12-
pub all_style: Rc<RefCell<HashMap<String, StyleValue>>>,
13+
pub all_style: Rc<RefCell<IndexMap<String, StyleValue>>>,
1314
}
1415

1516
pub struct KeyFramesData {
@@ -185,7 +186,7 @@ impl<'i> StyleParser<'i> {
185186
),
186187
)
187188
})
188-
.collect::<HashMap<_, _>>();
189+
.collect::<IndexMap<_, _>>();
189190

190191
StyleData {
191192
all_style: Rc::new(RefCell::new(final_all_style)),

src/style_propetries/line_height.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ impl From<(String, &Property<'_>)> for LineHeight {
4949
id: prop.0,
5050
value: match prop.1 {
5151
Property::LineHeight(value) => {
52-
println!("line-height: {:?}", value);
5352
match value {
5453
font::LineHeight::Length(val) => {
5554
generate_dimension_percentage!(EnumValue, val)

0 commit comments

Comments
 (0)