diff --git a/src/components/atoms/Icon/Icon.js b/src/components/atoms/Icon/Icon.js index 2a386526..2b0f65db 100644 --- a/src/components/atoms/Icon/Icon.js +++ b/src/components/atoms/Icon/Icon.js @@ -2,13 +2,16 @@ export default class Icon extends HTMLElement { constructor() { // Always call super first in constructor super(); - // Create a shadow root - // TODO: See CityOfDetroit/detroitmi#1099 - // eslint-disable-next-line no-unused-vars - const shadow = this.attachShadow({ mode: 'open' }); + + // Create a shadow root. + this.attachShadow({ mode: 'open' }); } connectedCallback() { + if (this.isIconConnected()) { + return; + } + // Icon attributes // TODO: See CityOfDetroit/detroitmi#1099 // eslint-disable-next-line prefer-const @@ -39,6 +42,10 @@ export default class Icon extends HTMLElement { this.shadowRoot.appendChild(iconContainer); } + isIconConnected() { + return this.shadowRoot.querySelector('span') !== null; + } + getIcon(icon, size) { switch (icon) { case 'house':