Skip to content

Commit c220465

Browse files
authored
fix(web): exact-match transform function names in style key regex (#2515)
1 parent 5812ef4 commit c220465

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

targets/web/src/AnimatedStyle.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020
* animated. Perspective has been left out as it would conflict with the
2121
* non-transform perspective style.
2222
*/
23-
const domTransforms = /^(matrix|translate|scale|rotate|skew)/
23+
const domTransforms =
24+
/^(matrix3d|matrix|translate3d|translate[XYZ]?|scale3d|scale[XYZ]?|rotate3d|rotate[XYZ]?|skew[XY]?)$/
2425

2526
// These keys have "px" units by default
2627
const pxTransforms = /^(translate)/

targets/web/src/animated.test.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,25 @@ describe('animated component', () => {
205205
const wrapper = getByTestId('wrapper').element() as HTMLElement
206206
expect(wrapper.style.transform).toBe('none')
207207
})
208+
it('does not treat custom spring keys that start with transform-function names as transforms', async () => {
209+
// Issue #1912: user-defined interpolation keys like `scale3dValue` or
210+
// `translateY_v2` were hijacked by the `^scale` / `^translate` prefix
211+
// match in `AnimatedStyle`, corrupting the composed `transform`.
212+
const scale3dValue = spring(0.5)
213+
const { getByTestId } = await render(
214+
<a.div
215+
style={
216+
{
217+
scale3dValue,
218+
transform: 'rotate(45deg)',
219+
} as React.CSSProperties
220+
}
221+
data-testid="wrapper"
222+
/>
223+
)
224+
const wrapper = getByTestId('wrapper').element() as HTMLElement
225+
expect(wrapper.style.transform).toBe('rotate(45deg)')
226+
})
208227
it('preserves transform-style and transform-origin properties', async () => {
209228
const { getByTestId } = await render(
210229
<a.div

0 commit comments

Comments
 (0)