HTMLLIElement.h 947 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/ARIA/Roles.h>
  8. #include <LibWeb/HTML/HTMLElement.h>
  9. namespace Web::HTML {
  10. class HTMLLIElement final : public HTMLElement {
  11. WEB_PLATFORM_OBJECT(HTMLLIElement, HTMLElement);
  12. JS_DECLARE_ALLOCATOR(HTMLLIElement);
  13. public:
  14. virtual ~HTMLLIElement() override;
  15. // https://www.w3.org/TR/html-aria/#el-li
  16. virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::listitem; }
  17. i32 value() { return get_attribute(AttributeNames::value).value_or("0"_string).to_number<i32>().value_or(0); }
  18. void set_value(i32 value)
  19. {
  20. set_attribute(AttributeNames::value, MUST(String::number(value))).release_value_but_fixme_should_propagate_errors();
  21. }
  22. private:
  23. HTMLLIElement(DOM::Document&, DOM::QualifiedName);
  24. virtual void initialize(JS::Realm&) override;
  25. };
  26. }