Struct silkenweb::elements::ScriptBuilder[][src]

pub struct ScriptBuilder(_);

Implementations

impl ScriptBuilder[src]

pub fn id(self, value: impl AttributeValue<String>) -> ScriptBuilder[src]

pub fn class(self, value: impl AttributeValue<String>) -> ScriptBuilder[src]

pub fn async_(self, value: impl AttributeValue<bool>) -> ScriptBuilder[src]

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.

pub fn crossorigin(self, value: impl AttributeValue<String>) -> ScriptBuilder[src]

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.

pub fn defer(self, value: impl AttributeValue<bool>) -> ScriptBuilder[src]

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.

pub fn integrity(self, value: impl AttributeValue<String>) -> ScriptBuilder[src]

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

pub fn nomodule(self, value: impl AttributeValue<bool>) -> ScriptBuilder[src]

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.

pub fn nonce(self, value: impl AttributeValue<String>) -> ScriptBuilder[src]

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.

pub fn referrerpolicy(self, value: impl AttributeValue<String>) -> ScriptBuilder[src]

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

pub fn src(self, value: impl AttributeValue<String>) -> ScriptBuilder[src]

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

pub fn type_(self, value: impl AttributeValue<String>) -> ScriptBuilder[src]

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.

impl ScriptBuilder[src]

pub fn on_blur(
    self,
    f: impl FnMut(FocusEvent, HtmlScriptElement) + 'static
) -> ScriptBuilder
[src]

pub fn on_click(
    self,
    f: impl FnMut(MouseEvent, HtmlScriptElement) + 'static
) -> ScriptBuilder
[src]

pub fn on_change(
    self,
    f: impl FnMut(Event, HtmlScriptElement) + 'static
) -> ScriptBuilder
[src]

pub fn on_dblclick(
    self,
    f: impl FnMut(MouseEvent, HtmlScriptElement) + 'static
) -> ScriptBuilder
[src]

pub fn on_focusout(
    self,
    f: impl FnMut(FocusEvent, HtmlScriptElement) + 'static
) -> ScriptBuilder
[src]

pub fn on_input(
    self,
    f: impl FnMut(InputEvent, HtmlScriptElement) + 'static
) -> ScriptBuilder
[src]

pub fn on_keydown(
    self,
    f: impl FnMut(KeyboardEvent, HtmlScriptElement) + 'static
) -> ScriptBuilder
[src]

pub fn on_keyup(
    self,
    f: impl FnMut(KeyboardEvent, HtmlScriptElement) + 'static
) -> ScriptBuilder
[src]

pub fn effect(self, f: impl Effect<HtmlScriptElement>) -> ScriptBuilder[src]

impl ScriptBuilder[src]

pub fn text(self, child: impl Text) -> ScriptBuilder[src]

pub fn child<Child>(self, c: Child) -> ScriptBuilder where
    Child: Into<Element>, 
[src]

Trait Implementations

impl Builder for ScriptBuilder[src]

type Target = Script

impl DomElement for ScriptBuilder[src]

impl From<ScriptBuilder> for Element[src]

impl From<ScriptBuilder> for ElementBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.