Struct ScriptBuilder

Source
pub struct ScriptBuilder(/* private fields */);

Implementations§

Source§

impl ScriptBuilder

Source

pub fn id(self, value: impl AttributeValue<String>) -> Self

Source

pub fn class(self, value: impl AttributeValue<String>) -> Self

Source

pub fn async_(self, value: impl AttributeValue<bool>) -> Self

For classic scripts, if the async attribute is present, then the classic script will be fetched in parallel to parsing and evaluated as soon as it is available.

For module scripts, if the async attribute is present then the scripts and all their dependencies will be executed in the defer queue, therefore they will get fetched in parallel to parsing and evaluated as soon as they are available.

This attribute allows the elimination of parser-blocking JavaScript where the browser would have to load and evaluate scripts before continuing to parse. defer has a similar effect in this case.

Source

pub fn crossorigin(self, value: impl AttributeValue<String>) -> Self

Normal script elements pass minimal information to the window.onerror for scripts which do not pass the standard CORS checks. To allow error logging for sites which use a separate domain for static media, use this attribute.

Source

pub fn defer(self, value: impl AttributeValue<bool>) -> Self

Indicates to a browser that the script is meant to be executed after the document has been parsed, but before firing DOMContentLoaded.

Scripts with the defer attribute will prevent the DOMContentLoaded event from firing until the script has loaded and finished evaluating.

This attribute must not be used if the src attribute is absent (i.e. for inline scripts), in this case it would have no effect.

The defer attribute has no effect on module scripts — they defer by default.

Scripts with the defer attribute will execute in the order in which they appear in the document.

This attribute allows the elimination of parser-blocking JavaScript where the browser would have to load and evaluate scripts before continuing to parse. async has a similar effect in this case.

Source

pub fn integrity(self, value: impl AttributeValue<String>) -> Self

This attribute contains inline metadata that a user agent can use to verify that a fetched resource has been delivered free of unexpected manipulation.

Source

pub fn nomodule(self, value: impl AttributeValue<bool>) -> Self

Indicates that the script should not be executed in browsers that support ES2015 modules — in effect, this can be used to serve fallback scripts to older browsers that do not support modular JavaScript code.

Source

pub fn nonce(self, value: impl AttributeValue<String>) -> Self

A cryptographic nonce (number used once) to whitelist scripts in a script-src Content-Security-Policy. The server must generate a unique nonce value each time it transmits a policy. It is critical to provide a nonce that cannot be guessed as bypassing a resource’s policy is otherwise trivial.

Source

pub fn referrerpolicy(self, value: impl AttributeValue<String>) -> Self

Indicates which referrer to send when fetching the script, or resources fetched by the script.

Source

pub fn src(self, value: impl AttributeValue<String>) -> Self

This attribute specifies the URI of an external script; this can be used as an alternative to embedding a script directly within a document.

Source

pub fn type_(self, value: impl AttributeValue<String>) -> Self

This attribute indicates the type of script represented. The value of this attribute will be in one of the following categories:

  • Omitted or a JavaScript MIME type: This indicates the script is JavaScript. The HTML5 specification urges authors to omit the attribute rather than provide a redundant MIME type.
  • module: Causes the code to be treated as a JavaScript module. The processing of the script contents is not affected by the charset and defer attributes. Unlike classic scripts, module scripts require the use of the CORS protocol for cross-origin fetching.
  • Any other value: The embedded content is treated as a data block which won’t be processed by the browser. Developers must use a valid MIME type that is not a JavaScript MIME type to denote data blocks. The src attribute will be ignored.
Source§

impl ScriptBuilder

Source

pub fn on_blur( self, f: impl 'static + FnMut(FocusEvent, HtmlScriptElement), ) -> Self

Source

pub fn on_click( self, f: impl 'static + FnMut(MouseEvent, HtmlScriptElement), ) -> Self

Source

pub fn on_change( self, f: impl 'static + FnMut(Event, HtmlScriptElement), ) -> Self

Source

pub fn on_dblclick( self, f: impl 'static + FnMut(MouseEvent, HtmlScriptElement), ) -> Self

Source

pub fn on_focusout( self, f: impl 'static + FnMut(FocusEvent, HtmlScriptElement), ) -> Self

Source

pub fn on_input( self, f: impl 'static + FnMut(InputEvent, HtmlScriptElement), ) -> Self

Source

pub fn on_keydown( self, f: impl 'static + FnMut(KeyboardEvent, HtmlScriptElement), ) -> Self

Source

pub fn on_keyup( self, f: impl 'static + FnMut(KeyboardEvent, HtmlScriptElement), ) -> Self

Source

pub fn effect(self, f: impl Effect<HtmlScriptElement>) -> Self

Source§

impl ScriptBuilder

Source

pub fn text(self, child: impl Text) -> Self

Source

pub fn child<Child>(self, c: Child) -> Self
where Child: Into<Element>,

Trait Implementations§

Source§

impl Builder for ScriptBuilder

Source§

impl DomElement for ScriptBuilder

Source§

impl From<ScriptBuilder> for Element

Source§

fn from(builder: ScriptBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<ScriptBuilder> for ElementBuilder

Source§

fn from(builder: ScriptBuilder) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.