1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 09:48:11 +00:00

LibWeb: Return TypeError for [HTMLConstructor] IDL constructors

This matches the spec since there can be no matching custom element
definition if we don't support custom elements yet.
This commit is contained in:
Srikavin Ramkumar 2023-03-23 04:01:05 -04:00 committed by Andreas Kling
parent 6bc6ea8e97
commit daf421846c

View file

@ -3011,6 +3011,15 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::constru
generator.set("constructor.length", "0");
generator.append(R"~~~(
return vm().throw_completion<JS::TypeError>(JS::ErrorType::NotAConstructor, "@namespaced_name@");
)~~~");
} else if (interface.constructors.find_if([](auto const& x) { return x.extended_attributes.contains("HTMLConstructor"); }) != interface.constructors.end()) {
// https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor
VERIFY(interface.constructors.size() == 1);
// FIXME: Properly implement HTMLConstructor extended attribute once custom elements are implemented
generator.set("constructor.length", "0");
generator.append(R"~~~(
return vm().throw_completion<JS::TypeError>(JS::ErrorType::NotAConstructor, "@namespaced_name@");
)~~~");
} else if (interface.constructors.size() == 1) {
// Single constructor