mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +00:00
LibWeb: Make factory method of DOM::NamedNodeMap fallible
This commit is contained in:
parent
ce18dfc417
commit
e3e281addd
Notes:
sideshowbarker
2024-07-17 00:12:08 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/e3e281addd Pull-request: https://github.com/SerenityOS/serenity/pull/17491 Reviewed-by: https://github.com/linusg ✅
|
@ -8,6 +8,7 @@
|
|||
#include <AK/Debug.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibWeb/Bindings/ElementPrototype.h>
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/ResolvedCSSStyleDeclaration.h>
|
||||
|
@ -66,7 +67,9 @@ JS::ThrowCompletionOr<void> Element::initialize(JS::Realm& realm)
|
|||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::ElementPrototype>(realm, "Element"));
|
||||
|
||||
m_attributes = NamedNodeMap::create(*this);
|
||||
m_attributes = TRY(Bindings::throw_dom_exception_if_needed(realm.vm(), [&]() {
|
||||
return NamedNodeMap::create(*this);
|
||||
}));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
JS::NonnullGCPtr<NamedNodeMap> NamedNodeMap::create(Element& element)
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<NamedNodeMap>> NamedNodeMap::create(Element& element)
|
||||
{
|
||||
auto& realm = element.realm();
|
||||
return realm.heap().allocate<NamedNodeMap>(realm, element).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<NamedNodeMap>(realm, element));
|
||||
}
|
||||
|
||||
NamedNodeMap::NamedNodeMap(Element& element)
|
||||
|
|
|
@ -22,7 +22,7 @@ class NamedNodeMap : public Bindings::LegacyPlatformObject {
|
|||
WEB_PLATFORM_OBJECT(NamedNodeMap, Bindings::LegacyPlatformObject);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<NamedNodeMap> create(Element&);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<NamedNodeMap>> create(Element&);
|
||||
~NamedNodeMap() = default;
|
||||
|
||||
virtual bool is_supported_property_index(u32 index) const override;
|
||||
|
|
Loading…
Reference in a new issue