Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Fix coverage to work in IE8
Browse files Browse the repository at this point in the history
IE8 has a bit differrent CCSOM structure
  • Loading branch information
Sergey Tatarintsev committed Feb 4, 2015
1 parent ff44216 commit b932091
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/browser/client-scripts/gemini.coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,29 @@
sheets = document.styleSheets;
try {
for (var i = 0; i < sheets.length; i++) {
var rules = sheets[i].cssRules,
var rules = sheets[i].cssRules || sheets[i].rules,
ctx = {
// media rule counter
// coverage for media rules is stored by its index within stylesheet
media: -1,
href: sheets[i].href,
coverage: coverage
};
for (var r = 0; r < rules.length; r++) {
coverageRule(rules[r], rect, ctx);
coverageForRule(rules[r], rect, ctx);
}
}
} catch (e) {
return {
error: 'JS',
message: e.stack
message: e.stack || e.message
};
}

return coverage;
};

function coverageRule(rule, area, ctx) {
function coverageForRule(rule, area, ctx) {
if (rule.cssRules || rule.styleSheet) {
if (rule.conditionText) {
ctx.media++;
Expand All @@ -40,7 +41,7 @@

var rules = rule.cssRules || rule.styleSheet.cssRules;
for (var r = 0; r < rules.length; r++) {
coverageRule(rules[r], area, ctx);
coverageForRule(rules[r], area, ctx);
}

return;
Expand Down Expand Up @@ -77,7 +78,7 @@
}
}

var byfile = ctx.coverage[rule.parentStyleSheet.href] = ctx.coverage[rule.parentStyleSheet.href] || {};
var byfile = ctx.coverage[ctx.href] = ctx.coverage[ctx.href] || {};
if (rule.parentRule && rule.parentRule.conditionText) {
selector = '?' + ctx.media + ':' + selector;
}
Expand Down

0 comments on commit b932091

Please sign in to comment.