From f0f5b5aac06420b413601b424c3dccce21188af7 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Tue, 1 Oct 2019 23:45:15 +0200 Subject: [PATCH] Add test for video bindings --- test/js/samples/video-bindings/expected.js | 77 +++++++++++++++++++++ test/js/samples/video-bindings/input.svelte | 5 ++ 2 files changed, 82 insertions(+) create mode 100644 test/js/samples/video-bindings/expected.js create mode 100644 test/js/samples/video-bindings/input.svelte diff --git a/test/js/samples/video-bindings/expected.js b/test/js/samples/video-bindings/expected.js new file mode 100644 index 0000000000..768b5c03a0 --- /dev/null +++ b/test/js/samples/video-bindings/expected.js @@ -0,0 +1,77 @@ +/* generated by Svelte vX.Y.Z */ +import { + SvelteComponent, + detach, + element, + init, + insert, + listen, + noop, + raf, + safe_not_equal +} from "svelte/internal"; + +function create_fragment(ctx) { + let video; + let video_updating = false; + let video_animationframe; + let dispose; + + function video_timeupdate_handler() { + cancelAnimationFrame(video_animationframe); + + if (!video.paused) { + video_animationframe = raf(video_timeupdate_handler); + video_updating = true; + } + + ctx.video_timeupdate_handler.call(video); + } + + return { + c() { + video = element("video"); + dispose = listen(video, "timeupdate", video_timeupdate_handler); + }, + m(target, anchor) { + insert(target, video, anchor); + }, + p(changed, ctx) { + if (!video_updating && changed.currentTime && !isNaN(ctx.currentTime)) { + video.currentTime = ctx.currentTime; + } + + video_updating = false; + }, + i: noop, + o: noop, + d(detaching) { + if (detaching) detach(video); + dispose(); + } + }; +} + +function instance($$self, $$props, $$invalidate) { + let { currentTime } = $$props; + + function video_timeupdate_handler() { + currentTime = this.currentTime; + $$invalidate("currentTime", currentTime); + } + + $$self.$set = $$props => { + if ("currentTime" in $$props) $$invalidate("currentTime", currentTime = $$props.currentTime); + }; + + return { currentTime, video_timeupdate_handler }; +} + +class Component extends SvelteComponent { + constructor(options) { + super(); + init(this, options, instance, create_fragment, safe_not_equal, { currentTime: 0 }); + } +} + +export default Component; \ No newline at end of file diff --git a/test/js/samples/video-bindings/input.svelte b/test/js/samples/video-bindings/input.svelte new file mode 100644 index 0000000000..977cc1325b --- /dev/null +++ b/test/js/samples/video-bindings/input.svelte @@ -0,0 +1,5 @@ + + +