pub trait Document: Dom + Sized {
type MountOutput;
type MountInHeadOutput;
// Required methods
fn mount(
id: &str,
element: impl Into<GenericElement<Self, Const>>
) -> Self::MountOutput;
fn mount_in_head(
id: &str,
head: DocumentHead<Self>
) -> Self::MountInHeadOutput;
fn unmount_all();
fn head_inner_html() -> String;
}
Required Associated Types§
type MountOutput
type MountInHeadOutput
Required Methods§
sourcefn mount(
id: &str,
element: impl Into<GenericElement<Self, Const>>
) -> Self::MountOutput
fn mount( id: &str, element: impl Into<GenericElement<Self, Const>> ) -> Self::MountOutput
Mount an element on the document.
id
is the id of the mount point element. The element will replace
the mount point.
sourcefn mount_in_head(id: &str, head: DocumentHead<Self>) -> Self::MountInHeadOutput
fn mount_in_head(id: &str, head: DocumentHead<Self>) -> Self::MountInHeadOutput
Mount some children in the document <head>
id
is used by hydration, which will set a data-silkenweb-head-id
attribute on each top level element in head
so it can identify which
elements to hydrate against.
§Panics
Mounting something with the same id
will cause a panic.
sourcefn unmount_all()
fn unmount_all()
Remove all mounted elements.
All elements mounted with mount
or mount_in_head
will be removed.
Mount points will not be restored. This is useful to ensure a clean
environment for testing.
sourcefn head_inner_html() -> String
fn head_inner_html() -> String
Get the inner HTML of <head>
.
This only includes elements added with mount_in_head
. It’s useful for
server side rendering, where it can be used to add any stylesheets
required for the HTML.
Object Safety§
This trait is not object safe.