1
+ //! WASM bindings for css-inline
2
+ #![ warn(
3
+ clippy:: doc_markdown,
4
+ clippy:: redundant_closure,
5
+ clippy:: explicit_iter_loop,
6
+ clippy:: match_same_arms,
7
+ clippy:: needless_borrow,
8
+ clippy:: print_stdout,
9
+ clippy:: integer_arithmetic,
10
+ clippy:: cast_possible_truncation,
11
+ clippy:: result_unwrap_used,
12
+ clippy:: result_map_unwrap_or_else,
13
+ clippy:: option_unwrap_used,
14
+ clippy:: option_map_unwrap_or_else,
15
+ clippy:: option_map_unwrap_or,
16
+ clippy:: trivially_copy_pass_by_ref,
17
+ clippy:: needless_pass_by_value,
18
+ missing_docs,
19
+ missing_debug_implementations,
20
+ trivial_casts,
21
+ trivial_numeric_casts,
22
+ unused_extern_crates,
23
+ unused_import_braces,
24
+ unused_qualifications,
25
+ variant_size_differences
26
+ ) ]
1
27
use css_inline as rust_inline;
2
- use wasm_bindgen:: prelude:: * ;
3
28
use std:: {
4
29
borrow:: Cow ,
5
30
convert:: { TryFrom , TryInto } ,
6
31
} ;
32
+ use wasm_bindgen:: prelude:: * ;
7
33
8
34
struct InlineErrorWrapper ( rust_inline:: InlineError ) ;
9
35
@@ -17,7 +43,7 @@ struct UrlError(url::ParseError);
17
43
18
44
impl From < UrlError > for JsValue {
19
45
fn from ( error : UrlError ) -> Self {
20
- JsValue :: from_str ( & error. 0 . to_string ( ) . as_str ( ) )
46
+ JsValue :: from_str ( error. 0 . to_string ( ) . as_str ( ) )
21
47
}
22
48
}
23
49
@@ -76,11 +102,9 @@ impl TryFrom<Options> for rust_inline::InlineOptions<'_> {
76
102
}
77
103
}
78
104
105
+ /// Inline CSS styles from <style> tags to matching elements in the HTML tree and return a string.
79
106
#[ wasm_bindgen( skip_typescript) ]
80
- pub fn inline (
81
- html : & str ,
82
- options : & JsValue ,
83
- ) -> Result < String , JsValue > {
107
+ pub fn inline ( html : & str , options : & JsValue ) -> Result < String , JsValue > {
84
108
let options: Options = if !options. is_undefined ( ) {
85
109
options. into_serde ( ) . map_err ( SerdeError ) ?
86
110
} else {
0 commit comments