IDLGenerators: Throw TypeError if custom element is already constructed

Throwing a TypeError instead of an InvalidStateError DOMException
follows the current specification steps.
This commit is contained in:
Tim Ledbetter 2025-02-21 16:45:06 +00:00 committed by Tim Flynn
commit 7ee33529e8
Notes: github-actions[bot] 2025-02-22 10:40:27 +00:00
5 changed files with 358 additions and 2 deletions

View file

@ -2701,9 +2701,9 @@ static void generate_html_constructor(SourceGenerator& generator, IDL::Construct
// 10. Let element be the last entry in definition's construction stack.
auto& element = definition->construction_stack().last();
// 11. If element is an already constructed marker, then throw an "InvalidStateError" DOMException.
// 11. If element is an already constructed marker, then throw a TypeError.
if (element.has<HTML::AlreadyConstructedCustomElementMarker>())
return JS::throw_completion(WebIDL::InvalidStateError::create(realm, "Custom element has already been constructed"_string));
return vm.throw_completion<JS::TypeError>("Custom element has already been constructed"sv);
// 12. Perform ? element.[[SetPrototypeOf]](prototype).
auto actual_element = element.get<GC::Ref<DOM::Element>>();