Skip to content

Commit 84a8289

Browse files
committed
helper function
1 parent 408e026 commit 84a8289

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/dom/element.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ impl<'a> ForEach<'a> for Element<'a> {
8383
}
8484

8585
impl Element<'_> {
86+
#[inline]
87+
pub fn has_class(&self, class: &str) -> bool {
88+
self.classes.contains_key(class)
89+
}
90+
8691
#[inline(always)]
8792
pub fn to_html(&self) -> String {
8893
let mut result = String::new();

src/dom/html.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ impl<'a> PartialEq<str> for &Attribute<'a> {
4646
}
4747
}
4848

49+
impl Borrow<str> for Attribute<'_> {
50+
fn borrow(&self) -> &str {
51+
self.as_str()
52+
}
53+
}
54+
4955
#[derive(Default, Serialize, PartialEq, Eq, IntoOwned, ToBorrowed, ToOwned)]
5056
#[serde(transparent)]
5157
pub struct Text<'a>(pub Cow<'a, str>);

0 commit comments

Comments
 (0)