diff --git a/.changeset/tiny-wasps-matter.md b/.changeset/tiny-wasps-matter.md new file mode 100644 index 00000000..57b4e9d4 --- /dev/null +++ b/.changeset/tiny-wasps-matter.md @@ -0,0 +1,5 @@ +--- +"@devup-ui/wasm": patch +--- + +Fix attribute selector issue diff --git a/libs/css/src/lib.rs b/libs/css/src/lib.rs index 4458d6e3..23f730b7 100644 --- a/libs/css/src/lib.rs +++ b/libs/css/src/lib.rs @@ -174,7 +174,7 @@ static DOUBLE_SEPARATOR: Lazy> = Lazy::new(|| { }); pub fn get_selector_separator(key: &str) -> SelectorSeparator { - if key.starts_with(":") || key.is_empty() { + if key.starts_with(":") || key.is_empty() || key.starts_with("[") { SelectorSeparator::None } else if DOUBLE_SEPARATOR.contains(key) { SelectorSeparator::Double diff --git a/libs/sheet/src/lib.rs b/libs/sheet/src/lib.rs index 40bad018..165061a7 100644 --- a/libs/sheet/src/lib.rs +++ b/libs/sheet/src/lib.rs @@ -437,6 +437,17 @@ mod tests { false, ); assert_debug_snapshot!(sheet.create_css()); + + let mut sheet = StyleSheet::default(); + sheet.add_property( + "test", + "bg", + 0, + "red", + Some(&"&[disabled='true']".into()), + false, + ); + assert_debug_snapshot!(sheet.create_css()); } #[test] diff --git a/libs/sheet/src/snapshots/sheet__tests__create_css-11.snap b/libs/sheet/src/snapshots/sheet__tests__create_css-11.snap new file mode 100644 index 00000000..aaea27aa --- /dev/null +++ b/libs/sheet/src/snapshots/sheet__tests__create_css-11.snap @@ -0,0 +1,5 @@ +--- +source: libs/sheet/src/lib.rs +expression: sheet.create_css() +--- +".test[disabled='true']{background:red}"