Skip to content

Commit 9a49544

Browse files
committed
helper function
1 parent c7fb8c3 commit 9a49544

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
@@ -77,6 +77,11 @@ pub enum WalkResult {
7777
}
7878

7979
impl<'a> Element<'a> {
80+
#[inline]
81+
pub fn has_class(&self, class: &str) -> bool {
82+
self.classes.contains_key(class)
83+
}
84+
8085
#[inline]
8186
pub fn for_each_element<F>(&mut self, mut f: F)
8287
where

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)