1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:08:12 +00:00

LibWeb: Add icon as possible resource type on the link tag

This commit is contained in:
Anthony Van de Gejuchte 2022-04-03 19:39:38 +02:00 committed by Andreas Kling
parent 44d78a8a13
commit 13847aa7e8
2 changed files with 10 additions and 1 deletions

View file

@ -55,9 +55,15 @@ void HTMLLinkElement::inserted()
void HTMLLinkElement::parse_attribute(FlyString const& name, String const& value)
{
// 4.6.7 Link types - https://html.spec.whatwg.org/multipage/links.html#linkTypes
if (name == HTML::AttributeNames::rel) {
m_relationship = 0;
auto parts = value.split_view(' ');
// Keywords are always ASCII case-insensitive, and must be compared as such.
auto lowercased_value = value.to_lowercase();
// To determine which link types apply to a link, a, area, or form element,
// the element's rel attribute must be split on ASCII whitespace.
// The resulting tokens are the keywords for the link types that apply to that element.
auto parts = lowercased_value.split_view(' ');
for (auto& part : parts) {
if (part == "stylesheet"sv)
m_relationship |= Relationship::Stylesheet;
@ -69,6 +75,8 @@ void HTMLLinkElement::parse_attribute(FlyString const& name, String const& value
m_relationship |= Relationship::DNSPrefetch;
else if (part == "preconnect"sv)
m_relationship |= Relationship::Preconnect;
else if (part == "icon"sv)
m_relationship |= Relationship::Icon;
}
}
}