mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-10 03:26:10 +00:00
LibWeb: Add null check in Document::ancestor_navigables()
The spec doesn't explicitly forbid calling this when the document doesn't have a node navigable, so let's handle that situation gracefully by just returning an empty list of ancestors. I hit this VERIFY somewhere on the web, but I don't know how to reproduce it.
This commit is contained in:
parent
bbd82265e1
commit
b118c99c27
Notes:
sideshowbarker
2024-07-17 00:47:29 +09:00
Author: https://github.com/awesomekling
Commit: b118c99c27
1 changed files with 6 additions and 2 deletions
|
@ -3063,9 +3063,13 @@ Vector<JS::Handle<HTML::Navigable>> Document::inclusive_descendant_navigables()
|
||||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#ancestor-navigables
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#ancestor-navigables
|
||||||
Vector<JS::Handle<HTML::Navigable>> Document::ancestor_navigables()
|
Vector<JS::Handle<HTML::Navigable>> Document::ancestor_navigables()
|
||||||
{
|
{
|
||||||
|
// NOTE: This isn't in the spec, but if we don't have a navigable, we can't have ancestors either.
|
||||||
|
auto document_node_navigable = this->navigable();
|
||||||
|
if (!document_node_navigable)
|
||||||
|
return {};
|
||||||
|
|
||||||
// 1. Let navigable be document's node navigable's parent.
|
// 1. Let navigable be document's node navigable's parent.
|
||||||
VERIFY(navigable());
|
auto navigable = document_node_navigable->parent();
|
||||||
auto navigable = this->navigable()->parent();
|
|
||||||
|
|
||||||
// 2. Let ancestors be an empty list.
|
// 2. Let ancestors be an empty list.
|
||||||
Vector<JS::Handle<HTML::Navigable>> ancestors;
|
Vector<JS::Handle<HTML::Navigable>> ancestors;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue