Coverage Report

Created: 2026-07-25 07:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h
Line
Count
Source
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
8
#pragma once
9
10
#include <LibWeb/HTML/HTMLElement.h>
11
12
namespace Web::HTML {
13
14
class HTMLOptionElement final : public HTMLElement {
15
    WEB_PLATFORM_OBJECT(HTMLOptionElement, HTMLElement);
16
    JS_DECLARE_ALLOCATOR(HTMLOptionElement);
17
18
public:
19
    virtual ~HTMLOptionElement() override;
20
21
0
    bool selected() const { return m_selected; }
22
    void set_selected(bool);
23
    void set_selected_internal(bool);
24
25
    String value() const;
26
    WebIDL::ExceptionOr<void> set_value(String const&);
27
28
    String text() const;
29
    void set_text(String const&);
30
31
    int index() const;
32
33
    bool disabled() const;
34
35
    JS::GCPtr<HTML::HTMLFormElement> form() const;
36
37
    virtual Optional<ARIA::Role> default_role() const override;
38
39
private:
40
    friend class Bindings::OptionConstructor;
41
    friend class HTMLSelectElement;
42
43
    HTMLOptionElement(DOM::Document&, DOM::QualifiedName);
44
45
    virtual void initialize(JS::Realm&) override;
46
47
    void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value) override;
48
49
    void ask_for_a_reset();
50
51
    // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness
52
    bool m_selected { false };
53
54
    // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-dirtiness
55
    bool m_dirty { false };
56
};
57
58
}