Browse Source

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.
Jonatan Klemets 1 year ago
parent
commit
0adda642a6
1 changed files with 3 additions and 2 deletions
  1. 3 2
      Userland/Libraries/LibWeb/DOM/Element.cpp

+ 3 - 2
Userland/Libraries/LibWeb/DOM/Element.cpp

@@ -47,6 +47,7 @@
 #include <LibWeb/HTML/HTMLSelectElement.h>
 #include <LibWeb/HTML/HTMLSelectElement.h>
 #include <LibWeb/HTML/HTMLStyleElement.h>
 #include <LibWeb/HTML/HTMLStyleElement.h>
 #include <LibWeb/HTML/HTMLTextAreaElement.h>
 #include <LibWeb/HTML/HTMLTextAreaElement.h>
+#include <LibWeb/HTML/Numbers.h>
 #include <LibWeb/HTML/Parser/HTMLParser.h>
 #include <LibWeb/HTML/Parser/HTMLParser.h>
 #include <LibWeb/HTML/Window.h>
 #include <LibWeb/HTML/Window.h>
 #include <LibWeb/Infra/CharacterTypes.h>
 #include <LibWeb/Infra/CharacterTypes.h>
@@ -903,8 +904,8 @@ i32 Element::default_tab_index_value() const
 // https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
 // https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
 i32 Element::tab_index() const
 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<i32>();
+    auto maybe_table_index = Web::HTML::parse_integer(attribute(HTML::AttributeNames::tabindex));
+
     if (!maybe_table_index.has_value())
     if (!maybe_table_index.has_value())
         return default_tab_index_value();
         return default_tab_index_value();
     return maybe_table_index.value();
     return maybe_table_index.value();