<commit_before><template id=header-group>

<style>

  header-group
    { display: block }

  header-group
    hgroup
      { background: #bada55; color: var(--darkest-color) }

</style>

<hgroup>
  <h1><a href=/examples/index.html>snuggsi ツ</a></h1>
  <slot name=header><h2>try an example</h2></slot>
</hgroup>

</template>

<script>
const tag = `header-group`

Element `header-group`

(class extends HTMLElement {

  static onimportload (event) {
    let template = event.target.import
      .querySelector ('template')

      document
        .querySelector('head')
        .appendChild (template)

      // possibly should be adopting node into document
      // and should do it on DOMContentLoaded hook up onimportload

    const shadow = function (element) {
      let fragment = template.content.cloneNode (true)

      fragment.slots =
        Array.from (fragment.querySelectorAll ('slot'))

      element.slots =
        Array.from (element.querySelectorAll ('[slot]'))

      element.slots.map (function (namedslot) {
        fragment.slots
          .filter (slot =>
            (slot.getAttribute ('name') === namedslot.getAttribute ('slot'))
          )
          .map (slot => {
            slot.innerHTML = ''
            , slot.appendChild (namedslot)
          })
      })

      element.innerHTML = ''
      element.append (fragment)
    }

    Array.from
      // should be using currentScript ?
      (document.getElementsByTagName (tag))
      .map (shadow)
  }

  initialize () {
    const selector = `link#${tag}, link[href*='${tag}']`
    const link = document
      .querySelector (selector)

    ! link.onload &&
    !! (link.onload = this.constructor.onimportload.bind (this))
  }
})

</script>
<commit_msg>Replace slot due to uncertainty @brandondees https://github.com/devpunks/snuggsi/pull/23/files#r113990636<commit_after><template id=header-group>

<style>

  header-group
    { display: block }

  header-group
    hgroup
      { background: #bada55; color: var(--darkest-color) }

</style>

<hgroup>
  <h1><a href=/examples/index.html>snuggsi ツ</a></h1>
  <slot name=header><h2>try an example</h2></slot>
</hgroup>

</template>

<script>
const tag = `header-group`

Element `header-group`

(class extends HTMLElement {

  static onimportload (event) {
    let template = event.target.import
      .querySelector ('template')

      document
        .querySelector('head')
        .appendChild (template)

      // possibly should be adopting node into document
      // and should do it on DOMContentLoaded hook up onimportload

    const shadow = function (element) {
      let fragment = template.content.cloneNode (true)

      fragment.slots =
        Array.from (fragment.querySelectorAll ('slot'))

      element.slots =
        Array.from (element.querySelectorAll ('[slot]'))

      element.slots.map (function (namedslot) {
        fragment.slots
          .filter (slot =>
            (slot.getAttribute ('name') === namedslot.getAttribute ('slot'))
          )
          .map (slot =>
            // Replace slot due to uncertainty
            // https://github.com/devpunks/snuggsi/pull/23/files#r113990636

            // prefer to use replaceWith however support is sparse
            // https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/replaceWith
            // using `Node.parentNode` & `Node.replaceChid` as is defined in (ancient) W3C DOM Level 1,2,3
            // https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode
            // https://developer.mozilla.org/en-US/docs/Web/API/Node/replaceChild

            slot.parentNode
              .replaceChild (namedslot, slot)
          )
      })

      element.innerHTML = ''
      element.append (fragment)
    }

    Array.from
      // should be using currentScript ?
      (document.getElementsByTagName (tag))
      .map (shadow)
  }

  initialize () {
    const selector = `link#${tag}, link[href*='${tag}']`
    const link = document
      .querySelector (selector)

    ! link.onload &&
    !! (link.onload = this.constructor.onimportload.bind (this))
  }
})

</script>

{'fraction_non_alphanumeric': 0.13373934226552983, 'fraction_numerical': 0.00925700365408039, 'mean_word_length': 2.3990066225165565, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 39, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2457146', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1233, 'n_words': 272}