diff --git a/org/w3c/css/atrules/css3/AtRuleMedia.java b/org/w3c/css/atrules/css3/AtRuleMedia.java index b2ea0d81..654eafd3 100644 --- a/org/w3c/css/atrules/css3/AtRuleMedia.java +++ b/org/w3c/css/atrules/css3/AtRuleMedia.java @@ -80,7 +80,13 @@ public org.w3c.css.atrules.css.AtRuleMedia addMedia(String restrictor, String me */ public void addMediaFeature(MediaFeature feature, ApplContext ac) throws InvalidParamException { - Media latest = allMedia.get(allMedia.size() - 1); + Media latest; + if (allMedia.isEmpty()) { + latest = new Media(); + allMedia.add(latest); + } else { + latest = allMedia.get(allMedia.size() - 1); + } latest.addFeature(feature); }