Skip to content

Commit 5316b97

Browse files
committed
Add fillType to all rules, simplify more of the things that branch based on it.
1 parent eaae6b4 commit 5316b97

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

parser.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ function parse(tokens) {
2626
};
2727
var switchto = function(newmode) {
2828
if(newmode === undefined) {
29-
if(rule.ruleType == 'SELECTOR-RULE' || (rule.ruleType == 'AT-RULE' && rule.fillType == 'declaration'))
30-
mode = 'declaration';
31-
else if(rule.ruleType == 'AT-RULE' && rule.fillType == 'rule')
32-
mode = 'rule';
29+
if(rule.fillType !== '')
30+
mode = rule.fillType;
3331
else if(rule.ruleType == 'STYLESHEET')
3432
mode = 'top-level'
3533
else { console.log("Unknown rule-type while switching to current rule's content mode: ",rule); mode = ''; }
@@ -247,6 +245,7 @@ function parse(tokens) {
247245
}
248246

249247
function CSSParserRule() { return this; }
248+
CSSParserRule.prototype.fillType = '';
250249
CSSParserRule.prototype.toString = function(indent) {
251250
return JSON.stringify(this.toJSON(),null,indent);
252251
}
@@ -271,8 +270,6 @@ function AtRule(name) {
271270
this.value = [];
272271
if(name in AtRule.registry)
273272
this.fillType = AtRule.registry[name];
274-
else
275-
this.fillType = '';
276273
return this;
277274
}
278275
AtRule.prototype = new CSSParserRule;
@@ -306,6 +303,7 @@ function StyleRule() {
306303
}
307304
StyleRule.prototype = new CSSParserRule;
308305
StyleRule.prototype.ruleType = "SELECTOR-RULE";
306+
StyleRule.prototype.fillType = 'declaration';
309307
StyleRule.prototype.appendSelector = function(val) {
310308
this.selector.push(val);
311309
return this;

0 commit comments

Comments
 (0)