Skip to content

Allow custom element names in conformance with the current spec requirements #1953

@AndySky21

Description

@AndySky21

Spec URL

https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name | https://dom.spec.whatwg.org/#valid-element-local-name

Test case

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" dir="ltr">
<head>
  <meta charset="UTF-8"/>
  <title>Custom Element Demo</title>
</head>
<body>
  <andy-custom:menu></andy-custom:menu>

  <script>
    class AndyCustomMenu extends HTMLElement {
      constructor() {
        super();
        this.attachShadow({ mode: "open" });
        this.shadowRoot.innerHTML = `
          <style>
            div {
              padding: 10px;
              background: #eef;
              border: 1px solid #99c;
              font-family: sans-serif;
            }
          </style>
          <div>Menu personalizzato</div>
        `;
      }
    }

    // Registrazione del custom element
    customElements.define("andy-custom:menu", AndyCustomMenu);
  </script>
</body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions