Skip to content

Documentation text and sample are inconsistent: parentheses around RegExp literals #9022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alecglassford opened this issue Jul 22, 2023 · 1 comment · Fixed by #9027
Closed

Comments

@alecglassford
Copy link

alecglassford commented Jul 22, 2023

Describe the bug

On https://svelte.dev/docs/basic-markup#text-expressions (source markdown), there is an aside that reads:

If you're using a regular expression (RegExp) literal notation, you'll need to wrap it in parentheses.

This is followed by a markup sample:

<div>{/^[A-Za-z ]+$/.test(value) ? x : y}</div>

Note that in the sample, the RegExp literal is not wrapped in parentheses. Therefore this section of the doc becomes confusing to users: do you need to wrap RegExp literals in parentheses or not?

Reproduction

Navigate to https://svelte.dev/docs/basic-markup#text-expressions

Logs

N/A

System Info

N/A

Severity

annoyance

@alecglassford
Copy link
Author

A little digging, in case it's helpful:

This part of the doc was added in #5640, and you'll see in this PR that the RegExp literal in the sample originally was wrapped in parentheses:

<div>{(/^[A-Za-z ]+$/).test(value) ? x : y}</div>

The parentheses were later removed in #8435 (specifically in this squashed commit).

  • If the parentheses removal was purposeful, then the (now-outdated) aside text should also be removed.
  • If the parentheses removal was accidental, then the parentheses should likely be added back to the sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant