From 0adda642a680567d76607ab2f57ac7e1ef4e55fa Mon Sep 17 00:00:00 2001 From: Jonatan Klemets Date: Wed, 30 Aug 2023 20:43:25 +0300 Subject: [PATCH] LibWeb: Fix int parsing in Element::tab_index We now have functions for parsing integers in a spec-compliant way. This patch replaces the `to_int` call with a call to the spec-compliant `Web::HTML::parse_integer` function. --- Userland/Libraries/LibWeb/DOM/Element.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index f7116d8e690..8e7865a04da 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -903,8 +904,8 @@ i32 Element::default_tab_index_value() const // https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex i32 Element::tab_index() const { - // FIXME: I'm not sure if "to_int" exactly matches the specs "rules for parsing integers" - auto maybe_table_index = attribute(HTML::AttributeNames::tabindex).to_int(); + auto maybe_table_index = Web::HTML::parse_integer(attribute(HTML::AttributeNames::tabindex)); + if (!maybe_table_index.has_value()) return default_tab_index_value(); return maybe_table_index.value();