mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 18:20:51 +00:00
Add binding for Object.getOwnPropertyDescriptors()
This commit is contained in:
parent
b005e96fd9
commit
2d91fa11b5
@ -2031,6 +2031,13 @@ extern "C" {
|
||||
#[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptor)]
|
||||
pub fn get_own_property_descriptor(obj: &Object, prop: &JsValue) -> JsValue;
|
||||
|
||||
/// The Object.getOwnPropertyDescriptors() method returns all own
|
||||
/// property descriptors of a given object.
|
||||
///
|
||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors)
|
||||
#[wasm_bindgen(static_method_of = Object, js_name = getOwnPropertyDescriptors)]
|
||||
pub fn get_own_property_descriptors(obj: &Object) -> JsValue;
|
||||
|
||||
/// The `hasOwnProperty()` method returns a boolean indicating whether the
|
||||
/// object has the specified property as its own property (as opposed to
|
||||
/// inheriting it).
|
||||
|
@ -114,6 +114,14 @@ fn get_own_property_descriptor() {
|
||||
assert!(PropertyDescriptor::from(desc).value().is_undefined());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn get_own_property_descriptors() {
|
||||
let foo = foo_42();
|
||||
let descriptors = Object::get_own_property_descriptors(&foo);
|
||||
let foo_desc = Reflect::get(&descriptors, &"foo".into());
|
||||
assert_eq!(PropertyDescriptor::from(foo_desc).value(), 42);
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn has_own_property() {
|
||||
assert!(foo_42().has_own_property(&"foo".into()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user