mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibWeb: Add LocationObject::url()
https://html.spec.whatwg.org/multipage/history.html#concept-location-url > A Location object has an associated url, which is this Location > object's relevant Document's URL, if this Location object's relevant > Document is non-null, and about:blank otherwise.
This commit is contained in:
parent
da8525279e
commit
7fb9f431ea
2 changed files with 11 additions and 0 deletions
|
@ -56,6 +56,15 @@ DOM::Document const* LocationObject::relevant_document() const
|
|||
return browsing_context ? browsing_context->active_document() : nullptr;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#concept-location-url
|
||||
AK::URL LocationObject::url() const
|
||||
{
|
||||
// A Location object has an associated url, which is this Location object's relevant Document's URL,
|
||||
// if this Location object's relevant Document is non-null, and about:blank otherwise.
|
||||
auto const* relevant_document = this->relevant_document();
|
||||
return relevant_document ? relevant_document->url() : "about:blank"sv;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#dom-location-href
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_getter)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue