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.
This commit is contained in:
Sam Atkins 2025-07-01 12:59:26 +01:00
commit 16ef883e44
Notes: github-actions[bot] 2025-07-21 09:06:55 +00:00

View file

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