diff --git a/boa/src/builtins/object/mod.rs b/boa/src/builtins/object/mod.rs index e1ca18c874..35914e6b74 100644 --- a/boa/src/builtins/object/mod.rs +++ b/boa/src/builtins/object/mod.rs @@ -696,7 +696,7 @@ impl Object { /// [spec]: https://tc39.es/ecma262/#sec-object.seal /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal pub fn seal(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { - let o = args.get(0).cloned().unwrap_or_default(); + let o = args.get_or_undefined(0); if let Some(o) = o.as_object() { // 2. Let status be ? SetIntegrityLevel(O, sealed). @@ -708,7 +708,7 @@ impl Object { } // 1. If Type(O) is not Object, return O. // 4. Return O. - Ok(o) + Ok(o.clone()) } /// `Object.isSealed( target )` @@ -720,7 +720,7 @@ impl Object { /// [spec]: https://tc39.es/ecma262/#sec-object.issealed /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed pub fn is_sealed(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { - let o = args.get(0).cloned().unwrap_or_default(); + let o = args.get_or_undefined(0); // 1. If Type(O) is not Object, return true. // 2. Return ? TestIntegrityLevel(O, sealed). @@ -741,7 +741,7 @@ impl Object { /// [spec]: https://tc39.es/ecma262/#sec-object.freeze /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze pub fn freeze(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { - let o = args.get(0).cloned().unwrap_or_default(); + let o = args.get_or_undefined(0); if let Some(o) = o.as_object() { // 2. Let status be ? SetIntegrityLevel(O, frozen). @@ -753,7 +753,7 @@ impl Object { } // 1. If Type(O) is not Object, return O. // 4. Return O. - Ok(o) + Ok(o.clone()) } /// `Object.isFrozen( target )` @@ -765,7 +765,7 @@ impl Object { /// [spec]: https://tc39.es/ecma262/#sec-object.isfrozen /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen pub fn is_frozen(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult { - let o = args.get(0).cloned().unwrap_or_default(); + let o = args.get_or_undefined(0); // 1. If Type(O) is not Object, return true. // 2. Return ? TestIntegrityLevel(O, frozen). @@ -790,7 +790,7 @@ impl Object { args: &[JsValue], context: &mut Context, ) -> JsResult { - let o = args.get(0).cloned().unwrap_or_default(); + let o = args.get_or_undefined(0); if let Some(o) = o.as_object() { // 2. Let status be ? O.[[PreventExtensions]](). @@ -802,7 +802,7 @@ impl Object { } // 1. If Type(O) is not Object, return O. // 4. Return O. - Ok(o) + Ok(o.clone()) } /// `Object.isExtensible( target )` @@ -818,7 +818,7 @@ impl Object { args: &[JsValue], context: &mut Context, ) -> JsResult { - let o = args.get(0).cloned().unwrap_or_default(); + let o = args.get_or_undefined(0); // 1. If Type(O) is not Object, return false. if let Some(o) = o.as_object() { // 2. Return ? IsExtensible(O).