From 244ea0fa9c21415e5230f8aad4b979bf9d0a66e0 Mon Sep 17 00:00:00 2001 From: Kyle Lanmon Date: Mon, 20 Mar 2023 23:02:08 -0500 Subject: [PATCH] Presenter: Don't give a style value if there are no styles --- Userland/Applications/Presenter/SlideObject.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Userland/Applications/Presenter/SlideObject.cpp b/Userland/Applications/Presenter/SlideObject.cpp index 25d12bf1b6..6576b5be88 100644 --- a/Userland/Applications/Presenter/SlideObject.cpp +++ b/Userland/Applications/Presenter/SlideObject.cpp @@ -145,12 +145,15 @@ ErrorOr HTMLElement::serialize(StringBuilder& builder) const // FIXME: Escape the value string as necessary. TRY(builder.try_appendff(" {}='{}'", key, value)); } - TRY(builder.try_append(" style=\""sv)); - for (auto const& [key, value] : style) { - // FIXME: Escape the value string as necessary. - TRY(builder.try_appendff(" {}: {};", key, value)); + if (!style.is_empty()) { + TRY(builder.try_append(" style=\""sv)); + for (auto const& [key, value] : style) { + // FIXME: Escape the value string as necessary. + TRY(builder.try_appendff(" {}: {};", key, value)); + } + TRY(builder.try_append("\""sv)); } - TRY(builder.try_append("\">"sv)); + TRY(builder.try_append(">"sv)); if (!inner_text.is_empty()) TRY(builder.try_append(inner_text)); for (auto const& child : children) {