preactjs / preactjs/preact-render-to-string
`px` unit for grid gap discrepancy between preact-render-to-string and react-dom/server #218
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 726
- Forks
- 101
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 6
Description
We've noticed a discrepancy in how preact / react server renders a component that looks like this:
import React from "preact/compat";
import "./styles.css";
export default function App() {
return (
<div
style={{
display: "grid",
"grid-column-gap": 16,
"grid-row-gap": 24,
border: "1px solid red"
}}
>
<div className="child">Child</div>
<div className="child">Child</div>
<div className="child">Child</div>
<div className="child">Child</div>
</div>
);
}
Code sandboxes for preact and react to compare the output:
We're using React 16.14.0 but as far as I can tell, React 17.x would have the same discrepancy.
I think the difference is that in Preact, we use this regex:
IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
Which would match grid-gap, but React explicitly lists non dimensional properties: https://github.com/facebook/react/blob/v17.0.0/packages/react-dom/src/shared/CSSProperty.js#L11
So properties that would be non dimensional in Preact but not React are:
- gridRowGap
- gridColumnGap
There might be more, it might be worth auditing gap properties fully to ensure there aren't more discrepancies
Contributor guide
No contributing guide indexed for this repository
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 by locating the IS_NON_DIMENSIONAL regex cited in the report and compare its grid-gap handling with React's CSSProperty.js list. Audit the related gap properties and add coverage for the reported server-rendered output; done means the Preact and React renderings agree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100