pub struct DomTokenListMut<'a, Ext: 'static> { /* private fields */ }Expand description
Mutable handle to an element’s class tokens. Holds a NodeMut
so mutations route through the existing class-set machinery
(add_class / remove_class / replace_class), keeping
cascade dirty-tracking and the per-class index in sync.
Implementations§
Source§impl<'a, Ext: 'static> DomTokenListMut<'a, Ext>
impl<'a, Ext: 'static> DomTokenListMut<'a, Ext>
Sourcepub fn new(node: NodeMut<'a, Ext>) -> Self
pub fn new(node: NodeMut<'a, Ext>) -> Self
Construct from a borrowed NodeMut. The mutable list shares
the node’s lifetime — drop the list to release the borrow.
Sourcepub fn add(&mut self, token: &str) -> Result<()>
pub fn add(&mut self, token: &str) -> Result<()>
Add token to the class set. Idempotent — no-op if the
token is already present. DOM add.
Sourcepub fn remove(&mut self, token: &str) -> Result<bool>
pub fn remove(&mut self, token: &str) -> Result<bool>
Remove token from the class set. Returns true iff a
token was actually removed (false when the token wasn’t
present). DOM remove.
Sourcepub fn toggle(&mut self, token: &str, force: Option<bool>) -> Result<bool>
pub fn toggle(&mut self, token: &str, force: Option<bool>) -> Result<bool>
Toggle token with optional force.
force = Some(true)→ ensure present; returnstrue.force = Some(false)→ ensure absent; returnsfalse.force = None→ flip; returns the post-flip presence.
DOM toggle(token, force).
Sourcepub fn replace(&mut self, old: &str, new: &str) -> Result<bool>
pub fn replace(&mut self, old: &str, new: &str) -> Result<bool>
Replace old with new. Returns true iff the
replacement happened (i.e., old was present). DOM
replace(old, new).
Sourcepub fn supports(&self, _token: &str) -> bool
pub fn supports(&self, _token: &str) -> bool
true iff token is in the supported-token list for this
attribute. DOM spec only defines this for specific
element-attribute pairs (<link>.relList,
<iframe>.sandbox, …); for classList and everything else
rdom doesn’t track, returns false. DOM supports.