mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-28 05:52:21 +03:00
Merge pull request #681 from sepiropht/master
[670] add extends for some types
This commit is contained in:
commit
c0c27775f3
@ -2886,7 +2886,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;
|
||||
|
||||
|
1
crates/js-sys/tests/wasm/JsString.js
Normal file
1
crates/js-sys/tests/wasm/JsString.js
Normal file
@ -0,0 +1 @@
|
||||
exports.new_string_object = () => new String("hi");
|
@ -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::<JsString>());
|
||||
assert!(string.is_instance_of::<Object>());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn length() {
|
||||
fn test(s: &str) {
|
||||
|
Loading…
Reference in New Issue
Block a user