From f9b7d3622fc201b931df362c47ea6e08db771f68 Mon Sep 17 00:00:00 2001 From: pushkine Date: Sat, 18 Apr 2020 21:07:51 +0200 Subject: [PATCH] check value instead of risking stale state --- .../render_dom/wrappers/Element/Binding.ts | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/compiler/compile/render_dom/wrappers/Element/Binding.ts b/src/compiler/compile/render_dom/wrappers/Element/Binding.ts index eca6e9d325..7f42fffa8a 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/Binding.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/Binding.ts @@ -57,7 +57,7 @@ export default class BindingWrapper { this.is_readonly = this.node.is_readonly; - this.needs_lock = this.node.name === 'currentTime' || (parent.node.name === 'input' && parent.node.get_static_attribute_value('type') === 'number'); // TODO others? + this.needs_lock = this.node.name === 'currentTime' // TODO others? } get_dependencies() { @@ -93,11 +93,23 @@ export default class BindingWrapper { update_conditions.push(block.renderer.dirty(dependency_array)); } - if (parent.node.name === 'input') { - const type = parent.node.get_static_attribute_value('type'); - - if (type === null || type === "" || type === "text" || type === "email" || type === "password") { - update_conditions.push(x`${parent.var}.${this.node.name} !== ${this.snippet}`); + if (parent.node.name === "input") { + const type = parent.node.get_static_attribute_value("type"); + + if ( + type === null || + type === "" || + type === "text" || + type === "email" || + type === "password" + ) { + update_conditions.push( + x`${parent.var}.${this.node.name} !== ${this.snippet}` + ); + } else if (type === "number") { + update_conditions.push( + x`@to_number(${parent.var}.${this.node.name}) !== ${this.snippet}` + ); } }