Skip to content

Commit

Permalink
Fix shadowdom in Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
maxatdetroit committed Oct 5, 2023
1 parent a00d048 commit 9556640
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/atoms/Icon/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit 9556640

Please sign in to comment.