mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Allow to use value attribute for all tags
It was allowed for `option` before.
This commit is contained in:
parent
cc2f5b7bf0
commit
c92b2554ae
@ -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
|
||||
|
||||
@ -311,13 +311,15 @@ pub fn unpack<COMP: Component>(mut stack: Stack<COMP>) -> VNode<COMP> {
|
||||
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<COMP: Component, T: ToString>(stack: &mut Stack<COMP>, 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());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user