mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-03 17:58:49 +00:00
LibWeb: Return an Optional<String> from HTMLToken::attribute
Move away from using a nullable StringView.
This commit is contained in:
parent
72bb928dd8
commit
96fc1741b5
Notes:
sideshowbarker
2024-07-16 23:44:30 +09:00
Author: https://github.com/shannonbooth
Commit: 96fc1741b5
Pull-request: https://github.com/SerenityOS/serenity/pull/21880
2 changed files with 5 additions and 8 deletions
|
@ -665,10 +665,7 @@ JS::NonnullGCPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& t
|
||||||
auto const& local_name = token.tag_name();
|
auto const& local_name = token.tag_name();
|
||||||
|
|
||||||
// 5. Let is be the value of the "is" attribute in the given token, if such an attribute exists, or null otherwise.
|
// 5. Let is be the value of the "is" attribute in the given token, if such an attribute exists, or null otherwise.
|
||||||
auto is_value_deprecated_string = token.attribute(AttributeNames::is);
|
auto is_value = token.attribute(AttributeNames::is);
|
||||||
Optional<String> is_value;
|
|
||||||
if (!is_value_deprecated_string.is_null())
|
|
||||||
is_value = String::from_utf8(is_value_deprecated_string).release_value_but_fixme_should_propagate_errors();
|
|
||||||
|
|
||||||
// 6. Let definition be the result of looking up a custom element definition given document, given namespace, local name, and is.
|
// 6. Let definition be the result of looking up a custom element definition given document, given namespace, local name, and is.
|
||||||
auto definition = document->lookup_custom_element_definition(namespace_, local_name, is_value);
|
auto definition = document->lookup_custom_element_definition(namespace_, local_name, is_value);
|
||||||
|
@ -2286,7 +2283,7 @@ void HTMLParser::handle_in_body(HTMLToken& token)
|
||||||
|
|
||||||
// If the token does not have an attribute with the name "type", or if it does, but that attribute's value is not an ASCII case-insensitive match for the string "hidden", then: set the frameset-ok flag to "not ok".
|
// If the token does not have an attribute with the name "type", or if it does, but that attribute's value is not an ASCII case-insensitive match for the string "hidden", then: set the frameset-ok flag to "not ok".
|
||||||
auto type_attribute = token.attribute(HTML::AttributeNames::type);
|
auto type_attribute = token.attribute(HTML::AttributeNames::type);
|
||||||
if (type_attribute.is_null() || !type_attribute.equals_ignoring_ascii_case("hidden"sv)) {
|
if (!type_attribute.has_value() || !type_attribute->equals_ignoring_ascii_case("hidden"sv)) {
|
||||||
m_frameset_ok = false;
|
m_frameset_ok = false;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -3285,7 +3282,7 @@ void HTMLParser::handle_in_table(HTMLToken& token)
|
||||||
// or if it does, but that attribute's value is not an ASCII case-insensitive match for the string "hidden",
|
// or if it does, but that attribute's value is not an ASCII case-insensitive match for the string "hidden",
|
||||||
// then: act as described in the "anything else" entry below.
|
// then: act as described in the "anything else" entry below.
|
||||||
auto type_attribute = token.attribute(HTML::AttributeNames::type);
|
auto type_attribute = token.attribute(HTML::AttributeNames::type);
|
||||||
if (type_attribute.is_null() || !type_attribute.equals_ignoring_ascii_case("hidden"sv)) {
|
if (!type_attribute.has_value() || !type_attribute->equals_ignoring_ascii_case("hidden"sv)) {
|
||||||
goto AnythingElse;
|
goto AnythingElse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView attribute(FlyString const& attribute_name) const
|
Optional<String> attribute(FlyString const& attribute_name) const
|
||||||
{
|
{
|
||||||
if (auto result = raw_attribute(attribute_name); result.has_value())
|
if (auto result = raw_attribute(attribute_name); result.has_value())
|
||||||
return result->value;
|
return result->value;
|
||||||
|
@ -268,7 +268,7 @@ public:
|
||||||
|
|
||||||
bool has_attribute(FlyString const& attribute_name) const
|
bool has_attribute(FlyString const& attribute_name) const
|
||||||
{
|
{
|
||||||
return !attribute(attribute_name).is_null();
|
return attribute(attribute_name).has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void adjust_tag_name(FlyString const& old_name, FlyString const& new_name)
|
void adjust_tag_name(FlyString const& old_name, FlyString const& new_name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue