Skip to content

Commit

Permalink
Fix mistake in XML component system
Browse files Browse the repository at this point in the history
Use argument value instead of argument type, previously the
component system would instantiate

<component name="Foo" args="blah: String">
    <p>{blah}</p>
</component>

<Foo blah="Test"/>

with "<p>String</p>" instead of: "<p>Test</p>".
  • Loading branch information
fschutt committed Jun 14, 2019
1 parent ff06433 commit 8b7de76
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 53 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azul/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ fn validate_and_filter_component_args(xml_attributes: &XmlAttributeMap, valid_ar
for (xml_attribute_name, xml_attribute_value) in xml_attributes.iter() {

let arg_value = match valid_args.get(xml_attribute_name) {
Some(s) => Some(s),
Some(valid_arg_type) => Some(xml_attribute_value),
None => {
if DEFAULT_ARGS.contains(&xml_attribute_name.as_str()) {
None // no error, but don't insert the attribute name
Expand Down
19 changes: 13 additions & 6 deletions examples/xml/ui.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<app>
<div id="wrapper">
<div id="overflowing_1"></div>
<div id="overflowing_2">
<div id="overflowing_3"></div>
<component name="MenuBarLabel" args="menu_name: String">
<div class="menubar_label_container">
<p class="menubar_label">{menu_name}</p>
</div>
</component>

<component name="MenuBar">
<div class="menubar_container">
<MenuBarLabel menu_name="Test"/>
</div>
</div>
</component>

<app>
<MenuBar />
</app>
46 changes: 0 additions & 46 deletions examples/xml/xml.css
Original file line number Diff line number Diff line change
@@ -1,46 +0,0 @@
* {
border: 1px solid black;
box-sizing: border-box;
border-radius: 10px;
}

#wrapper {
top: 50px;
left: 50px;
width: 400px;
height: 400px;
background: green;
overflow: scroll;
}

#overflowing_1 {
position: absolute;
top: 200px;
left: 40px;
width: 40px;
height: 40px;
background: red;
}

#overflowing_2 {
position: absolute;
top: 290px;
left: 40px;
width: 40px;
height: 40px;
background: blue;
overflow: visible;
}

#overflowing_3 {
position: absolute;
width: 40px;
height: 40px;
top: 100px;
left: 100px;
background: yellow;
}

#overflowing_3:hover {
background-color: red;
}

0 comments on commit 8b7de76

Please sign in to comment.