mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 00:55:06 +00:00
LibWeb: Update Location::replace()
to use navigables
This commit is contained in:
parent
acff244335
commit
d45f2a4952
4 changed files with 15 additions and 16 deletions
|
@ -372,11 +372,21 @@ void Location::reload() const
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#dom-location-replace
|
||||
void Location::replace(String const& url) const
|
||||
WebIDL::ExceptionOr<void> Location::replace(String const& url)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
|
||||
// FIXME: This needs spec compliance work.
|
||||
window.did_call_location_replace({}, url.to_deprecated_string());
|
||||
// 1. If this's relevant Document is null, then return.
|
||||
if (!relevant_document())
|
||||
return {};
|
||||
|
||||
// 2. Parse url relative to the entry settings object. If that failed, throw a "SyntaxError" DOMException.
|
||||
auto replace_url = entry_settings_object().parse_url(url);
|
||||
if (!replace_url.is_valid())
|
||||
return WebIDL::SyntaxError::create(realm(), MUST(String::formatted("Invalid URL '{}'", url)));
|
||||
|
||||
// 3. Location-object navigate this to the resulting URL record given "replace".
|
||||
TRY(navigate(replace_url, HistoryHandlingBehavior::Replace));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location-assign
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue