11use bumpalo:: { Bump , BumpAllocSafe } ;
2+ use std:: sync:: Once ;
23use wasm_bindgen:: prelude:: * ;
34
45pub mod js {
56 use wasm_bindgen:: prelude:: * ;
67
7- #[ wasm_bindgen( module = "dodrio/change-list" ) ]
8+ #[ wasm_bindgen]
89 extern "C" {
910 #[ derive( Clone , Debug ) ]
1011 pub type ChangeList ;
1112
1213 #[ wasm_bindgen( constructor) ]
1314 pub fn new ( container : & web_sys:: Node ) -> ChangeList ;
1415
15- #[ wasm_bindgen( method, js_name = addChangeListRange) ]
16+ #[ wasm_bindgen( structural , method, js_name = addChangeListRange) ]
1617 pub fn add_change_list_range ( this : & ChangeList , start : usize , len : usize ) ;
1718
18- #[ wasm_bindgen( method, js_name = applyChanges) ]
19+ #[ wasm_bindgen( structural , method, js_name = applyChanges) ]
1920 pub fn apply_changes ( this : & ChangeList , memory : JsValue ) ;
2021 }
2122}
@@ -27,6 +28,17 @@ pub(crate) struct ChangeList {
2728
2829impl ChangeList {
2930 pub ( crate ) fn new ( container : & web_sys:: Node ) -> ChangeList {
31+ // XXX: Because wasm-bindgen-test doesn't support third party JS
32+ // dependencies, we can't use `wasm_bindgen(module = "...")` for our
33+ // `ChangeList` JS import. Instead, this *should* be a local JS snippet,
34+ // but that isn't implemented yet:
35+ // https://github.com/rustwasm/rfcs/pull/6
36+ static EVAL : Once = Once :: new ( ) ;
37+ EVAL . call_once ( || {
38+ js_sys:: eval ( include_str ! ( "../js/change-list.js" ) )
39+ . expect ( "should eval change-list.js OK" ) ;
40+ } ) ;
41+
3042 let bump = Bump :: new ( ) ;
3143 let js = js:: ChangeList :: new ( container) ;
3244 ChangeList { bump, js }
0 commit comments