fix: Reflect.has target should be &Object

This commit is contained in:
Jannik Keye
2018-07-04 15:32:34 +02:00
parent 3442f9d9d7
commit 008f17143b
2 changed files with 4 additions and 10 deletions

View File

@ -1040,8 +1040,8 @@ extern "C" {
/// 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
#[wasm_bindgen(static_method_of = Reflect, catch)]
pub fn has(target: &JsValue, property_key: &JsValue) -> Result<JsValue, JsValue>;
#[wasm_bindgen(static_method_of = Reflect)]
pub fn has(target: &Object, property_key: &JsValue) -> bool;
/// The static Reflect.isExtensible() method determines if an object is extensible
/// (whether it can have new properties added to it). It is similar to

View File

@ -402,13 +402,8 @@ fn has() {
use wasm_bindgen::js;
#[wasm_bindgen]
pub fn has(target: &JsValue, property_key: &JsValue) -> JsValue {
let result = js::Reflect::has(target, property_key);
let result = match result {
Ok(val) => val,
Err(_err) => "TypeError".into()
};
result
pub fn has(target: &js::Object, property_key: &JsValue) -> bool {
js::Reflect::has(target, property_key)
}
"#,
)
@ -428,7 +423,6 @@ fn has() {
assert.equal(wasm.has(object, "foo"), false);
assert.equal(wasm.has(array, 3), true);
assert.equal(wasm.has(array, 10), false);
assert.equal(wasm.has("", "property"), "TypeError");
}
"#,
)