Browse Source

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.
Srikavin Ramkumar 2 years ago
parent
commit
daf421846c

+ 9 - 0
Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp

@@ -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