From de9151942312052671b00898b59421ed4dd44c62 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 23 Apr 2024 18:26:02 +0200 Subject: [PATCH] add a default media if the list is empty and a mediafeature is about to be added --- org/w3c/css/atrules/css3/AtRuleMedia.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/org/w3c/css/atrules/css3/AtRuleMedia.java b/org/w3c/css/atrules/css3/AtRuleMedia.java index b2ea0d816..654eafd3b 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); }