mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Bring fragment parsing up to spec
Corresponds to https://github.com/whatwg/html/pull/10874 Also, parse_fragment() returns ExceptionOr, so stop voiding the error from append_child().
This commit is contained in:
parent
7d502df807
commit
89296b88a0
Notes:
github-actions[bot]
2025-01-07 15:06:58 +00:00
Author: https://github.com/AtkinsSJ
Commit: 89296b88a0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3168
Reviewed-by: https://github.com/gmta ✅
2 changed files with 30 additions and 29 deletions
|
@ -1545,18 +1545,17 @@ WebIDL::ExceptionOr<GC::Ref<DOM::DocumentFragment>> Element::parse_fragment(Stri
|
|||
dbgln("FIXME: Handle fragment parsing of XML documents");
|
||||
}
|
||||
|
||||
// 3. Let new children be the result of invoking algorithm given markup, with context set to context.
|
||||
// 3. Let newChildren be the result of invoking algorithm given context and markup.
|
||||
auto new_children = algorithm(*this, markup, HTML::HTMLParser::AllowDeclarativeShadowRoots::No);
|
||||
|
||||
// 4. Let fragment be a new DocumentFragment whose node document is context's node document.
|
||||
auto fragment = realm().create<DOM::DocumentFragment>(document());
|
||||
|
||||
// 5. Append each Node in new children to fragment (in tree order).
|
||||
for (auto& child : new_children) {
|
||||
// I don't know if this can throw here, but let's be safe.
|
||||
(void)TRY(fragment->append_child(*child));
|
||||
}
|
||||
// 5. For each node of newChildren, in tree order: append node to fragment.
|
||||
for (auto& child : new_children)
|
||||
TRY(fragment->append_child(*child));
|
||||
|
||||
// 6. Return fragment.
|
||||
return fragment;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue