From dd10ac499e8517a41026795896af4e84960a082b Mon Sep 17 00:00:00 2001 From: Repo Assist Date: Sun, 22 Feb 2026 17:37:34 +0000 Subject: [PATCH] Fix #1383: Throw NotSupportedException for unrecognized CSS pseudo-classes Instead of the misleading 'Invalid css selector syntax' error, throw NotSupportedException with a descriptive message when an unrecognized CSS pseudo-class or pseudo-element (e.g. :nth-child, :first-child) is encountered. This makes it clear the syntax is valid CSS but not yet implemented in FSharp.Data's CSS selector engine. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/FSharp.Data.Html.Core/HtmlCssSelectors.fs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/FSharp.Data.Html.Core/HtmlCssSelectors.fs b/src/FSharp.Data.Html.Core/HtmlCssSelectors.fs index 4c894532e..ff8e9cead 100644 --- a/src/FSharp.Data.Html.Core/HtmlCssSelectors.fs +++ b/src/FSharp.Data.Html.Core/HtmlCssSelectors.fs @@ -178,6 +178,16 @@ module internal HtmlCssSelectors = | StartsWith ":enabled" t -> tokenize' (Enabled(getOffset t + 1) :: acc) t | StartsWith ":file" t -> tokenize' (File(getOffset t + 1) :: acc) t | StartsWith ":submit" t -> tokenize' (Submit(getOffset t + 1) :: acc) t + | ':' :: t -> + let s, _ = readString "" t + + raise ( + NotSupportedException( + sprintf + "CSS pseudo-class or pseudo-element ':%s' is not supported. See https://fsprojects.github.io/FSharp.Data/library/HtmlCssSelectors.html for the list of supported selectors." + s + ) + ) | '>' :: t -> let seqtoken = acc |> List.toSeq |> Seq.skip (1) |> Seq.toList