DEV Community

artydev
artydev

Posted on

1

The Validity of Custom Element Tag Names

Jim Nielsen, in his article shows a nice way to test the validity of element tag names:

<my-custom-element>&lt;my-custom-element&gt;</my-custom-element>
<capital-LETTERS>&lt;capital-LETTERS&gt;</capital-LETTERS>
<with-per.iod>&lt;with-per.iod&gt;</with-per.iod>
<with-digit0>&lt;with-digit0&gt;</with-digit0>
<my-0.02>&lt;my-0.02&gt;</my-0.02>
<my-$0.02>&lt;my-$0.02&gt;</my-$0.02>
<my-2¢>&lt;my-2¢&gt;</my-2¢>
<branded-element>&lt;branded-element™&gt;</branded-element>
<emotion-😍>&lt;emotion-😍&gt;</emotion-😍>
<dont-use-or-we-sue©>
Enter fullscreen mode Exit fullscreen mode
body {
  font-family: monospace;
  display: flex;
  flex-direction: column;
  margin: 50px;
  font-size: 1.5em;
}
Enter fullscreen mode Exit fullscreen mode
[
  "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>`;
      }
    }
  );
});

Enter fullscreen mode Exit fullscreen mode

Demo

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more