-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.rs
57 lines (46 loc) · 1.13 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#[macro_use]
extern crate wurst;
// TODO generate a prelude
use wurst::elements::*;
use wurst::{El, OutputConsole};
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
extern crate js_sys;
extern crate web_sys;
#[wasm_bindgen]
pub fn run() {
let mut div = create_element!("div", {
// Element interface
id: "Boop",
// HTMLElement interface
title: "hey I am a title",
lang: "en-GB"
});
div.create();
div.add_to_body();
let mut input = create_element!("input", {
// Element interface
id: "Boop",
// Input interface
value: "hey!",
// HTMLElement interface
title: "2323",
lang: "boom"
});
input.create();
input.map(|mut el| {
let v = el.has_child_nodes();
console_log!("Input has children:", v);
let v = el.check_validity();
console_log!("Input is valid:", v);
el.id = Some("boo".into());
el
});
input.update();
div.append(input);
div.map(|mut el| {
let v = el.has_child_nodes();
console_log!("Div has children:", v);
el
});
}