diff --git a/src/text.ts b/src/text.ts index 72bbfdfb..627b5f02 100644 --- a/src/text.ts +++ b/src/text.ts @@ -419,11 +419,15 @@ export default async function* buildTextNodes( } flow(r) measuredTextSize = { width: r, height } - return { width: r, height } + return { width: Math.ceil(r), height } } - measuredTextSize = { width, height } - return { width, height } + // This may be a temporary fix, I didn't dig deep into yoga. + // But when the return value of width here doesn't change (assuming the value of width is 216.9), + // when we later get the width through `parent.getComputedWidth()`, sometimes it returns 216 and sometimes 217. + // I'm not sure if this is a yoga bug, but it seems related to the entire page width. + // So I use Math.ceil. + return { width: Math.ceil(width), height } }) const [x, y] = yield diff --git a/test/__image_snapshots__/basic-test-tsx-test-basic-test-tsx-basic-should-combine-text-nodes-correctly-1-snap.png b/test/__image_snapshots__/basic-test-tsx-test-basic-test-tsx-basic-should-combine-text-nodes-correctly-1-snap.png index edf0addc..738485b6 100644 Binary files a/test/__image_snapshots__/basic-test-tsx-test-basic-test-tsx-basic-should-combine-text-nodes-correctly-1-snap.png and b/test/__image_snapshots__/basic-test-tsx-test-basic-test-tsx-basic-should-combine-text-nodes-correctly-1-snap.png differ diff --git a/test/__image_snapshots__/color-models-test-tsx-test-color-models-test-tsx-color-models-background-color-and-color-should-support-currentcolor-when-border-1-snap.png b/test/__image_snapshots__/color-models-test-tsx-test-color-models-test-tsx-color-models-background-color-and-color-should-support-currentcolor-when-border-1-snap.png index 56cf4887..651e4303 100644 Binary files a/test/__image_snapshots__/color-models-test-tsx-test-color-models-test-tsx-color-models-background-color-and-color-should-support-currentcolor-when-border-1-snap.png and b/test/__image_snapshots__/color-models-test-tsx-test-color-models-test-tsx-color-models-background-color-and-color-should-support-currentcolor-when-border-1-snap.png differ diff --git a/test/__image_snapshots__/color-models-test-tsx-test-color-models-test-tsx-color-models-should-support-css-4-syntax-color-in-hsl-1-snap.png b/test/__image_snapshots__/color-models-test-tsx-test-color-models-test-tsx-color-models-should-support-css-4-syntax-color-in-hsl-1-snap.png index d8618f54..a180f008 100644 Binary files a/test/__image_snapshots__/color-models-test-tsx-test-color-models-test-tsx-color-models-should-support-css-4-syntax-color-in-hsl-1-snap.png and b/test/__image_snapshots__/color-models-test-tsx-test-color-models-test-tsx-color-models-should-support-css-4-syntax-color-in-hsl-1-snap.png differ diff --git a/test/basic.test.tsx b/test/basic.test.tsx index c70d85f4..5738a417 100644 --- a/test/basic.test.tsx +++ b/test/basic.test.tsx @@ -105,6 +105,7 @@ describe('Basic', () => { display: 'flex', height: '100%', width: '100%', + background: 'white', }} > Hi {0}