mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 14:28:49 +00:00
LibWeb: Bring HTMLHyperlinkElementUtils::hostname() closer to spec
Actually reinitialize the URL like we are supposed to, and then check if it's null. Also add some missing spec links.
This commit is contained in:
parent
3ce81512dd
commit
bf724ba2f6
Notes:
github-actions[bot]
2024-11-30 11:23:15 +00:00
Author: https://github.com/AtkinsSJ
Commit: bf724ba2f6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2610
Reviewed-by: https://github.com/shannonbooth ✅
1 changed files with 7 additions and 5 deletions
|
@ -198,22 +198,24 @@ void HTMLHyperlinkElementUtils::set_host(StringView host)
|
|||
update_href();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-hostname
|
||||
String HTMLHyperlinkElementUtils::hostname() const
|
||||
{
|
||||
// 1. Reinitialize url.
|
||||
//
|
||||
reinitialize_url();
|
||||
|
||||
// 2. Let url be this element's url.
|
||||
URL::URL url(href());
|
||||
auto url = m_url;
|
||||
|
||||
// 3. If url or url's host is null, return the empty string.
|
||||
// FIXME: How can url be null here?
|
||||
if (!url.host().has_value())
|
||||
if (!url.has_value() || !url->host().has_value())
|
||||
return String {};
|
||||
|
||||
// 4. Return url's host, serialized.
|
||||
return url.serialized_host();
|
||||
return url->serialized_host();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-hostname
|
||||
void HTMLHyperlinkElementUtils::set_hostname(StringView hostname)
|
||||
{
|
||||
// 1. Reinitialize url.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue