mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 15:43:20 +00:00
LibWeb: Replace is<T>()
with as_if<T>()
where possible
This commit is contained in:
parent
3d97251da3
commit
cb1a1a5cb5
Notes:
github-actions[bot]
2025-08-25 16:46:19 +00:00
Author: https://github.com/tcl3
Commit: cb1a1a5cb5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5985
Reviewed-by: https://github.com/gmta ✅
26 changed files with 92 additions and 109 deletions
|
@ -1049,14 +1049,15 @@ WebIDL::ExceptionOr<void> Element::set_inner_html(StringView value)
|
|||
auto fragment = TRY(as<Element>(*context).parse_fragment(value));
|
||||
|
||||
// 4. If context is a template element, then set context to the template element's template contents (a DocumentFragment).
|
||||
if (is<HTML::HTMLTemplateElement>(*context))
|
||||
context = as<HTML::HTMLTemplateElement>(*context).content();
|
||||
auto* template_element = as_if<HTML::HTMLTemplateElement>(*context);
|
||||
if (template_element)
|
||||
context = template_element->content();
|
||||
|
||||
// 5. Replace all with fragment within context.
|
||||
context->replace_all(fragment);
|
||||
|
||||
// NOTE: We don't invalidate style & layout for <template> elements since they don't affect rendering.
|
||||
if (!is<HTML::HTMLTemplateElement>(*context)) {
|
||||
if (!template_element) {
|
||||
context->set_needs_style_update(true);
|
||||
|
||||
if (context->is_connected()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue