diff options
author | Linus Groh <mail@linusgroh.de> | 2020-06-02 12:36:11 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-02 13:51:02 +0200 |
commit | c1248a7fd8bfe4087bd4dd71f20ddcfbf3c69181 (patch) | |
tree | cbd1133a1714d194c3d56a771e316956f1ff2b9e /Libraries/LibJS/Runtime/ReflectObject.cpp | |
parent | b958e4f573b6171f8507efa9c097c82f072d73a3 (diff) | |
download | serenity-c1248a7fd8bfe4087bd4dd71f20ddcfbf3c69181.zip |
LibJS: Implement Reflect.{isExtensible,preventExtensions}()
Diffstat (limited to 'Libraries/LibJS/Runtime/ReflectObject.cpp')
-rw-r--r-- | Libraries/LibJS/Runtime/ReflectObject.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Libraries/LibJS/Runtime/ReflectObject.cpp b/Libraries/LibJS/Runtime/ReflectObject.cpp index a36be0520e..3fd2dddb04 100644 --- a/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -211,12 +211,12 @@ Value ReflectObject::has(Interpreter& interpreter) return Value(target->has_property(property_key)); } -Value ReflectObject::is_extensible(Interpreter&) +Value ReflectObject::is_extensible(Interpreter& interpreter) { - // FIXME: For this to be useful we need one of these: - // Object.seal(), Object.freeze(), Reflect.preventExtensions() - // For now we just return true, as that's always the case. - return Value(true); + auto* target = get_target_object_from(interpreter, "isExtensible"); + if (!target) + return {}; + return Value(target->is_extensible()); } Value ReflectObject::own_keys(Interpreter& interpreter) @@ -227,10 +227,12 @@ Value ReflectObject::own_keys(Interpreter& interpreter) return target->get_own_properties(*target, GetOwnPropertyMode::Key); } -Value ReflectObject::prevent_extensions(Interpreter&) +Value ReflectObject::prevent_extensions(Interpreter& interpreter) { - // FIXME: Implement me :^) - ASSERT_NOT_REACHED(); + auto* target = get_target_object_from(interpreter, "preventExtensions"); + if (!target) + return {}; + return Value(target->prevent_extensions()); } Value ReflectObject::set(Interpreter& interpreter) |