Skip to content

Commit

Permalink
add a default media if the list is empty and a mediafeature is about …
Browse files Browse the repository at this point in the history
…to be added
  • Loading branch information
ylafon committed Apr 23, 2024
1 parent 27c550c commit de91519
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion org/w3c/css/atrules/css3/AtRuleMedia.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

1 comment on commit de91519

@ylafon
Copy link
Member Author

@ylafon ylafon commented on de91519 Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes #406

Please sign in to comment.