Skip to content

Commit de91519

Browse files
committed
add a default media if the list is empty and a mediafeature is about to be added
1 parent 27c550c commit de91519

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

org/w3c/css/atrules/css3/AtRuleMedia.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ public org.w3c.css.atrules.css.AtRuleMedia addMedia(String restrictor, String me
8080
*/
8181
public void addMediaFeature(MediaFeature feature, ApplContext ac)
8282
throws InvalidParamException {
83-
Media latest = allMedia.get(allMedia.size() - 1);
83+
Media latest;
84+
if (allMedia.isEmpty()) {
85+
latest = new Media();
86+
allMedia.add(latest);
87+
} else {
88+
latest = allMedia.get(allMedia.size() - 1);
89+
}
8490
latest.addFeature(feature);
8591
}
8692

0 commit comments

Comments
 (0)