mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-21 16:51:33 +00:00
fix: Reflect.has target should be &Object
This commit is contained in:
@ -1040,8 +1040,8 @@ extern "C" {
|
|||||||
/// The static Reflect.has() method works like the in operator as a function.
|
/// The static Reflect.has() method works like the in operator as a function.
|
||||||
///
|
///
|
||||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has
|
||||||
#[wasm_bindgen(static_method_of = Reflect, catch)]
|
#[wasm_bindgen(static_method_of = Reflect)]
|
||||||
pub fn has(target: &JsValue, property_key: &JsValue) -> Result<JsValue, JsValue>;
|
pub fn has(target: &Object, property_key: &JsValue) -> bool;
|
||||||
|
|
||||||
/// The static Reflect.isExtensible() method determines if an object is extensible
|
/// The static Reflect.isExtensible() method determines if an object is extensible
|
||||||
/// (whether it can have new properties added to it). It is similar to
|
/// (whether it can have new properties added to it). It is similar to
|
||||||
|
@ -402,13 +402,8 @@ fn has() {
|
|||||||
use wasm_bindgen::js;
|
use wasm_bindgen::js;
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn has(target: &JsValue, property_key: &JsValue) -> JsValue {
|
pub fn has(target: &js::Object, property_key: &JsValue) -> bool {
|
||||||
let result = js::Reflect::has(target, property_key);
|
js::Reflect::has(target, property_key)
|
||||||
let result = match result {
|
|
||||||
Ok(val) => val,
|
|
||||||
Err(_err) => "TypeError".into()
|
|
||||||
};
|
|
||||||
result
|
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
@ -428,7 +423,6 @@ fn has() {
|
|||||||
assert.equal(wasm.has(object, "foo"), false);
|
assert.equal(wasm.has(object, "foo"), false);
|
||||||
assert.equal(wasm.has(array, 3), true);
|
assert.equal(wasm.has(array, 3), true);
|
||||||
assert.equal(wasm.has(array, 10), false);
|
assert.equal(wasm.has(array, 10), false);
|
||||||
assert.equal(wasm.has("", "property"), "TypeError");
|
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user