From c92b2554ae47a344f335c8c557dd87791d854de8 Mon Sep 17 00:00:00 2001 From: Denis Kolodin Date: Mon, 18 Feb 2019 16:07:48 +0300 Subject: [PATCH] Allow to use value attribute for all tags It was allowed for `option` before. --- CHANGELOG.md | 4 ++++ src/macros.rs | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d84192ad..1d9a00663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ ### Bug fixes +- It was impossible to set `value` attribute for any tag instead of `option`, because it used + inner value of `VTag` to keep the value for `input` element. Now `value` attribute works + for `options`, `progress` tags, etc. + ## 0.5 - Released 2019-02-01 ### Breaking changes diff --git a/src/macros.rs b/src/macros.rs index d0e6ba0d5..b67ec7358 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -311,13 +311,15 @@ pub fn unpack(mut stack: Stack) -> VNode { stack.pop().expect("no html elements in the stack") } +/// This method uses `value` attribute of macro to set a value of `input` element +/// or set that attribute as is for other elements like: `option`, `progress`, etc. #[doc(hidden)] pub fn set_value_or_attribute(stack: &mut Stack, value: T) { if let Some(&mut VNode::VTag(ref mut vtag)) = stack.last_mut() { - if vtag.tag().eq_ignore_ascii_case("option") { - vtag.add_attribute("value", &value) - } else { + if vtag.tag().eq_ignore_ascii_case("input") { vtag.set_value(&value) + } else { + vtag.add_attribute("value", &value) } } else { panic!("no tag to set value: {}", value.to_string());