The pseudo class ":first-child" is potentially unsafe when doing server-side rendering
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
### mapbox-gl-js version
3.20.0
### Browser and version
Chrome 146.0.7680.80
### Context:
Product: ui library
Stack: React, Typescript, Emotion
### Expected behavior
Use `:first-of-type` instead of `:first-child`.
### Actual behavior
The imported `mapbox-gl.css` file causes Emotion to log this error to the console:
`The pseudo-class ":first-child" is potentially unsafe when doing server-side rendering. Try changing it to ":first-of-type".`
The error looks valid. The current version of the mapbox-gl.css file still has that pseudo-selector:
https://github.com/mapbox/mapbox-gl-js/blob/main/src/css/mapbox-gl.css
### Link to the demonstration
[Link to reproduce](https://stackblitz.com/edit/vitejs-vite-2d9vybmp?file=src%2FApp.tsx)
### Steps to trigger the unexpected behavior
1. Navigate the link above
2. Wait for the project to set up
3. Open the DevTools's console
4. Observe a result
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/css/mapbox-gl.css and inspect the :first-child selector reported by Emotion. Reproduce the warning with the linked StackBlitz example, then verify that the selector change removes the console error without affecting the stylesheet behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100