diff --git a/index.js b/index.js index cb47369..0c6d087 100644 --- a/index.js +++ b/index.js @@ -1,17 +1,17 @@ /* eslint no-undef: 0 */ class WCInclude extends HTMLElement { static get observedAttributes () { - return ['src']; + return ['src'] } attributeChangedCallback (name, oldValue, newValue) { - if (!this.__initialized) { return; } + if (!this.__initialized) { return } if (oldValue !== newValue) { this[name] = newValue; } } - get src () { return this.getAttribute('src'); } + get src () { return this.getAttribute('src') } set src (value) { this.setAttribute('src', value); this.setSrc(); @@ -46,7 +46,7 @@ class WCInclude extends HTMLElement { async fetchSrc (src) { const response = await fetch(src); - return response.text(); + return response.text() } } diff --git a/src/wc-include.js b/src/wc-include.js index 2dba1a9..74f223f 100644 --- a/src/wc-include.js +++ b/src/wc-include.js @@ -1,53 +1,53 @@ /* eslint no-undef: 0 */ export class WCInclude extends HTMLElement { static get observedAttributes () { - return ['src']; + return ['src'] } attributeChangedCallback (name, oldValue, newValue) { - if (!this.__initialized) { return; } + if (!this.__initialized) { return } if (oldValue !== newValue) { - this[name] = newValue; + this[name] = newValue } } - get src () { return this.getAttribute('src'); } + get src () { return this.getAttribute('src') } set src (value) { - this.setAttribute('src', value); - this.setSrc(); + this.setAttribute('src', value) + this.setSrc() } constructor () { - super(); - this.__initialized = false; - this.__element = null; - const shadow = this.hasAttribute('shadow'); + super() + this.__initialized = false + this.__element = null + const shadow = this.hasAttribute('shadow') if (shadow) { - this.attachShadow({ mode: 'open' }); + this.attachShadow({ mode: 'open' }) } this.__element = shadow ? this.shadowRoot - : this; + : this } async connectedCallback () { if (this.hasAttribute('src')) { - this.setSrc(); + this.setSrc() } - this.__initialized = true; + this.__initialized = true } async setSrc () { - const src = this.getAttribute('src'); - const contents = await this.fetchSrc(src); - this.__element.innerHTML = contents; + const src = this.getAttribute('src') + const contents = await this.fetchSrc(src) + this.__element.innerHTML = contents } async fetchSrc (src) { - const response = await fetch(src); - return response.text(); + const response = await fetch(src) + return response.text() } } -customElements.define('wc-include', WCInclude); +customElements.define('wc-include', WCInclude)