Skip to content

Commit 0514825

Browse files
github-actions[bot]Repo AssistCopilotdsyme
authored
Fix #1383: Throw NotSupportedException for unrecognized CSS pseudo-classes (#1613)
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: Repo Assist <repo-assist@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Don Syme <dsyme@users.noreply.github.com>
1 parent c0d22d1 commit 0514825

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/FSharp.Data.Html.Core/HtmlCssSelectors.fs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ module internal HtmlCssSelectors =
178178
| StartsWith ":enabled" t -> tokenize' (Enabled(getOffset t + 1) :: acc) t
179179
| StartsWith ":file" t -> tokenize' (File(getOffset t + 1) :: acc) t
180180
| StartsWith ":submit" t -> tokenize' (Submit(getOffset t + 1) :: acc) t
181+
| ':' :: t ->
182+
let s, _ = readString "" t
183+
184+
raise (
185+
NotSupportedException(
186+
sprintf
187+
"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."
188+
s
189+
)
190+
)
181191

182192
| '>' :: t ->
183193
let seqtoken = acc |> List.toSeq |> Seq.skip (1) |> Seq.toList

0 commit comments

Comments
 (0)