Skip to content

Commit

Permalink
fix(utils): add try and catch for computedStyle (#7214)
Browse files Browse the repository at this point in the history
  • Loading branch information
weiz18 authored May 11, 2021
1 parent 06cdb6f commit 90ce2d7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/js/utils/computed-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ function computedStyle(el, prop) {
}

if (typeof window.getComputedStyle === 'function') {
const computedStyleValue = window.getComputedStyle(el);
let computedStyleValue;

try {
computedStyleValue = window.getComputedStyle(el);
} catch (e) {
return '';
}

return computedStyleValue ? computedStyleValue.getPropertyValue(prop) || computedStyleValue[prop] : '';
}
Expand Down

0 comments on commit 90ce2d7

Please sign in to comment.