Skip to content

Commit de0e067

Browse files
authored
fix: prevent AppShellRegistry validation failure for StyleSheet.Container (#22630)
When AppShellRegistry validates offending annotation on other compoent classes it ignore the StyleSheet annotation. However, if a component has multiple StyleSheet annotations on it, the validation fails. This change also ignores StyleSheet.Container annotation during validation Fixes #22629
1 parent 6df2857 commit de0e067

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

flow-server/src/main/java/com/vaadin/flow/server/AppShellRegistry.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public String validateClass(Class<?> clz) {
176176
// StyleSheet is allowed on Components; do not treat it as an
177177
// AppShell-only annotation
178178
validOnlyForAppShell.remove(StyleSheet.class);
179+
validOnlyForAppShell.remove(StyleSheet.Container.class);
179180
if (WebComponentExporter.class.isAssignableFrom(clz)) {
180181
// Webcomponent exporter should have the theme annotation
181182
// and Push annotation as it is not appShell configured.

flow-server/src/test/java/com/vaadin/flow/server/startup/VaadinAppShellInitializerTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ public static class AppShellExtendingComponent extends Component
208208
public static class ComponentWithStylesheet extends Component {
209209
}
210210

211+
@StyleSheet("./foo1.css")
212+
@StyleSheet("./foo2.css")
213+
@StyleSheet("./foo3.css")
214+
@StyleSheet("./foo4.css")
215+
public static class ComponentWithMultipleStylesheet extends Component {
216+
}
217+
211218
@StyleSheet("context://my-styles.css")
212219
@StyleSheet("https://cdn.example.com/ui.css")
213220
public static class MyAppShellWithStyleSheets
@@ -554,6 +561,13 @@ public void styleSheetOnComponent_notOffending() throws Exception {
554561
initializer.process(classes, servletContext);
555562
}
556563

564+
@Test
565+
public void multipleStyleSheetOnComponent_notOffending() throws Exception {
566+
classes.add(ComponentWithMultipleStylesheet.class);
567+
// Should not throw as @StyleSheet is allowed on Components
568+
initializer.process(classes, servletContext);
569+
}
570+
557571
@Test
558572
public void styleSheetResolution_variousScenarios() throws Exception {
559573
classes.add(MyAppShellWithVariousStyleSheets.class);

0 commit comments

Comments
 (0)