mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-24 02:09:28 +00:00
LibWeb/HTML: Fix URL fragment comparison triggering unwanted events
This update ensures consistent handling of URL fragments, treating null fragments as empty strings in `Location::set_hash` method. This fixes all tests in https://wpt.live/html/browsers/browsing-the-web/history-traversal/hash-empty-string.html
This commit is contained in:
committed by
Tim Ledbetter
parent
9585aeafda
commit
b0e061b943
@@ -413,7 +413,10 @@ WebIDL::ExceptionOr<void> Location::set_hash(String const& value)
|
||||
(void)URL::Parser::basic_parse(input, {}, ©_url, URL::Parser::State::Fragment);
|
||||
|
||||
// 7. If copyURL's fragment is this's url's fragment, then return.
|
||||
if (copy_url.fragment() == this->url().fragment())
|
||||
// NOTE: Ignore null values when comparing fragments. This behavior is not explicitly mentioned in the specs, potential bug?
|
||||
auto copy_url_fragment = copy_url.fragment().has_value() ? copy_url.fragment() : String {};
|
||||
auto this_url_fragment = this->url().fragment().has_value() ? this->url().fragment() : String {};
|
||||
if (copy_url_fragment == this_url_fragment)
|
||||
return {};
|
||||
|
||||
// 8. Location-object navigate this to copyURL.
|
||||
|
||||
Reference in New Issue
Block a user