Skip to main content

DomTokenListMut

Struct DomTokenListMut 

Source
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>

Source

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.

Source

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.

Source

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.

Source

pub fn toggle(&mut self, token: &str, force: Option<bool>) -> Result<bool>

Toggle token with optional force.

  • force = Some(true) → ensure present; returns true.
  • force = Some(false) → ensure absent; returns false.
  • force = None → flip; returns the post-flip presence.

DOM toggle(token, force).

Source

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).

Source

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.

Source

pub fn contains(&self, token: &str) -> bool

Borrow the current token set without releasing the NodeMut.

Source

pub fn len(&self) -> usize

Number of tokens currently on the element. DOM length.

Source

pub fn is_empty(&self) -> bool

true iff the element has no class tokens.

Auto Trait Implementations§

§

impl<'a, Ext> !RefUnwindSafe for DomTokenListMut<'a, Ext>

§

impl<'a, Ext> !Send for DomTokenListMut<'a, Ext>

§

impl<'a, Ext> !Sync for DomTokenListMut<'a, Ext>

§

impl<'a, Ext> !UnwindSafe for DomTokenListMut<'a, Ext>

§

impl<'a, Ext> Freeze for DomTokenListMut<'a, Ext>
where NodeMut<'a, Ext>: Freeze,

§

impl<'a, Ext> Unpin for DomTokenListMut<'a, Ext>
where NodeMut<'a, Ext>: Unpin,

§

impl<'a, Ext> UnsafeUnpin for DomTokenListMut<'a, Ext>
where NodeMut<'a, Ext>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.