mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-01 06:07:59 +00:00
LibJS: Add Object.{isExtensible,preventExtensions}()
This commit is contained in:
committed by
Andreas Kling
parent
daa3f59a55
commit
d5ae73a63b
@@ -48,6 +48,8 @@ ObjectConstructor::ObjectConstructor()
|
||||
define_native_function("getOwnPropertyNames", get_own_property_names, 1, attr);
|
||||
define_native_function("getPrototypeOf", get_prototype_of, 1, attr);
|
||||
define_native_function("setPrototypeOf", set_prototype_of, 2, attr);
|
||||
define_native_function("isExtensible", is_extensible, 1, attr);
|
||||
define_native_function("preventExtensions", prevent_extensions, 1, attr);
|
||||
define_native_function("keys", keys, 1, attr);
|
||||
define_native_function("values", values, 1, attr);
|
||||
define_native_function("entries", entries, 1, attr);
|
||||
@@ -104,6 +106,26 @@ Value ObjectConstructor::set_prototype_of(Interpreter& interpreter)
|
||||
return {};
|
||||
}
|
||||
|
||||
Value ObjectConstructor::is_extensible(Interpreter& interpreter)
|
||||
{
|
||||
auto argument = interpreter.argument(0);
|
||||
if (!argument.is_object())
|
||||
return Value(false);
|
||||
return Value(argument.as_object().is_extensible());
|
||||
}
|
||||
|
||||
Value ObjectConstructor::prevent_extensions(Interpreter& interpreter)
|
||||
{
|
||||
auto argument = interpreter.argument(0);
|
||||
if (!argument.is_object())
|
||||
return argument;
|
||||
if (!argument.as_object().prevent_extensions()) {
|
||||
interpreter.throw_exception<TypeError>("Proxy preventExtensions handler returned false");
|
||||
return {};
|
||||
}
|
||||
return argument;
|
||||
}
|
||||
|
||||
Value ObjectConstructor::get_own_property_descriptor(Interpreter& interpreter)
|
||||
{
|
||||
auto* object = interpreter.argument(0).to_object(interpreter);
|
||||
|
||||
Reference in New Issue
Block a user