Skip to content

Commit 2574065

Browse files
committed
Add EndTag.removed property to consolidate impl_mutations_end_tag
1 parent 614d7b0 commit 2574065

File tree

3 files changed

+8
-42
lines changed

3 files changed

+8
-42
lines changed

js-api/src/end_tag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use lol_html::html_content::EndTag as NativeEndTag;
55
pub struct EndTag(NativeRefWrap<NativeEndTag<'static>>);
66

77
impl_from_native!(NativeEndTag => EndTag);
8-
impl_mutations_end_tag!(EndTag);
8+
impl_mutations!(EndTag);
99

1010
#[wasm_bindgen]
1111
impl EndTag {

js-api/src/lib.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -155,47 +155,6 @@ macro_rules! impl_mutations {
155155
};
156156
}
157157

158-
macro_rules! impl_mutations_end_tag {
159-
($Ty:ident) => {
160-
#[wasm_bindgen]
161-
impl $Ty {
162-
pub fn before(
163-
&mut self,
164-
content: &str,
165-
content_type: Option<ContentTypeOptions>,
166-
) -> Result<(), JsValue> {
167-
self.0
168-
.get_mut()
169-
.map(|o| o.before(content, content_type.into_native()))
170-
}
171-
172-
pub fn after(
173-
&mut self,
174-
content: &str,
175-
content_type: Option<ContentTypeOptions>,
176-
) -> Result<(), JsValue> {
177-
self.0
178-
.get_mut()
179-
.map(|o| o.after(content, content_type.into_native()))
180-
}
181-
182-
pub fn replace(
183-
&mut self,
184-
content: &str,
185-
content_type: Option<ContentTypeOptions>,
186-
) -> Result<(), JsValue> {
187-
self.0
188-
.get_mut()
189-
.map(|o| o.replace(content, content_type.into_native()))
190-
}
191-
192-
pub fn remove(&mut self) -> Result<(), JsValue> {
193-
self.0.get_mut().map(|o| o.remove())
194-
}
195-
}
196-
};
197-
}
198-
199158
macro_rules! impl_from_native {
200159
($Ty:ty => $JsTy:path) => {
201160
impl $JsTy {

src/rewritable_units/tokens/end_tag.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ impl<'i> EndTag<'i> {
141141
self.mutations.mutate().remove();
142142
}
143143

144+
/// Returns `true` if the comment has been replaced or removed.
145+
#[inline]
146+
#[must_use]
147+
pub fn removed(&self) -> bool {
148+
self.mutations.removed()
149+
}
150+
144151
#[inline]
145152
fn serialize_self(&self, output_handler: &mut dyn FnMut(&[u8])) -> Result<(), RewritingError> {
146153
if let Some(raw) = &self.raw {

0 commit comments

Comments
 (0)