ComponentV2

Trait ComponentV2 

Source
pub trait ComponentV2 {
    // Required methods
    fn init(&mut self, this: HtmlElement);
    fn attribute_changed_callback(
        &self,
        _name: String,
        _old_value: JsValue,
        _new_value: JsValue,
        _this: HtmlElement,
    );
    fn connected_callback(&mut self, this: HtmlElement);
    fn disconnected_callback(&self, this: HtmlElement);

    // Provided methods
    fn observed_attributes(&self, _this: HtmlElement) -> Vec<String> { ... }
    fn adopted_callback(&self, _this: HtmlElement) { ... }
    fn set_data(&mut self, _data: JsValue, _this: HtmlElement) { ... }
}

Required Methods§

Source

fn init(&mut self, this: HtmlElement)

Gives access to a web_sys::HtmlElement. Invoked in the constructor of the CustomElement.

§Arguments
  • this - A structure that holds an HtmlElement
Source

fn attribute_changed_callback( &self, _name: String, _old_value: JsValue, _new_value: JsValue, _this: HtmlElement, )

Invoked when one of the custom element’s attributes is added, removed, or changed.

§Arguments
  • _name - A name of an attribute
  • _old_value - A previous value of an attribute
  • _old_value - A new value of an attribute
  • _this - A structure that holds an HtmlElement
Source

fn connected_callback(&mut self, this: HtmlElement)

Invoked when the custom element is first connected to the document’s DOM.

§Arguments
  • this - A structure that holds an HtmlElement
Source

fn disconnected_callback(&self, this: HtmlElement)

Invoked when the custom element is disconnected from the document’s DOM.

§Arguments
  • this - A structure that holds an HtmlElement

Provided Methods§

Source

fn observed_attributes(&self, _this: HtmlElement) -> Vec<String>

§Arguments
  • this - A structure that holds an HtmlElement Returns list of observed attributes
Source

fn adopted_callback(&self, _this: HtmlElement)

Invoked when the custom element is moved to a new document.

§Arguments
  • this - A structure that holds an HtmlElement
Source

fn set_data(&mut self, _data: JsValue, _this: HtmlElement)

Can be invoked to pass state to a custom element

§Arguments
  • this - A structure that holds an HtmlElement

Implementors§