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

Minor fixes to new media bindings #837

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/generators/dom/visitors/Element/Binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ function getBindingValue(
return `@toNumber(${state.parentNode}.${attribute.name})`;
}

if (isMediaElement && attribute.name === 'buffered' || attribute.name === 'seekable' || attribute.name === 'played') {
return `@timeRangesToArray(${state.parentNode}.${attribute.name})`
if (isMediaElement && (attribute.name === 'buffered' || attribute.name === 'seekable' || attribute.name === 'played')) {
return `${state.parentNode}.${attribute.name} ? @timeRangesToArray(${state.parentNode}.${attribute.name}) : []`
}

// everything else
Expand Down
6 changes: 3 additions & 3 deletions test/js/samples/media-bindings/expected-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,19 @@ function create_main_fragment(state, component) {

function audio_progress_loadedmetadata_handler() {
audio_updating = true;
component.set({ buffered: timeRangesToArray(audio.buffered) });
component.set({ buffered: audio.buffered ? timeRangesToArray(audio.buffered) : [] });
audio_updating = false;
}

function audio_loadedmetadata_handler() {
audio_updating = true;
component.set({ seekable: timeRangesToArray(audio.seekable) });
component.set({ seekable: audio.seekable ? timeRangesToArray(audio.seekable) : [] });
audio_updating = false;
}

function audio_timeupdate_handler() {
audio_updating = true;
component.set({ played: timeRangesToArray(audio.played) });
component.set({ played: audio.played ? timeRangesToArray(audio.played) : [] });
audio_updating = false;
}

Expand Down
8 changes: 4 additions & 4 deletions test/js/samples/media-bindings/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ function create_main_fragment(state, component) {

function audio_progress_loadedmetadata_handler() {
audio_updating = true;
component.set({ buffered: timeRangesToArray(audio.buffered) });
component.set({ buffered: audio.buffered ? timeRangesToArray(audio.buffered) : [] });
audio_updating = false;
}

function audio_loadedmetadata_handler() {
audio_updating = true;
component.set({ seekable: timeRangesToArray(audio.seekable) });
component.set({ seekable: audio.seekable ? timeRangesToArray(audio.seekable) : [] });
audio_updating = false;
}

function audio_timeupdate_handler() {
audio_updating = true;
component.set({ played: timeRangesToArray(audio.played) });
component.set({ played: audio.played ? timeRangesToArray(audio.played) : [] });
audio_updating = false;
}

Expand Down Expand Up @@ -138,4 +138,4 @@ function SvelteComponent(options) {

assign(SvelteComponent.prototype, proto );

export default SvelteComponent;
export default SvelteComponent;