Skip to content

Commit 15b2a10

Browse files
committed
Check theme class name presence on the <body>
1 parent 1976c6d commit 15b2a10

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/_pub_shared/lib/validation/html/html_validation.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ void validateHtml(Node root) {
192192
throw AssertionError(
193193
'<$tag> tag should not have role attribute, found: ${elem.outerHtml}');
194194
}
195+
196+
// body always has one of the theme classes
197+
final body = querySelectorAll('body').singleOrNull;
198+
if (body != null) {
199+
final classes = body.classes.toSet();
200+
if (!classes.contains('light-theme') && !classes.contains('dark-theme')) {
201+
throw AssertionError(
202+
'<body> must contain either `light-theme` or `dark-theme`');
203+
}
204+
}
195205
}
196206

197207
/// "Google Search result usually points to the canonical page, unless one of

0 commit comments

Comments
 (0)