Skip to content

Commit 12864cf

Browse files
sghoweriEvanLovely
authored andcommitted
fix: add check for contains method to prevent error from getting thrown in IE11 (#566)
1 parent 72bf670 commit 12864cf

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

packages/components/bolt-icon/src/icon.standalone.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ export class BoltIcon extends withPreact(withComponent()) {
6565
* The container with the class change contains this particular icon element so
6666
* we should double-check the color contrast values.
6767
*/
68-
if (data.target.contains(elem)) {
69-
const recalculatedSecondaryColor = colorContrast(
70-
rgb2hex(window.getComputedStyle(elem).getPropertyValue('color')),
71-
);
72-
73-
elem.setAttribute('contrast-color', recalculatedSecondaryColor);
74-
elem.state.secondaryColor = recalculatedSecondaryColor;
68+
if (data.target.contains) {
69+
if (data.target.contains(elem)) {
70+
const recalculatedSecondaryColor = colorContrast(
71+
rgb2hex(window.getComputedStyle(elem).getPropertyValue('color')),
72+
);
73+
74+
elem.setAttribute('contrast-color', recalculatedSecondaryColor);
75+
elem.state.secondaryColor = recalculatedSecondaryColor;
76+
}
7577
}
7678
};
7779

@@ -136,7 +138,7 @@ export class BoltIcon extends withPreact(withComponent()) {
136138
{background && size === 'xlarge' &&
137139
<span className={backgroundClasses}></span>
138140
}
139-
</div>
141+
</div>
140142
);
141143
}
142144
}

0 commit comments

Comments
 (0)