Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

then you may be able to do things like this I think

  <mesh-card id="card-123" hx-swap-oob="true">
    <template shadowrootmode="open">
      <link rel="stylesheet" href="/static/css/components/card.css" />
      <div class="card">
        <div class="card-header">
          <h3>Updated Card Title</h3>
        </div>
        <div class="card-content">
          Updated card description here.
        </div>
        <div class="actions">
          <button type="button">Edit</button>
        </div>
      </div>
    </template>
  </mesh-card>

  class MeshCard extends HTMLElement {
    connectedCallback() {
      if (!this.shadowRoot) {
        const tmpl = this.querySelector('template[shadowrootmode="open"]');
        if (tmpl) {
          this.attachShadow({mode: 'open'})
            .appendChild(tmpl.content.cloneNode(true));
        }
      }
    }
  }

  customElements.define('mesh-card', MeshCard);


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: