Skip to main content

HtmlCollection

Struct HtmlCollection 

Source
pub struct HtmlCollection<'a, Ext: 'static> { /* private fields */ }
Expand description

Snapshot of element ids captured at construction with name-based lookup. Used by form.elements, getElementsByTagName, etc.

Implementations§

Source§

impl<'a, Ext: 'static> HtmlCollection<'a, Ext>

Source

pub fn from_ids( dom: &'a Dom<Ext>, nodes: impl IntoIterator<Item = NodeId>, ) -> Self

Construct from an iterator of element ids and a borrowed Dom. Used by form.elements() (M4b step 30) and tests.

Source

pub fn len(&self) -> usize

Number of element ids in the snapshot. DOM length.

Source

pub fn is_empty(&self) -> bool

true iff the snapshot has no element ids.

Source

pub fn item(&self, index: usize) -> Option<NodeRef<'a, Ext>>

Borrow the i-th element if (a) the index is in range and (b) the underlying id still resolves to a live element. DOM item(i).

Source

pub fn named_item(&self, name: &str) -> Option<NodeRef<'a, Ext>>

Look up the first element whose name attribute matches name, falling back to id attribute. Matches DOM namedItem (the “named property getter” on HTMLCollection). Snapshot-resolved — removed nodes are skipped even if their id was in the original snapshot.

Source

pub fn iter(&self) -> impl Iterator<Item = NodeRef<'a, Ext>> + '_

Iterate over the live members of the snapshot in snapshot order. Nodes removed since the snapshot was taken are skipped.

Source

pub fn ids(&self) -> &[NodeId]

Raw access to the snapshot’s id slice. Escape hatch.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<'a, Ext> Freeze for HtmlCollection<'a, Ext>
where &'a Dom<Ext>: Freeze,

§

impl<'a, Ext> Unpin for HtmlCollection<'a, Ext>
where &'a Dom<Ext>: Unpin,

§

impl<'a, Ext> UnsafeUnpin for HtmlCollection<'a, Ext>
where &'a Dom<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.