File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -2022,6 +2022,15 @@ extern "C" {
2022
2022
#[ wasm_bindgen( static_method_of = Object ) ]
2023
2023
pub fn freeze ( value : & Object ) -> Object ;
2024
2024
2025
+ /// The Object.getOwnPropertyDescriptor() method returns a
2026
+ /// property descriptor for an own property (that is, one directly
2027
+ /// present on an object and not in the object's prototype chain)
2028
+ /// of a given object.
2029
+ ///
2030
+ /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor)
2031
+ #[ wasm_bindgen( static_method_of = Object , js_name = getOwnPropertyDescriptor) ]
2032
+ pub fn get_own_property_descriptor ( obj : & Object , prop : & JsValue ) -> JsValue ;
2033
+
2025
2034
/// The `hasOwnProperty()` method returns a boolean indicating whether the
2026
2035
/// object has the specified property as its own property (as opposed to
2027
2036
/// inheriting it).
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ extern "C" {
13
13
type DefinePropertyAttrs ;
14
14
#[ wasm_bindgen( method, setter, structural) ]
15
15
fn set_value ( this : & DefinePropertyAttrs , val : & JsValue ) ;
16
+
17
+ type PropertyDescriptor ;
18
+ #[ wasm_bindgen( method, getter, structural) ]
19
+ fn value ( this : & PropertyDescriptor ) -> JsValue ;
16
20
}
17
21
18
22
#[ wasm_bindgen( module = "tests/wasm/Object.js" ) ]
@@ -101,6 +105,15 @@ fn define_properties() {
101
105
assert ! ( foo. has_own_property( & "car" . into( ) ) ) ;
102
106
}
103
107
108
+ #[ wasm_bindgen_test]
109
+ fn get_own_property_descriptor ( ) {
110
+ let foo = foo_42 ( ) ;
111
+ let desc = Object :: get_own_property_descriptor ( & foo, & "foo" . into ( ) ) ;
112
+ assert_eq ! ( PropertyDescriptor :: from( desc) . value( ) , 42 ) ;
113
+ let desc = Object :: get_own_property_descriptor ( & foo, & "bar" . into ( ) ) ;
114
+ assert ! ( PropertyDescriptor :: from( desc) . value( ) . is_undefined( ) ) ;
115
+ }
116
+
104
117
#[ wasm_bindgen_test]
105
118
fn has_own_property ( ) {
106
119
assert ! ( foo_42( ) . has_own_property( & "foo" . into( ) ) ) ;
You can’t perform that action at this time.
0 commit comments