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§
Sourcefn init(&mut self, this: HtmlElement)
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
Sourcefn attribute_changed_callback(
&self,
_name: String,
_old_value: JsValue,
_new_value: JsValue,
_this: HtmlElement,
)
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
Sourcefn connected_callback(&mut self, this: HtmlElement)
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
Sourcefn disconnected_callback(&self, this: HtmlElement)
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§
Sourcefn observed_attributes(&self, _this: HtmlElement) -> Vec<String>
fn observed_attributes(&self, _this: HtmlElement) -> Vec<String>
§Arguments
this- A structure that holds an HtmlElement Returns list of observed attributes
Sourcefn adopted_callback(&self, _this: HtmlElement)
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
Sourcefn set_data(&mut self, _data: JsValue, _this: HtmlElement)
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