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
use crate::elem::{HtmlProp, HtmlProps};
use std::borrow::Cow;
use web_sys::HtmlUListElement;

#[allow(non_camel_case_types)]
#[derive(Clone, PartialEq)]
pub enum UListProp {
    compact(bool),
    r#type(Cow<'static, str>),
}

#[sealed::sealed]
impl crate::elem::HtmlComponent for HtmlUListElement {
    type PropEnum = UListProp;
}
#[sealed::sealed]
impl crate::elem::PropEnum<HtmlUListElement> for UListProp {
    fn unset_on(&self, elem: &HtmlUListElement) {
        match self {
            UListProp::compact(_) => elem.remove_attribute("compact").unwrap(),
            UListProp::r#type(_) => elem.remove_attribute("type").unwrap(),
        }
    }

    fn set_on(&self, elem: &HtmlUListElement) {
        match self {
            UListProp::compact(v) => elem.set_compact(*v),
            UListProp::r#type(v) => elem.set_type(v),
        }
    }
}

impl HtmlProps<HtmlUListElement> {
    pub fn compact(mut self, val: bool) -> Self {
        self.0.push_back(HtmlProp::Own(UListProp::compact(val)));
        self
    }

    pub fn r#type(mut self, val: Cow<'static, str>) -> Self {
        self.0.push_back(HtmlProp::Own(UListProp::r#type(val)));
        self
    }
}