mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
LibWeb: Make factory method of DOM::NamedNodeMap fallible
This commit is contained in:
parent
ce18dfc417
commit
e3e281addd
3 changed files with 7 additions and 4 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include <AK/Debug.h>
|
#include <AK/Debug.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <LibWeb/Bindings/ElementPrototype.h>
|
#include <LibWeb/Bindings/ElementPrototype.h>
|
||||||
|
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/CSS/PropertyID.h>
|
#include <LibWeb/CSS/PropertyID.h>
|
||||||
#include <LibWeb/CSS/ResolvedCSSStyleDeclaration.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));
|
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::ElementPrototype>(realm, "Element"));
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::DOM {
|
||||||
|
|
||||||
JS::NonnullGCPtr<NamedNodeMap> NamedNodeMap::create(Element& element)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<NamedNodeMap>> NamedNodeMap::create(Element& element)
|
||||||
{
|
{
|
||||||
auto& realm = element.realm();
|
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)
|
NamedNodeMap::NamedNodeMap(Element& element)
|
||||||
|
|
|
@ -22,7 +22,7 @@ class NamedNodeMap : public Bindings::LegacyPlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(NamedNodeMap, Bindings::LegacyPlatformObject);
|
WEB_PLATFORM_OBJECT(NamedNodeMap, Bindings::LegacyPlatformObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static JS::NonnullGCPtr<NamedNodeMap> create(Element&);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<NamedNodeMap>> create(Element&);
|
||||||
~NamedNodeMap() = default;
|
~NamedNodeMap() = default;
|
||||||
|
|
||||||
virtual bool is_supported_property_index(u32 index) const override;
|
virtual bool is_supported_property_index(u32 index) const override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue