File tree 2 files changed +9
-5
lines changed
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ extern {
84
84
///
85
85
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
86
86
#[ wasm_bindgen( method, js_name = hasOwnProperty) ]
87
- pub fn has_own_property ( this : & Object , property : & str ) -> bool ;
87
+ pub fn has_own_property ( this : & Object , property : & JsValue ) -> bool ;
88
88
89
89
/// The toString() method returns a string representing the object.
90
90
///
Original file line number Diff line number Diff line change @@ -39,17 +39,21 @@ fn has_own_property() {
39
39
use wasm_bindgen::js;
40
40
41
41
#[wasm_bindgen]
42
- pub fn has_own_foo_property(obj: &js::Object) -> bool {
43
- obj.has_own_property("foo" )
42
+ pub fn has_own_foo_property(obj: &js::Object, property: &JsValue ) -> bool {
43
+ obj.has_own_property(&property )
44
44
}
45
45
"# )
46
46
. file ( "test.ts" , r#"
47
47
import * as assert from "assert";
48
48
import * as wasm from "./out";
49
49
50
50
export function test() {
51
- assert.ok(wasm.has_own_foo_property({ foo: 42 }));
52
- assert.ok(!wasm.has_own_foo_property({}));
51
+ assert(wasm.has_own_foo_property({ foo: 42 }, "foo"));
52
+ assert(wasm.has_own_foo_property({ 42: "foo" }, 42));
53
+ assert(!wasm.has_own_foo_property({ foo: 42 }, "bar"));
54
+
55
+ const s = Symbol();
56
+ assert(wasm.has_own_foo_property({ [s]: "foo" }, s));
53
57
}
54
58
"# )
55
59
. test ( )
You can’t perform that action at this time.
0 commit comments