Browse Source

LibWeb: Make factory method of HTML::HTMLOptionsCollection fallible

Kenneth Myhra 2 năm trước cách đây
mục cha
commit
2b391ea622

+ 2 - 2
Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp

@@ -13,9 +13,9 @@
 
 namespace Web::HTML {
 
-JS::NonnullGCPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLOptionsCollection>> HTMLOptionsCollection::create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)
 {
-    return root.heap().allocate<HTMLOptionsCollection>(root.realm(), root, move(filter)).release_allocated_value_but_fixme_should_propagate_errors();
+    return MUST_OR_THROW_OOM(root.heap().allocate<HTMLOptionsCollection>(root.realm(), root, move(filter)));
 }
 
 HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)

+ 1 - 1
Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h

@@ -19,7 +19,7 @@ class HTMLOptionsCollection final : public DOM::HTMLCollection {
     WEB_PLATFORM_OBJECT(HTMLOptionsCollection, DOM::HTMLCollection);
 
 public:
-    static JS::NonnullGCPtr<HTMLOptionsCollection> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
+    static WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLOptionsCollection>> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
     virtual ~HTMLOptionsCollection() override;
 
     WebIDL::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});

+ 1 - 1
Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp

@@ -44,7 +44,7 @@ JS::GCPtr<HTMLOptionsCollection> const& HTMLSelectElement::options()
             // the select element, and all the option element children of all the optgroup element children
             // of the select element, in tree order.
             return is<HTMLOptionElement>(element);
-        });
+        }).release_value_but_fixme_should_propagate_errors();
     }
     return m_options;
 }