HTMLOptionElement.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibWeb/HTML/HTMLElement.h>
  9. namespace Web::HTML {
  10. class HTMLOptionElement final : public HTMLElement {
  11. WEB_PLATFORM_OBJECT(HTMLOptionElement, HTMLElement);
  12. public:
  13. virtual ~HTMLOptionElement() override;
  14. bool selected() const { return m_selected; }
  15. void set_selected(bool);
  16. DeprecatedString value() const;
  17. void set_value(DeprecatedString);
  18. DeprecatedString text() const;
  19. void set_text(DeprecatedString);
  20. int index() const;
  21. bool disabled() const;
  22. virtual Optional<ARIA::Role> default_role() const override;
  23. private:
  24. friend class Bindings::OptionConstructor;
  25. friend class HTMLSelectElement;
  26. HTMLOptionElement(DOM::Document&, DOM::QualifiedName);
  27. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  28. void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
  29. void did_remove_attribute(DeprecatedFlyString const& name) override;
  30. void ask_for_a_reset();
  31. // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness
  32. bool m_selected { false };
  33. // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-dirtiness
  34. bool m_dirty { false };
  35. };
  36. }