From ea0ac134dbe1af2847201be88f1703ea196b51ea Mon Sep 17 00:00:00 2001 From: Sendil Kumar Date: Tue, 14 Aug 2018 19:29:13 +0200 Subject: [PATCH] js-sys: Add extends attributes for js_sys::Uint8Array --- crates/js-sys/src/lib.rs | 1 + crates/js-sys/tests/wasm/TypedArray.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index 852d49f1..7bdcc9d0 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -2539,6 +2539,7 @@ extern { // Uint8Array #[wasm_bindgen] extern "C" { + #[wasm_bindgen(extends = Object)] #[derive(Clone, Debug)] pub type Uint8Array; diff --git a/crates/js-sys/tests/wasm/TypedArray.rs b/crates/js-sys/tests/wasm/TypedArray.rs index e3b6292a..ac9dcaba 100644 --- a/crates/js-sys/tests/wasm/TypedArray.rs +++ b/crates/js-sys/tests/wasm/TypedArray.rs @@ -1,7 +1,26 @@ use wasm_bindgen::prelude::*; use wasm_bindgen_test::*; +use wasm_bindgen::JsCast; use js_sys::*; +macro_rules! each { + ($m:ident) => ( + $m!(Uint8Array); + ) +} + +macro_rules! test_inheritence { + ($arr:ident) => ({ + let arr = $arr::new(&JsValue::undefined()); + assert!(arr.is_instance_of::()); + assert!(arr.is_instance_of::()); + }) +} +#[wasm_bindgen_test] +fn inheritence() { + each!(test_inheritence); +} + macro_rules! each { ($m:ident) => ( $m!(Uint8Array);