Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Web Component Examples - Include A Template Inline

Not sure if this is a good idea or not, but the goal is to have not have to put the [TODO: Code shorthand span ] on the page, just the call the to component

JavaScript

customElements.define(
  "my-widget",
  class extends HTMLElement {
    constructor() {
      super();
      let template = document.createElement("template");
      template.innerHTML = `<p>This is a new template</p>`
      let templateContent = template.content;
      const shadowRoot = this.attachShadow({ mode: "open" });
      shadowRoot.appendChild(templateContent.cloneNode(true));
    }
  },
);