[librsvg: 6/8] Add unit test to make sure xml:lang isn't clobbered by the cascade




commit 2a8c69993e13e399778c87b4b436a854866ac1e1
Author: Michael Howell <michael notriddle com>
Date:   Thu Oct 14 19:31:26 2021 -0700

    Add unit test to make sure xml:lang isn't clobbered by the cascade
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/606>

 src/css.rs        | 32 ++++++++++++++++++++++++++++++++
 src/properties.rs |  1 +
 2 files changed, 33 insertions(+)
---
diff --git a/src/css.rs b/src/css.rs
index 6803b875..ba0c5800 100644
--- a/src/css.rs
+++ b/src/css.rs
@@ -884,6 +884,38 @@ mod tests {
 
     use crate::document::Document;
 
+    #[test]
+    fn xml_lang() {
+        let document = Document::load_from_bytes(
+            br#"<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"; xml:lang="zh">
+  <text id="a" x="10" y="10" width="30" height="30"></text>
+  <text id="b" x="10" y="20" width="30" height="30" xml:lang="en"></text>
+</svg>
+"#,
+        );
+        let a = document.lookup_internal_node("a").unwrap();
+        assert_eq!(
+            a.borrow_element()
+                .get_computed_values()
+                .xml_lang()
+                .0
+                .unwrap()
+                .as_str(),
+            "zh"
+        );
+        let b = document.lookup_internal_node("b").unwrap();
+        assert_eq!(
+            b.borrow_element()
+                .get_computed_values()
+                .xml_lang()
+                .0
+                .unwrap()
+                .as_str(),
+            "en"
+        );
+    }
+
     #[test]
     fn impl_element() {
         let document = Document::load_from_bytes(
diff --git a/src/properties.rs b/src/properties.rs
index d661fb0e..e6b514e6 100644
--- a/src/properties.rs
+++ b/src/properties.rs
@@ -729,6 +729,7 @@ impl SpecifiedValues {
         compute!(Visibility, visibility);
         compute!(WritingMode, writing_mode);
         compute!(XmlSpace, xml_space);
+        compute!(XmlLang, xml_lang);
 
         computed.transform = self.transform.unwrap_or_else(|| {
             match self.get_property(PropertyId::TransformProperty) {


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