LibJS+LibWebView: Treat trivia tokens as comments

Trivia is whatever whitespace and comments appear before a token.
Previously this was always given a TokenCategory of Invalid, so it
would be displayed as an error in the view-source page, with red wiggly
underlines. Instead, treat it as what it actually is: whitespace and
comments!
This commit is contained in:
Sam Atkins 2025-03-04 16:36:34 +00:00 committed by Tim Flynn
commit 9b7fb0850d
Notes: github-actions[bot] 2025-03-04 20:59:17 +00:00
3 changed files with 5 additions and 1 deletions

View file

@ -205,6 +205,8 @@ StringView SourceHighlighterClient::class_for_token(u64 token_type) const
switch (category) {
case JS::TokenCategory::Invalid:
return "invalid"sv;
case JS::TokenCategory::Trivia:
return "comment"sv;
case JS::TokenCategory::Number:
return "number"sv;
case JS::TokenCategory::String: