Closed foolip closed 4 years ago
When removing an element from its parents, the callbacks stop, as expected. However, they are stopping because we automatically pause the video, and not because we prevent callbacks from being fired if we aren't part of the DOM. Playing the video after removing it from the DOM causes callbacks to fire again.
Also, setting display:none
(as opposed to calling video.parentNode.removeChild(video)
) doesn't pause the video, and callbacks are still fired (but at the background render rate of 250ms).
Here's a quick test page
Sounds like the behavior is well-worth testing! Does the spec say enough about what should happen here such that tests in WPT could be added to cover this?
Since the comment I mentioned, there have been some relevant implementation updates: Chromium now fires callbacks for out-of-DOM elements at the same rate as elements on the page (as opposed to the 250ms background render rate). There was also for a while the question of having the callback and identifiers be tied to the DOM, but that issue brought up more technical difficulties than benefits (#25).
I think that now that there is no difference between in and out of DOM elements, and that the callbacks+ids are truly per-video, a simple test might be "removing the element from the DOM and making sure callbacks still fire". I don't know if there things worth calling out in the spec however. Maybe that "out-of-DOM elements should still fire their callbacks when played"?
A simple test like that sounds good if there's nothing in the spec or anything it depends on that treats detached elements any differently. The spec also need not say anything about it, unless there's some place in it where one would naturally ask the question.
The tests have been added. Thanks!
The behavior per the spec is pretty clear (no more callbacks) but this is worth testing, as you might accidentally get some other behavior if you don't think of it.