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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
use crate::elem::{HtmlProp, HtmlProps}; use std::borrow::Cow; use web_sys::HtmlAnchorElement; #[allow(non_camel_case_types)] #[derive(Clone, PartialEq)] pub enum AnchorProp { target(Cow<'static, str>), download(Cow<'static, str>), ping(Cow<'static, str>), rel(Cow<'static, str>), referrer_policy(Cow<'static, str>), hreflang(Cow<'static, str>), r#type(Cow<'static, str>), coords(Cow<'static, str>), charset(Cow<'static, str>), name(Cow<'static, str>), rev(Cow<'static, str>), shape(Cow<'static, str>), href(Cow<'static, str>), protocol(Cow<'static, str>), username(Cow<'static, str>), password(Cow<'static, str>), host(Cow<'static, str>), hostname(Cow<'static, str>), port(Cow<'static, str>), pathname(Cow<'static, str>), search(Cow<'static, str>), hash(Cow<'static, str>), } #[sealed::sealed] impl crate::elem::HtmlComponent for HtmlAnchorElement { type PropEnum = AnchorProp; } #[sealed::sealed] impl crate::elem::PropEnum<HtmlAnchorElement> for AnchorProp { fn unset_on(&self, elem: &HtmlAnchorElement) { match self { AnchorProp::target(_) => elem.remove_attribute("target").unwrap(), AnchorProp::download(_) => elem.remove_attribute("download").unwrap(), AnchorProp::ping(_) => elem.remove_attribute("ping").unwrap(), AnchorProp::rel(_) => elem.remove_attribute("rel").unwrap(), AnchorProp::referrer_policy(_) => elem.remove_attribute("referrer_policy").unwrap(), AnchorProp::hreflang(_) => elem.remove_attribute("hreflang").unwrap(), AnchorProp::r#type(_) => elem.remove_attribute("type").unwrap(), AnchorProp::coords(_) => elem.remove_attribute("coords").unwrap(), AnchorProp::charset(_) => elem.remove_attribute("charset").unwrap(), AnchorProp::name(_) => elem.remove_attribute("name").unwrap(), AnchorProp::rev(_) => elem.remove_attribute("rev").unwrap(), AnchorProp::shape(_) => elem.remove_attribute("shape").unwrap(), AnchorProp::href(_) => elem.remove_attribute("href").unwrap(), AnchorProp::protocol(_) => elem.remove_attribute("protocol").unwrap(), AnchorProp::username(_) => elem.remove_attribute("username").unwrap(), AnchorProp::password(_) => elem.remove_attribute("password").unwrap(), AnchorProp::host(_) => elem.remove_attribute("host").unwrap(), AnchorProp::hostname(_) => elem.remove_attribute("hostname").unwrap(), AnchorProp::port(_) => elem.remove_attribute("port").unwrap(), AnchorProp::pathname(_) => elem.remove_attribute("pathname").unwrap(), AnchorProp::search(_) => elem.remove_attribute("search").unwrap(), AnchorProp::hash(_) => elem.remove_attribute("hash").unwrap(), } } fn set_on(&self, elem: &HtmlAnchorElement) { match self { AnchorProp::target(v) => elem.set_target(v), AnchorProp::download(v) => elem.set_download(v), AnchorProp::ping(v) => elem.set_ping(v), AnchorProp::rel(v) => elem.set_rel(v), AnchorProp::referrer_policy(v) => elem.set_referrer_policy(v), AnchorProp::hreflang(v) => elem.set_hreflang(v), AnchorProp::r#type(v) => elem.set_type(v), AnchorProp::coords(v) => elem.set_coords(v), AnchorProp::charset(v) => elem.set_charset(v), AnchorProp::name(v) => elem.set_name(v), AnchorProp::rev(v) => elem.set_rev(v), AnchorProp::shape(v) => elem.set_shape(v), AnchorProp::href(v) => elem.set_href(v), AnchorProp::protocol(v) => elem.set_protocol(v), AnchorProp::username(v) => elem.set_username(v), AnchorProp::password(v) => elem.set_password(v), AnchorProp::host(v) => elem.set_host(v), AnchorProp::hostname(v) => elem.set_hostname(v), AnchorProp::port(v) => elem.set_port(v), AnchorProp::pathname(v) => elem.set_pathname(v), AnchorProp::search(v) => elem.set_search(v), AnchorProp::hash(v) => elem.set_hash(v), } } } impl HtmlProps<HtmlAnchorElement> { pub fn target(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::target(val))); self } pub fn download(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::download(val))); self } pub fn ping(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::ping(val))); self } pub fn rel(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::rel(val))); self } pub fn referrer_policy(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0 .push_back(HtmlProp::Own(AnchorProp::referrer_policy(val))); self } pub fn hreflang(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::hreflang(val))); self } pub fn r#type(mut self, val: Cow<'static, str>) -> Self { self.0.push_back(HtmlProp::Own(AnchorProp::r#type(val))); self } pub fn coords(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::coords(val))); self } pub fn charset(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::charset(val))); self } pub fn name(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::name(val))); self } pub fn rev(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::rev(val))); self } pub fn shape(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::shape(val))); self } pub fn href(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::href(val))); self } pub fn protocol(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::protocol(val))); self } pub fn username(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::username(val))); self } pub fn password(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::password(val))); self } pub fn host(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::host(val))); self } pub fn hostname(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::hostname(val))); self } pub fn port(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::port(val))); self } pub fn pathname(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::pathname(val))); self } pub fn search(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::search(val))); self } pub fn hash(mut self, val: impl Into<Cow<'static, str>>) -> Self { let val = val.into(); self.0.push_back(HtmlProp::Own(AnchorProp::hash(val))); self } }