1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

LibWeb: Implement Element.hasAttributeNS

Particularly needed by xkcd's Right Click comic. https://xkcd.com/1975/
This commit is contained in:
Luke Wilde 2023-08-09 21:31:35 +01:00 committed by Tim Flynn
parent 3a98c48f20
commit 5694981352
3 changed files with 13 additions and 0 deletions

View file

@ -234,6 +234,17 @@ bool Element::has_attribute(DeprecatedFlyString const& name) const
return m_attributes->get_attribute(name) != nullptr;
}
// https://dom.spec.whatwg.org/#dom-element-hasattributens
bool Element::has_attribute_ns(DeprecatedFlyString namespace_, DeprecatedFlyString const& name) const
{
// 1. If namespace is the empty string, then set it to null.
if (namespace_.is_empty())
namespace_ = {};
// 2. Return true if this has an attribute whose namespace is namespace and local name is localName; otherwise false.
return m_attributes->get_attribute_ns(namespace_, name) != nullptr;
}
// https://dom.spec.whatwg.org/#dom-element-toggleattribute
WebIDL::ExceptionOr<bool> Element::toggle_attribute(DeprecatedFlyString const& name, Optional<bool> force)
{