Description
Hi, trying to play around Svelte, I'm having an issue with the media elements bindings, specifically buffered
.
REPL repro: https://svelte.dev/repl/021f1c1d512e49248347bfe746f037ad?version=3.4.3
Basically my issue is that I'm trying to setup a reactive variable that depends on the buffered
property, but that fails on load, because buffered
is not yet instantiated? (maybe?)
Like this (variables initialized outside the block):
$: {
progressBarPercent = (currentTime / duration) * 100;
loadedPercent = buffered.end(buffered.length - 1) / duration;
}
On my machine I'm getting a: proxy.js:135 TypeError: Cannot read property 'end' of undefined
with this kind of output:
$$self.$$.update = ($$dirty = { currentTime: 1, duration: 1, buffered: 1 }) => {
if ($$dirty.currentTime || $$dirty.duration || $$dirty.buffered) { {
$$invalidate('progressBarPercent', progressBarPercent = (currentTime / duration) * 100);
$$invalidate('loadedPercent', loadedPercent = buffered.end / duration);
} }
};
I've been able to find a workaround that is simply wrapping the loadedPercent
assignment in an if block and then, the updating behavior seems correct.
Looking in the repo I've found this #832 but this TimeRanges
modification doesn't seem to happen in the current version, and if I were, an update to the docs would probably be nice.
Am I doing something wrong or it is a bug?