3 ms·
I noticed that they use JavaScript to modify the hash string in the URL. Here is the probably root cause: There is an H2 heading between "Lightweight JIT compi
by low_tech_punk 3y ago
I noticed that they use JavaScript to modify the hash string in the URL. Here is the probably root cause:
There is an H2 heading between "Lightweight JIT compiler project goals" and "The current state of the MIR project". That h2 contains the Hoover Dams image and has an id generated from empty content because the content is just image: <h2 id="-h2"></h2>. When you scroll near that image, the javascript tries to update the url but that broken ID caused it to set the empty ID ("#"), thus jumping to top.
You can verify this by open the table of contents bar and see an untitled section. Whatever CMS they are using, it didn't handle the empty H2 correctly. Few additional considerations:
1. The article author should never produce an H2 with only an image in it.
2. The image should have an `alt` label to be accessible.
3. CMS should use `alt` label or file name to generate the ID when the H2 has no other textual content.
- low_tech_punk 3y agoThe w3c spec says valid hash fragment must starts with [a-zA-Z], so "-h2" is considered invalid. Ref: https://www.w3.org/TR/xhtml1/#C_8 https://www.w3.org/TR/xhtml1/#C_8