Skip to content

Commit

Permalink
LibWeb: Update DOMStringList to match PlatformObject changes
Browse files Browse the repository at this point in the history
- is_supported_property_index() no longer needs to be overridden
- item_value() now returns Optional
  • Loading branch information
AtkinsSJ committed Jul 29, 2024
1 parent 06484d0 commit 49e3b55
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
11 changes: 2 additions & 9 deletions Userland/Libraries/LibWeb/HTML/DOMStringList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,10 @@ bool DOMStringList::contains(StringView string)
return m_list.contains_slow(string);
}

bool DOMStringList::is_supported_property_index(u32 index) const
{
// The DOMStringList interface supports indexed properties. The supported property indices are the indices of this's
// associated list.
return index < m_list.size();
}

WebIDL::ExceptionOr<JS::Value> DOMStringList::item_value(size_t index) const
Optional<JS::Value> DOMStringList::item_value(size_t index) const
{
if (index + 1 > m_list.size())
return JS::js_undefined();
return {};

return JS::PrimitiveString::create(vm(), m_list.at(index));
}
Expand Down
3 changes: 1 addition & 2 deletions Userland/Libraries/LibWeb/HTML/DOMStringList.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class DOMStringList final : public Bindings::PlatformObject {
Optional<String> item(u32 index) const;
bool contains(StringView string);

virtual bool is_supported_property_index(u32) const override;
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
virtual Optional<JS::Value> item_value(size_t index) const override;

private:
explicit DOMStringList(JS::Realm&, Vector<String>);
Expand Down

0 comments on commit 49e3b55

Please sign in to comment.