Jim Nielsen, in his article shows a nice way to test the validity of element tag names:
<my-custom-element>❌ <my-custom-element></my-custom-element>
<capital-LETTERS>❌ <capital-LETTERS></capital-LETTERS>
<with-per.iod>❌ <with-per.iod></with-per.iod>
<with-digit0>❌ <with-digit0></with-digit0>
<my-0.02>❌ <my-0.02></my-0.02>
<my-$0.02>❌ <my-$0.02></my-$0.02>
<my-2¢>❌ <my-2¢></my-2¢>
<branded-element™>❌ <branded-element™></branded-element™>
<emotion-😍>❌ <emotion-😍></emotion-😍>
<dont-use-or-we-sue©>
body {
font-family: monospace;
display: flex;
flex-direction: column;
margin: 50px;
font-size: 1.5em;
}
[
"my-custom-element",
"capital-letters",
"with-per.iod",
"with-digit0",
"my-0.02",
"my-$0.02",
"branded-element™️",
"emotion-😍",
"dont-use-or-we-sue©"
].forEach((str) => {
customElements.define(
str,
class extends HTMLElement {
connectedCallback() {
this.innerHTML = `✅ <code>${this.tagName.toLowerCase()}</code>`;
}
}
);
});
Top comments (0)