From 16ef883e44febb95f538ad13494deddb1eec963f Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Tue, 1 Jul 2025 12:59:26 +0100 Subject: [PATCH] IDLGenerators: Update spec steps for "internally create a new object..." Also wrap these in {} so it's clearer which steps are from this, and which are from the HTML algorithm. --- .../BindingsGenerator/IDLGenerators.cpp | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 06d0952331d..c069fe5af59 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -2733,23 +2733,25 @@ static void generate_html_constructor(SourceGenerator& generator, IDL::Construct // https://webidl.spec.whatwg.org/#internally-create-a-new-object-implementing-the-interface // Important steps from "internally create a new object implementing the interface" - // 3.2: Let prototype be ? Get(newTarget, "prototype"). - auto prototype = TRY(new_target.get(vm.names.prototype)); + { + // 3.2: Let prototype be ? Get(newTarget, "prototype"). + auto prototype = TRY(new_target.get(vm.names.prototype)); - // 3.3. If Type(prototype) is not Object, then: - if (!prototype.is_object()) { - // 1. Let targetRealm be ? GetFunctionRealm(newTarget). - auto* target_realm = TRY(JS::get_function_realm(vm, new_target)); + // 3.3. If Type(prototype) is not an Object, then: + if (!prototype.is_object()) { + // 1. Let targetRealm be ? GetFunctionRealm(newTarget). + auto* target_realm = TRY(JS::get_function_realm(vm, new_target)); - // 2. Set prototype to the interface prototype object for interface in targetRealm. - VERIFY(target_realm); - prototype = &Bindings::ensure_web_prototype<@prototype_class@>(*target_realm, "@name@"_fly_string); + // 2. Set prototype to the interface prototype object for interface in targetRealm. + VERIFY(target_realm); + prototype = &Bindings::ensure_web_prototype<@prototype_class@>(*target_realm, "@name@"_fly_string); + } + + // 9. Set instance.[[Prototype]] to prototype. + VERIFY(prototype.is_object()); + MUST(element->internal_set_prototype_of(&prototype.as_object())); } - // 7. Set instance.[[Prototype]] to prototype. - VERIFY(prototype.is_object()); - MUST(element->internal_set_prototype_of(&prototype.as_object())); - // 6. Set element's custom element state to "custom". // 7. Set element's custom element definition to definition. // 8. Set element's is value to isValue.