Skip to content

Commit 5b0ae7d

Browse files
committed
fix: 修复:root不生效
1 parent 7141d5a commit 5b0ae7d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/json_writer.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ impl JsonWriter {
5252
Some({
5353
// 识别伪类
5454
let mut new_selector = rule_item.selector.selector.clone();
55-
let key_arr = new_selector.split(":").collect::<Vec<&str>>();
56-
if key_arr.len() == 2 {
57-
new_selector = key_arr[0].to_string();
55+
// 特殊处理:root选择器
56+
if new_selector != ":root" {
57+
let key_arr = new_selector.split(":").collect::<Vec<&str>>();
58+
if key_arr.len() == 2 {
59+
new_selector = key_arr[0].to_string();
60+
}
5861
}
59-
6062
let nesting_selector = utils::split_selector(&new_selector);
6163
let mut lit_props = vec![
6264
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {

0 commit comments

Comments
 (0)