1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:17:44 +00:00

LibWeb/WebIDL: Add the construct abstract operation

This will be used by custom elements to upgrade an element to a custom
element.
This commit is contained in:
Luke Wilde 2023-03-29 23:41:19 +01:00 committed by Andreas Kling
parent 9b8b363445
commit 083b547e97
2 changed files with 72 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
* Copyright (c) 2021-2023, Luke Wilde <lukew@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
@ -47,4 +47,18 @@ JS::Completion invoke_callback(WebIDL::CallbackType& callback, Optional<JS::Valu
return invoke_callback(callback, move(this_argument), move(arguments_list));
}
JS::Completion construct(WebIDL::CallbackType& callback, JS::MarkedVector<JS::Value> args);
// https://webidl.spec.whatwg.org/#construct-a-callback-function
template<typename... Args>
JS::Completion construct(WebIDL::CallbackType& callback, Args&&... args)
{
auto& function_object = callback.callback;
JS::MarkedVector<JS::Value> arguments_list { function_object->heap() };
(arguments_list.append(forward<Args>(args)), ...);
return construct(callback, move(arguments_list));
}
}