mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 12:31:22 +00:00
Add binding for Object.getOwnPropertyDescriptor()
This commit is contained in:
@ -13,6 +13,10 @@ extern "C" {
|
||||
type DefinePropertyAttrs;
|
||||
#[wasm_bindgen(method, setter, structural)]
|
||||
fn set_value(this: &DefinePropertyAttrs, val: &JsValue);
|
||||
|
||||
type PropertyDescriptor;
|
||||
#[wasm_bindgen(method, getter, structural)]
|
||||
fn value(this: &PropertyDescriptor) -> JsValue;
|
||||
}
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/Object.js")]
|
||||
@ -101,6 +105,15 @@ fn define_properties() {
|
||||
assert!(foo.has_own_property(&"car".into()));
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn get_own_property_descriptor() {
|
||||
let foo = foo_42();
|
||||
let desc = Object::get_own_property_descriptor(&foo, &"foo".into());
|
||||
assert_eq!(PropertyDescriptor::from(desc).value(), 42);
|
||||
let desc = Object::get_own_property_descriptor(&foo, &"bar".into());
|
||||
assert!(PropertyDescriptor::from(desc).value().is_undefined());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn has_own_property() {
|
||||
assert!(foo_42().has_own_property(&"foo".into()));
|
||||
|
Reference in New Issue
Block a user