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