react: Bug: `createRoot` function from React@18 break the css `:target`
Keywords
- React 18
- createRoot
- CSS selector
- CSS Target
- :target
React version: React@18
Steps To Reproduce
- open https://joyful-kelpie-c3bb20.netlify.app/buggy.html
- click
go to react id targetlink - You should see the
react id targetwith green background - Refresh page. The green background disappears
Link to code example:
The webpage source code is simple. You could check the source code directly.
Or, you can check this: https://gist.github.com/magic-akari/475a13219394fb938cff4169a9b61eb7
The current behavior
CSS target selector does not work. The green background disappears after refresh pages.
The expected behavior
CSS target selector should work after refresh pages.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 3
- Comments: 15
I’ve tested it in Chrome, Firefox, and Safari. Chrome and Safari show reported behavior, and Firefox doesn’t. The same goes for any Canary.
Just for convenience, the main difference between ok.html and buggy.html is shown below.
I’ve seen the same behavior. An issue I found that seems similar to me was https://github.com/remix-run/history/issues/503 , but history state is a bit new to me and I’m not sure if it’s related.
Edit: From other searching, it looks like this may be related to this whatwg issue: https://github.com/whatwg/html/issues/639#issuecomment-1030914480. It seems like they’re going to keep it that way.