euv_core/vdom/attribute/
impl.rs1use crate::*;
2
3impl PartialEq for AttributeValue {
10 fn eq(&self, other: &Self) -> bool {
21 match (self, other) {
22 (AttributeValue::Text(a_val), AttributeValue::Text(b_val)) => a_val == b_val,
23 (AttributeValue::Signal(a_sig), AttributeValue::Signal(b_sig)) => {
24 a_sig.get() == b_sig.get()
25 }
26 (AttributeValue::Signal(a_sig), AttributeValue::Text(b_val)) => a_sig.get() == *b_val,
27 (AttributeValue::Text(a_val), AttributeValue::Signal(b_sig)) => *a_val == b_sig.get(),
28 (AttributeValue::Event(_), AttributeValue::Event(_)) => true,
29 (AttributeValue::Css(a_css), AttributeValue::Css(b_css)) => {
30 a_css.get_name() == b_css.get_name()
31 }
32 (AttributeValue::Dynamic(a_dyn), AttributeValue::Dynamic(b_dyn)) => a_dyn == b_dyn,
33 _ => false,
34 }
35 }
36}
37
38impl PartialEq for AttributeEntry {
43 fn eq(&self, other: &Self) -> bool {
54 self.get_name() == other.get_name() && self.get_value() == other.get_value()
55 }
56}
57
58impl PartialEq for CssClass {
63 fn eq(&self, other: &Self) -> bool {
74 self.get_name() == other.get_name()
75 }
76}
77
78impl Attribute {
80 pub fn as_str(&self) -> Cow<'static, str> {
89 match self {
90 Attribute::AccessKey => Cow::Borrowed("accesskey"),
91 Attribute::Action => Cow::Borrowed("action"),
92 Attribute::Alt => Cow::Borrowed("alt"),
93 Attribute::AriaLabel => Cow::Borrowed("aria-label"),
94 Attribute::AutoComplete => Cow::Borrowed("autocomplete"),
95 Attribute::AutoFocus => Cow::Borrowed("autofocus"),
96 Attribute::Checked => Cow::Borrowed("checked"),
97 Attribute::Class => Cow::Borrowed("class"),
98 Attribute::Cols => Cow::Borrowed("cols"),
99 Attribute::ContentEditable => Cow::Borrowed("contenteditable"),
100 Attribute::Data(name) => Cow::Owned(format!("data-{}", name)),
101 Attribute::Dir => Cow::Borrowed("dir"),
102 Attribute::Disabled => Cow::Borrowed("disabled"),
103 Attribute::Draggable => Cow::Borrowed("draggable"),
104 Attribute::EncType => Cow::Borrowed("enctype"),
105 Attribute::For => Cow::Borrowed("for"),
106 Attribute::Form => Cow::Borrowed("form"),
107 Attribute::Height => Cow::Borrowed("height"),
108 Attribute::Hidden => Cow::Borrowed("hidden"),
109 Attribute::Href => Cow::Borrowed("href"),
110 Attribute::Id => Cow::Borrowed("id"),
111 Attribute::Lang => Cow::Borrowed("lang"),
112 Attribute::Max => Cow::Borrowed("max"),
113 Attribute::MaxLength => Cow::Borrowed("maxlength"),
114 Attribute::Method => Cow::Borrowed("method"),
115 Attribute::Min => Cow::Borrowed("min"),
116 Attribute::MinLength => Cow::Borrowed("minlength"),
117 Attribute::Multiple => Cow::Borrowed("multiple"),
118 Attribute::Name => Cow::Borrowed("name"),
119 Attribute::Pattern => Cow::Borrowed("pattern"),
120 Attribute::Placeholder => Cow::Borrowed("placeholder"),
121 Attribute::ReadOnly => Cow::Borrowed("readonly"),
122 Attribute::Required => Cow::Borrowed("required"),
123 Attribute::Rows => Cow::Borrowed("rows"),
124 Attribute::Selected => Cow::Borrowed("selected"),
125 Attribute::Size => Cow::Borrowed("size"),
126 Attribute::SpellCheck => Cow::Borrowed("spellcheck"),
127 Attribute::Src => Cow::Borrowed("src"),
128 Attribute::Step => Cow::Borrowed("step"),
129 Attribute::Style => Cow::Borrowed("style"),
130 Attribute::TabIndex => Cow::Borrowed("tabindex"),
131 Attribute::Target => Cow::Borrowed("target"),
132 Attribute::Title => Cow::Borrowed("title"),
133 Attribute::Type => Cow::Borrowed("type"),
134 Attribute::Value => Cow::Borrowed("value"),
135 Attribute::Width => Cow::Borrowed("width"),
136 Attribute::Other(name) => Cow::Owned(name.clone()),
137 }
138 }
139}