I have a custom element with attributes:
class MyElement extends HTMLElement {
...
static get observedAttributes() {
return ["camelCaseAttribute"];
}
set camelCaseAttribute(a) {
this._a = a;
}
...
}
I use it in my HTML like so:
<my-element camelCaseAttribute="blubb"></my-element>
The attribute camelCaseAttribute
is not set when writing it in camelCase, but writing it without upper-case-letters works. Why?
Form-associated custom elements # You can use the event-based API with any kind of component, but it only allows you to interact with the submission process. Standardized form controls participate in many parts of the form lifecycle besides submission.
Autonomous custom elements are new HTML tags, defined entirely by the author. They have none of the semantics of existing HTML elements, so all behaviors need to be defined by the author. Customized built-ins extend existing HTML elements with custom functionality. They inherit semantics from the elements they extend.
Custom Elements are a feature of modern browsers which allow you to modularise and install your JavaScript components into the browser itself in order to extend it in new and powerful ways. Custom Elements are HTML components which have their own self-contained markup, styling and behaviour.
In the HTML Living Standard, Section 4.13.3 Core Concepts:
4.13.3 Core concepts
Any namespace-less attribute that is relevant to the element's functioning, as determined by the element's author, may be specified on an autonomous custom element, so long as the attribute name is XML-compatible and contains no ASCII upper alphas. The exception is the
is
attribute, which must not be specified on an autonomous custom element (and which will have no effect if it is).
It is defined in the HTML Living Standard that a custom element's namespace-less attributes must be XML-compatible with no ASCII uppercase letters, thus your attributes cannot be camelCased.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With