1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

LibWeb: Expose HTMLSelectElement::options

Use the stub implementation of HTMLOptionsCollection to expose the
`option` children of `select` elements.

This fixes a JS error on openstreetmap.org, which occured when JQuery
code tried to access `options.length`:
https://github.com/jquery/jquery/blob/main/src/attributes/val.js#L121
This commit is contained in:
Simon Wanner 2022-03-16 13:08:12 +01:00 committed by Andreas Kling
parent 624527f15e
commit deef2911e9
3 changed files with 24 additions and 0 deletions

View file

@ -10,6 +10,7 @@
#include <LibWeb/HTML/FormAssociatedElement.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/HTMLOptionsCollection.h>
namespace Web::HTML {
@ -20,6 +21,8 @@ public:
HTMLSelectElement(DOM::Document&, DOM::QualifiedName);
virtual ~HTMLSelectElement() override;
RefPtr<HTMLOptionsCollection> const& options();
// ^FormAssociatedElement
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
virtual bool is_listed() const override { return true; }
@ -36,6 +39,9 @@ public:
// ^HTMLElement
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return true; }
private:
RefPtr<HTMLOptionsCollection> m_options;
};
}