mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 23:25:20 +00:00
LibWeb: Implement Element.removeAttributeNode()
This commit is contained in:
@@ -342,4 +342,19 @@ WebIDL::ExceptionOr<JS::Value> NamedNodeMap::named_item_value(FlyString const& n
|
||||
return node;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-removeattributenode
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Attr>> NamedNodeMap::remove_attribute_node(JS::NonnullGCPtr<Attr> attr)
|
||||
{
|
||||
// 1. If this’s attribute list does not contain attr, then throw a "NotFoundError" DOMException.
|
||||
auto index = m_attributes.find_first_index(attr);
|
||||
if (!index.has_value())
|
||||
return WebIDL::NotFoundError::create(realm(), "Attribute not found"_fly_string);
|
||||
|
||||
// 2. Remove attr.
|
||||
remove_attribute_at_index(index.value());
|
||||
|
||||
// 3. Return attr.
|
||||
return attr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user