Skip to content
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

fix: potential SyntaxError for generated id from markdown h1..h6 #1961

Merged
merged 1 commit into from
Mar 21, 2023

Conversation

electrolinux
Copy link
Contributor

Improve the way id are generated from markdown for h1 .. h6 tags

πŸ”— Linked issue

See #1960

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • [x ] 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Prevent a markdown id generated (for h1..h6 headings) to throw a SyntaxError when used in
document.querySelector() when such id start with a digit

Resolves #1960

See also:

πŸ“ Checklist

  • [ x] I have linked an issue or discussion.
  • I have updated the documentation accordingly.

…a digit

See http://calixe.fr/global_id.html for a demo:

* html works well with such id
* querySelector() thow a SyntaxError
@codesandbox
Copy link

codesandbox bot commented Mar 10, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@netlify
Copy link

netlify bot commented Mar 10, 2023

βœ… Deploy Preview for nuxt-content canceled.

Built without sensitive environment variables

Name Link
πŸ”¨ Latest commit f9f507a
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt-content/deploys/640b7b1797f9b80008d6d6a3

@atinux atinux requested a review from farnabaz March 13, 2023 08:47
Copy link
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@farnabaz farnabaz merged commit 884f5d8 into nuxt:main Mar 21, 2023
@electrolinux electrolinux deleted the fix-invalid-id-for-querySelector branch March 21, 2023 14:33
@farnabaz farnabaz mentioned this pull request Apr 19, 2023
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 this pull request may close these issues.

Generated id for headings are not working with document.querySelector() if starting with digit
2 participants