Przeglądaj źródła

LibWeb: Make factory method of DOM::MutationObserver fallible

Kenneth Myhra 2 lat temu
rodzic
commit
7852915dd3

+ 2 - 2
Userland/Libraries/LibWeb/DOM/MutationObserver.cpp

@@ -11,9 +11,9 @@
 
 namespace Web::DOM {
 
-JS::NonnullGCPtr<MutationObserver> MutationObserver::construct_impl(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackType> callback)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationObserver>> MutationObserver::construct_impl(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackType> callback)
 {
-    return realm.heap().allocate<MutationObserver>(realm, realm, callback).release_allocated_value_but_fixme_should_propagate_errors();
+    return MUST_OR_THROW_OOM(realm.heap().allocate<MutationObserver>(realm, realm, callback));
 }
 
 // https://dom.spec.whatwg.org/#dom-mutationobserver-mutationobserver

+ 1 - 1
Userland/Libraries/LibWeb/DOM/MutationObserver.h

@@ -32,7 +32,7 @@ class MutationObserver final : public Bindings::PlatformObject {
     WEB_PLATFORM_OBJECT(MutationObserver, Bindings::PlatformObject);
 
 public:
-    static JS::NonnullGCPtr<MutationObserver> construct_impl(JS::Realm&, JS::GCPtr<WebIDL::CallbackType>);
+    static WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationObserver>> construct_impl(JS::Realm&, JS::GCPtr<WebIDL::CallbackType>);
     virtual ~MutationObserver() override;
 
     WebIDL::ExceptionOr<void> observe(Node& target, MutationObserverInit options = {});