From 5e325d5a8718d3b00fc5682863ebd5e7e77ffa5f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 3 Sep 2017 12:45:45 -0400 Subject: [PATCH] remove redundant input blowback guard - closes #645 --- .../dom/visitors/Element/Binding.ts | 34 ++- .../expected-bundle.js | 237 ++++++++++++++++++ .../input-without-blowback-guard/expected.js | 66 +++++ .../input-without-blowback-guard/input.html | 1 + 4 files changed, 325 insertions(+), 13 deletions(-) create mode 100644 test/js/samples/input-without-blowback-guard/expected-bundle.js create mode 100644 test/js/samples/input-without-blowback-guard/expected.js create mode 100644 test/js/samples/input-without-blowback-guard/input.html diff --git a/src/generators/dom/visitors/Element/Binding.ts b/src/generators/dom/visitors/Element/Binding.ts index 7f28184e802b..8878af17d09c 100644 --- a/src/generators/dom/visitors/Element/Binding.ts +++ b/src/generators/dom/visitors/Element/Binding.ts @@ -51,10 +51,13 @@ export default function visitBinding( let setter = getSetter(block, name, snippet, state.parentNode, attribute, dependencies, value); let updateElement = `${state.parentNode}.${attribute.name} = ${snippet};`; + + const needsLock = node.name !== 'input' || !/radio|checkbox|range|color/.test(type); // TODO others? const lock = `#${state.parentNode}_updating`; - let updateCondition = `!${lock}`; + let updateConditions = needsLock ? [`!${lock}`] : []; + let readOnly = false; - block.addVariable(lock, 'false'); + if (needsLock) block.addVariable(lock, 'false'); // \ No newline at end of file