From 1040db97cbeb9e97627f5bb7630145ef9d935c23 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Tue, 18 Apr 2017 13:30:25 -0400 Subject: [PATCH] implement bind:duration and bind:paused --- .../dom/visitors/Element/Binding.js | 73 ++++++++++--------- src/validate/html/validateElement.js | 2 +- .../_config.js | 24 ++++++ .../main.html | 1 + .../binding-audio-currenttime/_config.js | 16 ---- .../binding-audio-currenttime/main.html | 1 - 6 files changed, 66 insertions(+), 51 deletions(-) create mode 100644 test/runtime/samples/binding-audio-currenttime-duration/_config.js create mode 100644 test/runtime/samples/binding-audio-currenttime-duration/main.html delete mode 100644 test/runtime/samples/binding-audio-currenttime/_config.js delete mode 100644 test/runtime/samples/binding-audio-currenttime/main.html diff --git a/src/generators/dom/visitors/Element/Binding.js b/src/generators/dom/visitors/Element/Binding.js index 2cc461bcd5..0850731907 100644 --- a/src/generators/dom/visitors/Element/Binding.js +++ b/src/generators/dom/visitors/Element/Binding.js @@ -13,16 +13,17 @@ export default function visitBinding ( generator, block, state, node, attribute if ( !~state.allUsedContexts.indexOf( context ) ) state.allUsedContexts.push( context ); }); - const handler = block.getUniqueName( `${state.parentNode}_change_handler` ); - + const eventName = getBindingEventName( node, attribute ); + const handler = block.getUniqueName( `${state.parentNode}_${eventName}_handler` ); const isMultipleSelect = node.name === 'select' && node.attributes.find( attr => attr.name.toLowerCase() === 'multiple' ); // TODO use getStaticAttributeValue const type = getStaticAttributeValue( node, 'type' ); const bindingGroup = attribute.name === 'group' ? getBindingGroup( generator, keypath ) : null; const value = getBindingValue( generator, block, state, node, attribute, isMultipleSelect, bindingGroup, type ); - const eventName = getBindingEventName( node, attribute ); let setter = getSetter({ block, name, keypath, context: '_svelte', attribute, dependencies, value }); - let updateElement; + let updateElement = `${state.parentNode}.${attribute.name} = ${snippet};`; + const lock = block.getUniqueName( `${state.parentNode}_${attribute.name}_updating` ); + let updateCondition = `!${lock}`; //