Skip to content

Commit

Permalink
fix an IE bug related to Object.keys(styles) that return an empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
Olesya Kogivchak authored and Olesya Kogivchak committed Sep 14, 2020
1 parent 0be563c commit 9317673
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ export function collectStyles (element, params) {

// Loop over computed styles
const styles = win.getComputedStyle(element, '')
const styleKeys = []; // prepare keys array, because Object.keys(styles) returns empty array in IE
for (let i = 0; i < styles.length; i++) {
styleKeys.push(i);
}

Object.keys(styles).map(key => {
styleKeys.map(key => {
// Check if style should be processed
if (params.targetStyles.indexOf('*') !== -1 || params.targetStyle.indexOf(styles[key]) !== -1 || targetStylesMatch(params.targetStyles, styles[key])) {
if (styles.getPropertyValue(styles[key])) elementStyle += styles[key] + ':' + styles.getPropertyValue(styles[key]) + ';'
Expand Down

0 comments on commit 9317673

Please sign in to comment.