CustomElement Class

The .NET object of a custom element defined with a CustomElementConstructor. The virtual methods are the lifecycle callbacks of the custom element (https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-reactions).

public abstract class CustomElement

Constructors

NameDescription
CustomElement(HtmlElement)Initializes the custom element of element, the element being created or upgraded.

CustomElement(HtmlElement)

CustomElementConstructor.cs

Initializes the custom element of element, the element being created or upgraded.

protected CustomElement(HtmlElement element)

Parameters

element HtmlElement

Properties

NameDescription
ElementGets the element.

Gets the element.

public HtmlElement Element { get; }

Property value

HtmlElement

Methods

NameDescription
AdoptedCallback(Document, Document)Called when the element is adopted into another document.
AttributeChangedCallback(string, string?, string?, string?)Called when an attribute listed in CustomElementConstructor.ObservedAttributes is added, changed, removed or replaced.
ConnectedCallback()Called when the element becomes connected.
ConnectedMoveCallback()Called when the element is moved with moveBefore(). The default implementation calls CustomElement.DisconnectedCallback, then CustomElement.ConnectedCallback.
DisconnectedCallback()Called when the element becomes disconnected.
FormAssociatedCallback(HtmlFormElement?)Called when the form owner of a form-associated custom element changes.
FormDisabledCallback(bool)Called when the disabled state of a form-associated custom element changes.
FormResetCallback()Called when the form owner of a form-associated custom element is reset.
FormStateRestoreCallback(object?, string)Called to restore the state of a form-associated custom element (mode is "restore" or "autocomplete"). The library never restores states.

AdoptedCallback(Document, Document)

CustomElementConstructor.cs

Called when the element is adopted into another document.

protected internal virtual void AdoptedCallback(Document oldDocument, Document newDocument)

Parameters

oldDocument Document
newDocument Document

AttributeChangedCallback(string, string?, string?, string?)

CustomElementConstructor.cs

Called when an attribute listed in CustomElementConstructor.ObservedAttributes is added, changed, removed or replaced.

protected internal virtual void AttributeChangedCallback(string name, string? oldValue, string? newValue, string? @namespace)

Parameters

name string
oldValue string?
newValue string?
namespace string?

ConnectedCallback()

CustomElementConstructor.cs

Called when the element becomes connected.

protected internal virtual void ConnectedCallback()

ConnectedMoveCallback()

CustomElementConstructor.cs

Called when the element is moved with moveBefore(). The default implementation calls CustomElement.DisconnectedCallback, then CustomElement.ConnectedCallback.

protected internal virtual void ConnectedMoveCallback()

DisconnectedCallback()

CustomElementConstructor.cs

Called when the element becomes disconnected.

protected internal virtual void DisconnectedCallback()

FormAssociatedCallback(HtmlFormElement?)

CustomElementConstructor.cs

Called when the form owner of a form-associated custom element changes.

protected internal virtual void FormAssociatedCallback(HtmlFormElement? form)

Parameters

form HtmlFormElement?

FormDisabledCallback(bool)

CustomElementConstructor.cs

Called when the disabled state of a form-associated custom element changes.

protected internal virtual void FormDisabledCallback(bool disabled)

Parameters

disabled bool

FormResetCallback()

CustomElementConstructor.cs

Called when the form owner of a form-associated custom element is reset.

protected internal virtual void FormResetCallback()

FormStateRestoreCallback(object?, string)

CustomElementConstructor.cs

Called to restore the state of a form-associated custom element (mode is "restore" or "autocomplete"). The library never restores states.

protected internal virtual void FormStateRestoreCallback(object? state, string mode)

Parameters

state object?
mode string