HTMLOptionElement.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. String value() const;
  17. WebIDL::ExceptionOr<void> set_value(String const&);
  18. String text() const;
  19. void set_text(String const&);
  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 void initialize(JS::Realm&) override;
  28. void attribute_changed(DeprecatedFlyString const& name, DeprecatedString const& value) override;
  29. void ask_for_a_reset();
  30. // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness
  31. bool m_selected { false };
  32. // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-dirtiness
  33. bool m_dirty { false };
  34. };
  35. }