Skip to content

Commit

Permalink
LibWeb: Normalize getter name for reflected “Element?” IDL types
Browse files Browse the repository at this point in the history
This change updates the bindings generator for the case defined at
https://html.spec.whatwg.org/#reflecting-content-attributes-in-idl-attributes:element;
that is, the case “If a reflected IDL attribute has the type T?, where T
is either Element or an interface that inherits from Element”.

The change “normalizes” the generator behavior for that case — such that
the generated code expects a getter with a name of the form used in
other cases; e.g., popover_target_element().

Otherwise, without this change, the generator expects a name of the form
get_popover_target_element() for that case.
  • Loading branch information
sideshowbarker authored and trflynn89 committed Dec 28, 2024
1 parent 19567d9 commit 0c6a6d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Libraries/LibWeb/HTML/PopoverInvokerElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PopoverInvokerElement {
public:
PopoverInvokerElement() { }

GC::Ptr<DOM::Element> get_popover_target_element() { return m_popover_target_element; }
GC::Ptr<DOM::Element> popover_target_element() { return m_popover_target_element; }

void set_popover_target_element(GC::Ptr<DOM::Element> value) { m_popover_target_element = value; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3821,7 +3821,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.getter_callback@)
// 1. If reflectedTarget's explicitly set attr-element is a descendant of any of element's shadow-including ancestors, then return reflectedTarget's explicitly set attr-element.
// 2. Return null.
attribute_generator.append(R"~~~(
auto const explicitly_set_attr = TRY(throw_dom_exception_if_needed(vm, [&] { return impl->get_@attribute.cpp_name@(); }));
auto const explicitly_set_attr = TRY(throw_dom_exception_if_needed(vm, [&] { return impl->@attribute.cpp_name@(); }));
if (explicitly_set_attr) {
if (&impl->shadow_including_root() == &explicitly_set_attr->shadow_including_root()) {
retval = explicitly_set_attr;
Expand Down

0 comments on commit 0c6a6d4

Please sign in to comment.