1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:07:34 +00:00

LibWeb: Remove DOM element deprecated_get_attribute()

This commit is contained in:
Bastiaan van der Plaat 2024-01-16 19:04:45 +01:00 committed by Andrew Kaster
parent c477f90df7
commit a681429dff
40 changed files with 114 additions and 122 deletions

View file

@ -68,8 +68,7 @@ DOMTokenList::DOMTokenList(Element& associated_element, FlyString associated_att
{
m_legacy_platform_object_flags = LegacyPlatformObjectFlags { .supports_indexed_properties = 1 };
auto value = associated_element.deprecated_get_attribute(m_associated_attribute);
associated_attribute_changed(value);
associated_attribute_changed(associated_element.get_attribute_value(m_associated_attribute));
}
void DOMTokenList::initialize(JS::Realm& realm)

View file

@ -134,15 +134,6 @@ Optional<String> Element::get_attribute_ns(Optional<FlyString> const& namespace_
return attribute->value();
}
ByteString Element::deprecated_get_attribute(FlyString const& name) const
{
auto maybe_attribute = get_attribute(name);
if (!maybe_attribute.has_value())
return ByteString::empty();
return maybe_attribute->to_byte_string();
}
// https://dom.spec.whatwg.org/#concept-element-attributes-get-value
String Element::get_attribute_value(FlyString const& local_name, Optional<FlyString> const& namespace_) const
{
@ -1051,7 +1042,7 @@ i32 Element::default_tab_index_value() const
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
i32 Element::tab_index() const
{
auto maybe_table_index = Web::HTML::parse_integer(deprecated_attribute(HTML::AttributeNames::tabindex));
auto maybe_table_index = Web::HTML::parse_integer(get_attribute_value(HTML::AttributeNames::tabindex));
if (!maybe_table_index.has_value())
return default_tab_index_value();
@ -2038,10 +2029,10 @@ void Element::for_each_attribute(Function<void(Attr const&)> callback) const
callback(*m_attributes->item(i));
}
void Element::for_each_attribute(Function<void(FlyString const&, ByteString const&)> callback) const
void Element::for_each_attribute(Function<void(FlyString const&, String const&)> callback) const
{
for_each_attribute([&callback](Attr const& attr) {
callback(attr.name(), attr.value().to_byte_string());
callback(attr.name(), attr.value());
});
}

View file

@ -93,12 +93,10 @@ public:
bool has_attribute_ns(Optional<FlyString> const& namespace_, FlyString const& name) const;
bool has_attributes() const;
ByteString deprecated_attribute(FlyString const& name) const { return deprecated_get_attribute(name); }
Optional<String> attribute(FlyString const& name) const { return get_attribute(name); }
Optional<String> get_attribute(FlyString const& name) const;
Optional<String> get_attribute_ns(Optional<FlyString> const& namespace_, FlyString const& name) const;
ByteString deprecated_get_attribute(FlyString const& name) const;
String get_attribute_value(FlyString const& local_name, Optional<FlyString> const& namespace_ = {}) const;
WebIDL::ExceptionOr<void> set_attribute(FlyString const& name, String const& value);
@ -135,7 +133,7 @@ public:
void for_each_attribute(Function<void(Attr const&)>) const;
void for_each_attribute(Function<void(FlyString const&, ByteString const&)>) const;
void for_each_attribute(Function<void(FlyString const&, String const&)>) const;
bool has_class(FlyString const&, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
Vector<FlyString> const& class_names() const { return m_classes; }

View file

@ -825,7 +825,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
element.for_each_attribute([&](auto& name, auto& value) {
// 1. Let copyAttribute be a clone of attribute.
// 2. Append copyAttribute to copy.
MUST(element_copy->set_attribute(name, MUST(String::from_byte_string(value))));
MUST(element_copy->set_attribute(name, value));
});
copy = move(element_copy);
@ -1396,7 +1396,7 @@ bool Node::is_equal_node(Node const* other_node) const
// If A is an element, each attribute in its attribute list has an attribute that equals an attribute in Bs attribute list.
bool has_same_attributes = true;
this_element.for_each_attribute([&](auto& name, auto& value) {
if (other_element.deprecated_get_attribute(name) != value)
if (other_element.get_attribute(name) != value)
has_same_attributes = false;
});
if (!has_same_attributes)