Skip to content

Commit 998aced

Browse files
committed
Update consumeAListOfRules into consumeAStylesheetsContents, to match spec. Export the new functions.
1 parent 2117221 commit 998aced

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

parse-css.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ function parseerror(s, msg) {
916916
return true;
917917
}
918918

919-
function consumeAListOfRules(s, topLevel=false) {
919+
function consumeAStylesheetsContents(s) {
920920
const rules = [];
921921
while(1) {
922922
const token = s.nextToken();
@@ -925,12 +925,7 @@ function consumeAListOfRules(s, topLevel=false) {
925925
} else if(token instanceof EOFToken) {
926926
return rules;
927927
} else if(token instanceof CDOToken || token instanceof CDCToken) {
928-
if(topLevel == "top-level") {
929-
s.discardToken();
930-
} else {
931-
const rule = consumeAQualifiedRule(s);
932-
if(rule) rules.push(rule);
933-
}
928+
s.discardToken();
934929
} else if(token instanceof AtKeywordToken) {
935930
const rule = consumeAnAtRule(s)
936931
if(rule) rules.push(rule);
@@ -1207,13 +1202,18 @@ function normalizeInput(input) {
12071202
function parseAStylesheet(s) {
12081203
s = normalizeInput(s);
12091204
var sheet = new Stylesheet();
1210-
sheet.rules = consumeAListOfRules(s, "top-level");
1205+
sheet.rules = consumeAStylesheetsContents(s);
12111206
return sheet;
12121207
}
12131208

1214-
function parseAListOfRules(s) {
1209+
function parseAStylesheetsContents(s) {
1210+
s = normalizeInput(s);
1211+
return consumeAStylesheetsContents(s);
1212+
}
1213+
1214+
function parseABlocksContents(s) {
12151215
s = normalizeInput(s);
1216-
return consumeAListOfRules(s);
1216+
return consumeABlocksContents(s);
12171217
}
12181218

12191219
function parseARule(s) {
@@ -1385,7 +1385,8 @@ exports.Declaration = Declaration;
13851385
exports.SimpleBlock = SimpleBlock;
13861386
exports.Func = Func;
13871387
exports.parseAStylesheet = parseAStylesheet;
1388-
exports.parseAListOfRules = parseAListOfRules;
1388+
exports.parseAStylesheetsContents = parseAStylesheetsContents;
1389+
exports.parseABlocksContents = parseABlocksContents;
13891390
exports.parseARule = parseARule;
13901391
exports.parseADeclaration = parseADeclaration;
13911392
exports.parseAComponentValue = parseAComponentValue;

0 commit comments

Comments
 (0)