From c937fe25a35aa7a6505850116d2b8ee9254abd68 Mon Sep 17 00:00:00 2001 From: glennsl Date: Tue, 8 Jun 2021 23:14:03 +0200 Subject: [PATCH] fix(vdom): don't update value property if it hasn't changed --- CHANGELOG.md | 1 + src/browser/util.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3922a210b..8b2cf648f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Implemented `FromIterator<(impl Into>, impl Into>)>` for `Headers`. - Derived `Eq` and `PartialEq` for `Header`. - Added `Header::name()` and `Header::value()`. +- Fixed an issue in vdom where inputs with invalid contents being cleared on Firefox ## v0.8.0 diff --git a/src/browser/util.rs b/src/browser/util.rs index 78d506a26..ebe176951 100644 --- a/src/browser/util.rs +++ b/src/browser/util.rs @@ -213,6 +213,11 @@ fn set_html_input_element_value( input: &web_sys::HtmlInputElement, value: &str, ) -> Result<(), Cow<'static, str>> { + // Don't update if value hasn't changed + if value == input.value() { + return Ok(()); + } + // In some cases we need to set selection manually because // otherwise the cursor would jump at the end on some platforms.