pub struct Doc;Expand description
Zero-sized handle providing convenient access to the current
web_sys::Document.
Each method resolves window().document() on demand, so no browser handles
are stored. Re-exported as Document.
Implementations§
Source§impl Doc
impl Doc
Sourcepub fn get_element_by_id(&self, id: &str) -> Option<Element>
pub fn get_element_by_id(&self, id: &str) -> Option<Element>
Returns the element with the given id, or None if it does not exist
or no document is available.
Sourcepub fn query_selector(&self, selector: &str) -> Result<Option<Element>, JsValue>
pub fn query_selector(&self, selector: &str) -> Result<Option<Element>, JsValue>
Returns the first element matching the CSS selector.
Returns Ok(None) when nothing matches, and Err when the document is
unavailable or the selector is invalid.
Sourcepub fn create_element(&self, tag: &str) -> Result<Element, JsValue>
pub fn create_element(&self, tag: &str) -> Result<Element, JsValue>
Creates a new element with the given tag name.
Returns Err when the window or document is unavailable.
Sourcepub fn body(&self) -> Result<HtmlElement, JsValue>
pub fn body(&self) -> Result<HtmlElement, JsValue>
Returns the document <body> element.
Returns Err when the window, document, or body is unavailable.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Doc
impl RefUnwindSafe for Doc
impl Send for Doc
impl Sync for Doc
impl Unpin for Doc
impl UnsafeUnpin for Doc
impl UnwindSafe for Doc
Blanket Implementations§
impl<Token, Builder, How> AllPropsFor<Builder, How> for Tokenwhere
Builder: Buildable<Token>,
<Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> HasAllProps<(), T> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self to a value of a Properties struct.Source§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.