mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
IDLGenerators: Set namespace object prototype to Object.prototype
Previously, namespace objects were constructed with no prototype, so calling methods like `toString()` on them would unexpectedly throw an exception.
This commit is contained in:
parent
dda730c46b
commit
1127fa1e01
Notes:
sideshowbarker
2024-07-17 07:35:03 +09:00
Author: https://github.com/tcl3
Commit: 1127fa1e01
Pull-request: https://github.com/SerenityOS/serenity/pull/24006
3 changed files with 30 additions and 1 deletions
|
@ -3738,6 +3738,7 @@ void generate_namespace_implementation(IDL::Interface const& interface, StringBu
|
|||
|
||||
generator.set("name", interface.name);
|
||||
generator.set("namespace_class", interface.namespace_class);
|
||||
generator.set("interface_name", interface.name);
|
||||
|
||||
generator.append(R"~~~(
|
||||
#include <AK/Function.h>
|
||||
|
@ -3795,7 +3796,7 @@ namespace Web::Bindings {
|
|||
JS_DEFINE_ALLOCATOR(@namespace_class@);
|
||||
|
||||
@namespace_class@::@namespace_class@(JS::Realm& realm)
|
||||
: Object(ConstructWithoutPrototypeTag::Tag, realm)
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -3810,6 +3811,8 @@ void @namespace_class@::initialize(JS::Realm& realm)
|
|||
|
||||
Base::initialize(realm);
|
||||
|
||||
define_direct_property(vm.well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm, "@interface_name@"_string), JS::Attribute::Configurable);
|
||||
|
||||
)~~~");
|
||||
|
||||
// https://webidl.spec.whatwg.org/#es-operations
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue