From daf421846c83ab1f748b33b52b1de1149d41c43c Mon Sep 17 00:00:00 2001 From: Srikavin Ramkumar Date: Thu, 23 Mar 2023 04:01:05 -0400 Subject: [PATCH] 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. --- .../LibWeb/BindingsGenerator/IDLGenerators.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 012e78fda2..b102245dd2 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -3011,6 +3011,15 @@ JS::ThrowCompletionOr> @constructor_class@::constru generator.set("constructor.length", "0"); generator.append(R"~~~( return vm().throw_completion(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::ErrorType::NotAConstructor, "@namespaced_name@"); )~~~"); } else if (interface.constructors.size() == 1) { // Single constructor