Skip to content

Commit b75c3ae

Browse files
committed
fix: incorrect behavior
1 parent 0e7afe2 commit b75c3ae

4 files changed

Lines changed: 4 additions & 16 deletions

src/text/index.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ function isFullyTransparent(color: string): boolean {
3535
return parsed ? parsed.alpha === 0 : false
3636
}
3737

38-
function isOpaqueWhite(color: string): boolean {
39-
if (!color) return false
40-
const parsed = cssColorParse(color)
41-
if (!parsed) return false
42-
const [r, g, b, a] = parsed.values
43-
return r === 255 && g === 255 && b === 255 && (a === undefined || a === 1)
44-
}
45-
4638
export default async function* buildTextNodes(
4739
content: string,
4840
context: LayoutContext
@@ -73,17 +65,13 @@ export default async function* buildTextNodes(
7365
tabSize = 8,
7466
letterSpacing,
7567
_inheritedBackgroundClipTextPath,
76-
_inheritedBackgroundClipTextHasBackground,
7768
WebkitTextFillColor,
7869
flexShrink,
7970
} = parentStyle
8071

8172
const textFillColor = WebkitTextFillColor as string | undefined
82-
const isTransparentText = textFillColor
83-
? isFullyTransparent(textFillColor)
84-
: isFullyTransparent(parentStyle.color) ||
85-
(!!_inheritedBackgroundClipTextHasBackground &&
86-
isOpaqueWhite(parentStyle.color))
73+
const effectiveColor = textFillColor || parentStyle.color
74+
const isTransparentText = isFullyTransparent(effectiveColor)
8775

8876
const {
8977
words,
@@ -880,7 +868,7 @@ export default async function* buildTextNodes(
880868
// Embed the font as path.
881869
if (mergedPath) {
882870
const p =
883-
(!isFullyTransparent(parentStyle.color) || filter) && opacity !== 0
871+
(!isTransparentText || filter) && opacity !== 0
884872
? `<g ${overflowMaskId ? `mask="url(#${overflowMaskId})"` : ''} ${
885873
clipPathId ? `clip-path="url(#${clipPathId})"` : ''
886874
}>` +
Loading

test/shadow.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ describe('Shadow', () => {
252252
expect(toImage(svg, 100)).toMatchImageSnapshot()
253253
})
254254

255-
it('should support text shadows with backgroundClip text', async () => {
255+
it('should render white text with shadow when backgroundClip is text', async () => {
256256
const svg = await satori(
257257
<div
258258
style={{

0 commit comments

Comments
 (0)