diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index db2e59b2f4..a1c5e935e7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -84,6 +84,25 @@ void HTMLMediaElement::did_remove_attribute(DeprecatedFlyString const& name) m_crossorigin = cors_setting_attribute_from_keyword({}); } +// https://html.spec.whatwg.org/multipage/media.html#playing-the-media-resource:media-element-83 +void HTMLMediaElement::removed_from(DOM::Node* node) +{ + Base::removed_from(node); + + // When a media element is removed from a Document, the user agent must run the following steps: + + // FIXME: 1. Await a stable state, allowing the task that removed the media element from the Document to continue. The + // synchronous section consists of all the remaining steps of this algorithm. (Steps in the synchronous section + // are marked with ⌛.) + + // 2. ⌛ If the media element is in a document, return. + if (in_a_document_tree()) + return; + + // 3. ⌛ Run the internal pause steps for the media element. + pause_element().release_value_but_fixme_should_propagate_errors(); +} + // https://html.spec.whatwg.org/multipage/media.html#fatal-decode-error WebIDL::ExceptionOr HTMLMediaElement::set_decoder_error(String error_message) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h index 4c262f6c68..74109250f5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h @@ -89,6 +89,7 @@ protected: virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; virtual void did_remove_attribute(DeprecatedFlyString const&) override; + virtual void removed_from(DOM::Node*) override; // Override in subclasses to handle implementation-specific behavior when the element state changes // to playing or paused, e.g. to start/stop play timers.