Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent bindings interfering with each other on the same element #503

Merged
merged 1 commit into from
Apr 19, 2017

Conversation

Rich-Harris
Copy link
Member

Fixes a bug with audio bindings — when replaying an ended audio track, it should return to the start, but because each of currentTime, duration and paused had their own 'lock' variables, state was getting out of sync with the DOM. Fixed by sharing a lock variable between all bindings on the same element.

It does mean we have var audio_updating = false repeated once per binding. I think the solution to that would be to add a block.addVariable method that declares all (or most) variables in a single block at the top — this would also make the code marginally easier to read (in my opinion):

// before
var p = createElement( 'p' );
var text_value = root.foo;
var text = createText( text_value );
appendNode( text, p );
var text_1 = createText( "\n" );
var p_1 = createElement( 'p' );
var text_2_value = root.bar;
var text_2 = createText( text_2_value );
appendNode( text_2, p_1 );
var text_3 = createText( "\n" );
var p_2 = createElement( 'p' );
var text_4_value = root.baz;
var text_4 = createText( text_4_value );
appendNode( text_4, p_2 );
// after
var text_value, text_2_value, text_4_value;

var p = createElement( 'p' );
var text = createText( text_value = root.foo );
appendNode( text, p );
var text_1 = createText( "\n" );
var p_1 = createElement( 'p' );
var text_2 = createText( text_2_value = root.bar );
appendNode( text_2, p_1 );
var text_3 = createText( "\n" );
var p_2 = createElement( 'p' );
var text_4 = createText( text_4_value = root.baz );
appendNode( text_4, p_2 );

@Rich-Harris Rich-Harris mentioned this pull request Apr 19, 2017
@Rich-Harris Rich-Harris merged commit cf86d8c into master Apr 19, 2017
@Rich-Harris Rich-Harris deleted the restart-audio branch April 19, 2017 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant