From 96c24c47a2c232cff99721443cea58b7a49e283b Mon Sep 17 00:00:00 2001 From: sepiropht Date: Fri, 10 Aug 2018 07:44:45 +0200 Subject: [PATCH] add extends for JsString --- crates/js-sys/src/lib.rs | 2 +- crates/js-sys/tests/wasm/JsString.js | 1 + crates/js-sys/tests/wasm/JsString.rs | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 crates/js-sys/tests/wasm/JsString.js diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index e0f01f7b..e90ef09c 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -2666,7 +2666,7 @@ extern "C" { // JsString #[wasm_bindgen] extern "C" { - #[wasm_bindgen(js_name = String)] + #[wasm_bindgen(js_name = String, extends = Object)] #[derive(Clone)] pub type JsString; diff --git a/crates/js-sys/tests/wasm/JsString.js b/crates/js-sys/tests/wasm/JsString.js new file mode 100644 index 00000000..04a64a9a --- /dev/null +++ b/crates/js-sys/tests/wasm/JsString.js @@ -0,0 +1 @@ +exports.new_string_object = () => new String("hi"); \ No newline at end of file diff --git a/crates/js-sys/tests/wasm/JsString.rs b/crates/js-sys/tests/wasm/JsString.rs index 973f2cef..881c7a47 100644 --- a/crates/js-sys/tests/wasm/JsString.rs +++ b/crates/js-sys/tests/wasm/JsString.rs @@ -1,7 +1,21 @@ use wasm_bindgen::JsValue; +use wasm_bindgen::prelude::*; +use wasm_bindgen::JsCast; use wasm_bindgen_test::*; use js_sys::*; +#[wasm_bindgen(module = "tests/wasm/JsString.js")] +extern { + fn new_string_object() -> JsValue; +} + +#[wasm_bindgen_test] +fn js_string_inheritance() { + let string = new_string_object(); + assert!(string.is_instance_of::()); + assert!(string.is_instance_of::()); +} + #[wasm_bindgen_test] fn length() { fn test(s: &str) {