Browse Source

Fix Object constructor (#2694)

This Pull Request changes the following:

- Add the additional required condition in the Object constructor that checks if the `NewTarget` is the Object constructor itself.
pull/2695/head
raskad 2 years ago
parent
commit
d794edfeb2
  1. 6
      boa_engine/src/builtins/object/mod.rs

6
boa_engine/src/builtins/object/mod.rs

@ -129,7 +129,11 @@ impl BuiltInConstructor for Object {
context: &mut Context<'_>,
) -> JsResult<JsValue> {
// 1. If NewTarget is neither undefined nor the active function object, then
if !new_target.is_undefined() {
if !new_target.is_undefined()
&& !new_target.as_object().map_or(false, |o| {
o.eq(&context.intrinsics().constructors().object().constructor())
})
{
// a. Return ? OrdinaryCreateFromConstructor(NewTarget, "%Object.prototype%").
let prototype =
get_prototype_from_constructor(new_target, StandardConstructors::object, context)?;

Loading…
Cancel
Save