mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 12:31:22 +00:00
Add binding for Object.defineProperty()
This commit is contained in:
@ -9,6 +9,10 @@ extern "C" {
|
||||
type Foo42;
|
||||
#[wasm_bindgen(method, setter, structural)]
|
||||
fn set_foo(this: &Foo42, val: JsValue);
|
||||
|
||||
type DefinePropertyAttrs;
|
||||
#[wasm_bindgen(method, setter, structural)]
|
||||
fn set_value(this: &DefinePropertyAttrs, val: &JsValue);
|
||||
}
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/Object.js")]
|
||||
@ -73,6 +77,16 @@ fn create() {
|
||||
assert!(my_array.is_instance_of::<Array>());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn define_property() {
|
||||
let value = DefinePropertyAttrs::from(JsValue::from(Object::new()));
|
||||
value.set_value(&43.into());
|
||||
let descriptor = Object::from(JsValue::from(value));
|
||||
let foo = foo_42();
|
||||
let foo = Object::define_property(&foo, &"bar".into(), &descriptor);
|
||||
assert!(foo.has_own_property(&"bar".into()));
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn has_own_property() {
|
||||
assert!(foo_42().has_own_property(&"foo".into()));
|
||||
|
Reference in New Issue
Block a user