{"size": 1660, "ext": "js", "max_stars_repo_path": "src/crossref.js", "max_stars_repo_name": "gotchoices/wylib", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/crossref.js", "max_issues_repo_name": "gotchoices/wylib", "max_issues_repo_issues_event_min_datetime": "2019-12-26T20:08:43.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-14T01:12:00.000Z", "max_forks_repo_path": "src/crossref.js", "max_forks_repo_name": "gotchoices/wylib", "max_forks_repo_forks_event_min_datetime": "2019-11-07T02:17:25.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-07T02:17:25.000Z"}
{"max_stars_count": null, "max_issues_count": 22, "max_forks_count": 1, "avg_line_length": 31.320754717, "max_line_length": 100, "alphanum_fraction": 0.6271084337}
//Class for supporting a custom cross-reference HTML tag
//Copyright WyattERP.org: See LICENSE in the root of this package
// -----------------------------------------------------------------------------
//- TODO:
//- 
const Attrs = ['name', 'value']
module.exports = class extends HTMLElement {
  static get observedAttributes() {return Attrs}
  
  constructor() {
    super()
//console.log('xConst n:', this.name, 'v:', this.value)
    Attrs.forEach(att=>{		//Establish attribute setters/getters
      Object.defineProperty(this, att, {
        get: function() {return this.getAttribute(att)},
        set: function(val) {
          if (val) this.setAttribute(att, val); else this.removeAttribute(att)
        }
      })
    })
    let shadowRoot = this.attachShadow({mode: 'open'})
      , shadowSpan = document.createElement('span')	//Our actual display element
    shadowRoot.appendChild(shadowSpan)
    this.update()
  }
  
  update() {
    let dispEl = this.shadowRoot.firstChild
    if (this.value)
      dispEl.innerText = this.value
    else
      dispEl.innerHTML = this.innerHTML
  }

  connectedCallback() {
    let ev = new CustomEvent('connect', {bubbles: true, detail: {name:this.name, value:this.value}})
//console.log('xConn n:', this.name, 'v:', this.value)
    this.update()
    this.dispatchEvent(ev)
  }

  disconnectedCallback() {
//console.log('xDisc n:', this.name, 'v:', this.value)
  }

  attributeChangedCallback(attrName, oldValue, newValue) {
    let ev = new CustomEvent('change', {detail: {attrName, newValue, oldValue}})
//console.log('xChange', attrName, oldValue, newValue)
    this.update()
    this.dispatchEvent(ev)
  }
}
