Describe the bug
When an In-Page Navigation component includes links which start with a number, clicking on those links does not navigate to the relevant section, and instead logs a JavaScript error to the console.
Example:
Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '#1-check-your-current-uswds-code-and-settings-versions-2' is not a valid selector.
This is likely related to #5068, which added the dynamically-created links based on heading content.
The reason for the error is likely due to CSS syntax restrictions, which prevent an selector ID from beginning with a number:
In CSS, identifiers (including element names, classes, and IDs in selectors) [...] cannot start with a digit, two hyphens, or a hyphen followed by a digit.
https://www.w3.org/TR/CSS2/syndata.html#value-def-identifier
Steps to reproduce the bug
- Go to https://designsystem.digital.gov/documentation/migration/
- Click a link in the In-Page Navigation
Expected Behavior
Page scrolls to the relevant section
Related code
No response
Screenshots
No response
System setup
- USWDS version: 3.4.1
- Operating system: macOS 12.6.3
- Browser: Chrome Version 111.0.5563.110 (Official Build) (arm64)
Additional context
No response
Code of Conduct
Describe the bug
When an In-Page Navigation component includes links which start with a number, clicking on those links does not navigate to the relevant section, and instead logs a JavaScript error to the console.
Example:
This is likely related to #5068, which added the dynamically-created links based on heading content.
The reason for the error is likely due to CSS syntax restrictions, which prevent an selector ID from beginning with a number:
https://www.w3.org/TR/CSS2/syndata.html#value-def-identifier
Steps to reproduce the bug
Expected Behavior
Page scrolls to the relevant section
Related code
No response
Screenshots
No response
System setup
Additional context
No response
Code of Conduct