Skip to content

Commit ab29a6e

Browse files
jonkempNV
authored andcommitted
Fix @font-face rules nested in @media (#103)
Fixes #102
1 parent c86c123 commit ab29a6e

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

lib/parse.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ CSSOM.parse = function parse(token) {
399399
prevScope = currentScope;
400400
currentScope = parentRule;
401401
currentScope.cssRules.push(prevScope);
402-
break;
403402
}
404403

405404
if (ancestorRules.length === 0) {

spec/parse.spec.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,48 @@ var TESTS = [
676676
return result;
677677
})()
678678
},
679+
{
680+
input: "@media screen{a{color:blue !important;background:red;} @font-face { font-family: 'Arial2'; } }",
681+
result: (function() {
682+
var result = {
683+
cssRules: [
684+
{
685+
media: {
686+
0: "screen",
687+
length: 1
688+
},
689+
cssRules: [
690+
{
691+
selectorText: "a",
692+
style: {
693+
0: "color",
694+
1: "background",
695+
color: "blue",
696+
background: "red",
697+
length: 2
698+
}
699+
},
700+
{
701+
style: {
702+
0: "font-family",
703+
"font-family": "'Arial2'",
704+
length: 1
705+
}
706+
},
707+
".."
708+
],
709+
parentRule: null
710+
}
711+
],
712+
parentStyleSheet: null
713+
};
714+
result.cssRules[0].parentStyleSheet = result.cssRules[0].cssRules[0].parentStyleSheet = result.cssRules[0].cssRules[1].parentStyleSheet = result;
715+
result.cssRules[0].cssRules[0].parentRule = result.cssRules[0].cssRules[1].parentRule = result.cssRules[0];
716+
result.cssRules[0].cssRules[0].style.parentRule = result.cssRules[0].cssRules[0];
717+
result.cssRules[0].cssRules[1].style.parentRule = result.cssRules[0].cssRules[1];
718+
return result;
719+
})()
720+
},
679721
{
680722
input: "@supports (display: grid) { html { display: grid; } }",
681723
result: (function() {

0 commit comments

Comments
 (0)