export default class HoytSecondary extends HTMLElement { constructor() { super(); const template = document.createElement( 'template' ); template.innerHTML = /* template */ `
`; // Root this.attachShadow( {mode: 'open'} ); this.shadowRoot.appendChild( template.content.cloneNode( true ) ); } // When attributes change _render() {;} // Promote properties // Values may be set before module load _upgrade( property ) { if( this.hasOwnProperty( property ) ) { const value = this[property]; delete this[property]; this[property] = value; } } // Setup connectedCallback() { this._upgrade( 'open' ); this._render(); } // Watched attributes static get observedAttributes() { return [ 'open' ]; } // Observed attribute has changed // Update render attributeChangedCallback( name, old, value ) { this._render(); } // Attributes // Reflected // Boolean, Number, String, null get open() { return this.hasAttribute( 'open' ); } set open( value ) { if( value !== null ) { if( typeof value === 'boolean' ) { value = value.toString(); } if( value === 'false' ) { this.removeAttribute( 'open' ); } else { this.setAttribute( 'open', '' ); } } else { this.removeAttribute( 'open' ); } } } window.customElements.define( 'hoyt-secondary', HoytSecondary );