Skip to content

Commit

Permalink
Merge yewstack#253
Browse files Browse the repository at this point in the history
253: Option value r=DenisKolodin a=DenisKolodin

Re-creation of yewstack#252 

Co-authored-by: Limira <[email protected]>
  • Loading branch information
bors[bot] and limira committed May 24, 2018
2 parents 3b9c8b8 + 1645f07 commit f392d7e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ macro_rules! html_impl {
};
// PATTERN: value="",
(@vtag $stack:ident (value = $value:expr, $($tail:tt)*)) => {
$crate::macros::set_value(&mut $stack, $value);
$crate::macros::set_value_or_attribute(&mut $stack, $value);
html_impl! { @vtag $stack ($($tail)*) }
};
// PATTERN: attribute=value, - workaround for `type` attribute
Expand Down Expand Up @@ -194,9 +194,13 @@ pub fn unpack<CTX, COMP: Component<CTX>>(mut stack: Stack<CTX, COMP>) -> VNode<C
}

#[doc(hidden)]
pub fn set_value<CTX, COMP: Component<CTX>, T: ToString>(stack: &mut Stack<CTX, COMP>, value: T) {
pub fn set_value_or_attribute<CTX, COMP: Component<CTX>, T: ToString>(stack: &mut Stack<CTX, COMP>, value: T) {
if let Some(&mut VNode::VTag(ref mut vtag)) = stack.last_mut() {
vtag.set_value(&value);
if vtag.tag().eq_ignore_ascii_case("option") {
vtag.add_attribute("value", &value)
} else {
vtag.set_value(&value)
}
} else {
panic!("no tag to set value: {}", value.to_string());
}
Expand Down Expand Up @@ -279,7 +283,7 @@ pub fn child_to_parent<CTX, COMP: Component<CTX>>(
// TODO Check it during compilation. Possible?
if let (&mut VNode::VTag(ref mut vtag), Some(endtag)) = (&mut node, endtag) {
let starttag = vtag.tag();
if starttag != endtag {
if !starttag.eq_ignore_ascii_case(endtag) {
panic!("wrong closing tag: <{}> -> </{}>", starttag, endtag);
}
}
Expand Down

0 comments on commit f392d7e

Please sign in to comment.