Add VTag::into_children (#2638)

* Add `VTag::into_children`

Currently, VTag supports `children` and `children_mut`, but not `into_children` to complete the pattern. This is useful if someone wishes to destructively acquire the children of a VTag to reparent them to a different VTag.

* Repair broken doc comment on `VTag::children_mut`

* Remove spaces between functions
This commit is contained in:
Lucille Blumire 2022-04-23 13:06:41 +01:00 committed by GitHub
parent 1794dd01bc
commit 2db4c81ad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -297,7 +297,7 @@ impl VTag {
}
/// Returns a mutable reference to the children of this [VTag], if the node can have
// children
/// children
pub fn children_mut(&mut self) -> Option<&mut VList> {
match &mut self.inner {
VTagInner::Other { children, .. } => Some(children),
@ -305,6 +305,14 @@ impl VTag {
}
}
/// Returns the children of this [VTag]
pub fn into_children(self) -> VList {
match self.inner {
VTagInner::Other { children, .. } => children,
_ => VList::new(),
}
}
/// Returns the `value` of an
/// [InputElement](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) or
/// [TextArea](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea)