[librsvg: 3/4] Remove redundant check for an empty "style" attribute




commit 8c0182070bb999b6654e5977f360ef8c119f7642
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Feb 12 11:00:08 2021 -0600

    Remove redundant check for an empty "style" attribute

 src/element.rs    | 5 ++---
 src/properties.rs | 9 +++++++++
 2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/element.rs b/src/element.rs
index 61c77504..7f6569eb 100644
--- a/src/element.rs
+++ b/src/element.rs
@@ -264,10 +264,9 @@ impl<T: SetAttributes + Draw> ElementInner<T> {
             .attributes
             .iter()
             .find(|(attr, _)| attr.expanded() == expanded_name!("", "style"))
-            .map(|(_, value)| value)
-            .unwrap_or("");
+            .map(|(_, value)| value);
 
-        if !style.is_empty() {
+        if let Some(style) = style {
             if let Err(e) = self.specified_values.parse_style_declarations(
                 style,
                 Origin::Author,
diff --git a/src/properties.rs b/src/properties.rs
index 4009766c..aeb153d2 100644
--- a/src/properties.rs
+++ b/src/properties.rs
@@ -940,4 +940,13 @@ mod tests {
 
         assert_eq!(computed.opacity(), half_opacity.clone());
     }
+
+    #[test]
+    fn empty_style_attribute_parses_ok() {
+        let mut specified = SpecifiedValues::default();
+
+        assert!(specified
+            .parse_style_declarations("", Origin::Author, &mut HashSet::new())
+            .is_ok())
+    }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]