HTMLSelectElement.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include <LibWeb/HTML/HTMLFormElement.h>
  8. #include <LibWeb/HTML/HTMLOptionElement.h>
  9. #include <LibWeb/HTML/HTMLSelectElement.h>
  10. namespace Web::HTML {
  11. HTMLSelectElement::HTMLSelectElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  12. : FormAssociatedElement(document, move(qualified_name))
  13. {
  14. }
  15. HTMLSelectElement::~HTMLSelectElement()
  16. {
  17. }
  18. // https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-options
  19. RefPtr<HTMLOptionsCollection> const& HTMLSelectElement::options()
  20. {
  21. if (!m_options) {
  22. m_options = HTMLOptionsCollection::create(*this, [](DOM::Element const& element) {
  23. // https://html.spec.whatwg.org/multipage/form-elements.html#concept-select-option-list
  24. // The list of options for a select element consists of all the option element children of
  25. // the select element, and all the option element children of all the optgroup element children
  26. // of the select element, in tree order.
  27. return is<HTMLOptionElement>(element);
  28. });
  29. }
  30. return m_options;
  31. }
  32. }