mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:17:35 +00:00
LibWeb: Reorganize window.parent so it looks a bit more like the spec
This commit is contained in:
parent
835ffbb365
commit
fc5e414596
3 changed files with 30 additions and 12 deletions
|
@ -396,22 +396,13 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::top_getter)
|
|||
return top_window.wrapper();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsers.html#dom-parent
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::parent_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
|
||||
auto* this_browsing_context = impl->associated_document().browsing_context();
|
||||
if (!this_browsing_context)
|
||||
auto* parent = impl->parent();
|
||||
if (!parent)
|
||||
return JS::js_null();
|
||||
|
||||
if (this_browsing_context->parent()) {
|
||||
VERIFY(this_browsing_context->parent()->active_document());
|
||||
auto& parent_window = this_browsing_context->parent()->active_document()->window();
|
||||
return parent_window.wrapper();
|
||||
}
|
||||
VERIFY(this_browsing_context == &this_browsing_context->top_level_browsing_context());
|
||||
return impl->wrapper();
|
||||
return parent->wrapper();
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::document_getter)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue