mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 14:28:49 +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:
parent
9585aeafda
commit
b0e061b943
Notes:
github-actions[bot]
2024-12-28 10:51:36 +00:00
Author: https://github.com/khaledev
Commit: b0e061b943
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3042
Reviewed-by: https://github.com/shannonbooth ✅
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 43 additions and 1 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue