CustomElementConstructor Class
A custom element constructor (https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-constructor), passed to CustomElementRegistry.Define.
public class CustomElementConstructorRemarks
In a browser, a custom element is an instance of a class that extends HTMLElement, and an upgrade changes the prototype of an existing element. A .NET object cannot change its type, so the element is always created by the library (an HtmlElement, or the element interface of the extended element for a customized built-in element), and the constructor creates a CustomElement attached to the element: its virtual methods are the lifecycle callbacks, and HtmlElement.CustomElement returns it. The static members of a JavaScript custom element class (observedAttributes, disabledFeatures, formAssociated) are properties of the constructor, read once by Define.
See also
Constructors
| Name | Description |
|---|---|
| CustomElementConstructor(Func<HtmlElement, CustomElement>) | Creates a constructor that attaches the object returned by factory to the elements it constructs. |
CustomElementConstructor(Func<HtmlElement, CustomElement>)
CustomElementConstructor.csCreates a constructor that attaches the object returned by factory to the elements it constructs.
public CustomElementConstructor(Func<HtmlElement, CustomElement> factory)Parameters
factoryFunc<HtmlElement, CustomElement>- Creates the
CustomElementof an element, when the element is created (e.g.createElement(), the HTML parser) or upgraded. It must pass the element to the constructor ofCustomElement. As in a JavaScript constructor, it must not add attributes or children to the element.
Properties
| Name | Description |
|---|---|
| DisabledFeatures | Gets the disabled features: "internals" disables attachInternals(), "shadow" disables attachShadow(). |
| FormAssociated | Gets whether the elements are form-associated custom elements (the static formAssociated property of a JavaScript custom element class). |
| ObservedAttributes | Gets the names of the attributes whose changes invoke CustomElement.AttributeChangedCallback (the static observedAttributes property of a JavaScript custom element class). |
DisabledFeatures
CustomElementConstructor.csGets the disabled features: "internals" disables attachInternals(), "shadow" disables attachShadow().
public IReadOnlyCollection<string> DisabledFeatures { get; init; }Property value
FormAssociated
CustomElementConstructor.csObservedAttributes
CustomElementConstructor.csGets the names of the attributes whose changes invoke CustomElement.AttributeChangedCallback (the static observedAttributes property of a JavaScript custom element class).
public IReadOnlyCollection<string> ObservedAttributes { get; init; }