diff --git a/src/js.rs b/src/js.rs index 09754469..e870f729 100644 --- a/src/js.rs +++ b/src/js.rs @@ -565,7 +565,8 @@ extern { extern { pub type WeakMap; - /// Returns the function that created an WeakMap wrapper. + /// The WeakMap object is a collection of key/value pairs in which the keys are weakly referenced. + /// The keys must be objects and the values can be arbitrary values. /// /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap #[wasm_bindgen(constructor)] @@ -576,27 +577,27 @@ extern { /// /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/set #[wasm_bindgen(method, js_class="WeakMap")] - pub fn set(this: &WeakMap, key: JsValue, value: JsValue) -> WeakMap; + pub fn set(this: &WeakMap, key: Object, value: JsValue) -> WeakMap; /// The get() method returns a specified by key element /// from a WeakMap object. /// /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get #[wasm_bindgen(method)] - pub fn get(this: &WeakMap, key: JsValue) -> JsValue; + pub fn get(this: &WeakMap, key: Object) -> JsValue; /// The has() method returns a boolean indicating whether an element with /// the specified key exists in the WeakMap object or not. /// /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/has #[wasm_bindgen(method)] - pub fn has(this: &WeakMap, key: JsValue) -> bool; + pub fn has(this: &WeakMap, key: Object) -> bool; /// The delete() method removes the specified element from a WeakMap object. /// /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/delete #[wasm_bindgen(method)] - pub fn delete(this: &WeakMap, key: JsValue) -> bool; + pub fn delete(this: &WeakMap, key: Object) -> bool; } // JsString diff --git a/tests/all/js_globals/WeakMap.rs b/tests/all/js_globals/WeakMap.rs index 47206ea8..6bad21bf 100644 --- a/tests/all/js_globals/WeakMap.rs +++ b/tests/all/js_globals/WeakMap.rs @@ -40,7 +40,7 @@ fn get() { use wasm_bindgen::js; #[wasm_bindgen] - pub fn get_value(this: &js::WeakMap, key: JsValue) -> JsValue { + pub fn get_value(this: &js::WeakMap, key: js::Object) -> JsValue { this.get(key) } "#) @@ -72,7 +72,7 @@ fn set() { use wasm_bindgen::js; #[wasm_bindgen] - pub fn set_value(this: &js::WeakMap, key: JsValue, value: JsValue) -> js::WeakMap { + pub fn set_value(this: &js::WeakMap, key: js::Object, value: js::JsValue) -> js::WeakMap { this.set(key, value) } "#) @@ -101,7 +101,7 @@ fn has() { use wasm_bindgen::js; #[wasm_bindgen] - pub fn has_value(this: &js::WeakMap, key: JsValue) -> bool { + pub fn has_value(this: &js::WeakMap, key: js::Object) -> bool { this.has(key) } "#) @@ -133,7 +133,7 @@ fn delete() { use wasm_bindgen::js; #[wasm_bindgen] - pub fn delete_key(this: &js::WeakMap, key: JsValue) -> bool { + pub fn delete_key(this: &js::WeakMap, key: js::Object) -> bool { this.delete(key) } "#)