LibWeb: Bring HTMLHyperlinkElementUtils::hostname() closer to spec
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run

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:
Sam Atkins 2024-11-28 14:46:01 +00:00 committed by Andreas Kling
parent 3ce81512dd
commit bf724ba2f6
Notes: github-actions[bot] 2024-11-30 11:23:15 +00:00

View file

@ -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.