Skip to content

Commit

Permalink
Add support for SVG transformOrigin prop (#26130)
Browse files Browse the repository at this point in the history
Co-authored-by: eps1lon <silbermann.sebastian@gmail.com>
  • Loading branch information
arav-ind and eps1lon authored Feb 9, 2023
1 parent 3ff1540 commit 28fcae0
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
52 changes: 51 additions & 1 deletion fixtures/attribute-behavior/AttributeTableSnapshot.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## `about` (on `<div>` inside `<div>`)
## `about` (on `<div>` inside `<div>`)
| Test Case | Flags | Result |
| --- | --- | --- |
| `about=(string)`| (changed)| `"a string"` |
Expand Down Expand Up @@ -11373,6 +11373,56 @@
| `transform=(null)`| (initial)| `[]` |
| `transform=(undefined)`| (initial)| `[]` |

## `transform-origin` (on `<svg>` inside `<div>`)
| Test Case | Flags | Result |
| --- | --- | --- |
| `transform-origin=(string)`| (changed, warning)| `"a string"` |
| `transform-origin=(empty string)`| (changed, warning)| `<empty string>` |
| `transform-origin=(array with string)`| (changed, warning)| `"string"` |
| `transform-origin=(empty array)`| (changed, warning)| `<empty string>` |
| `transform-origin=(object)`| (changed, warning)| `"result of toString()"` |
| `transform-origin=(numeric string)`| (changed, warning)| `"42"` |
| `transform-origin=(-1)`| (changed, warning)| `"-1"` |
| `transform-origin=(0)`| (changed, warning)| `"0"` |
| `transform-origin=(integer)`| (changed, warning)| `"1"` |
| `transform-origin=(NaN)`| (changed, warning)| `"NaN"` |
| `transform-origin=(float)`| (changed, warning)| `"99.99"` |
| `transform-origin=(true)`| (initial, warning)| `<null>` |
| `transform-origin=(false)`| (initial, warning)| `<null>` |
| `transform-origin=(string 'true')`| (changed, warning)| `"true"` |
| `transform-origin=(string 'false')`| (changed, warning)| `"false"` |
| `transform-origin=(string 'on')`| (changed, warning)| `"on"` |
| `transform-origin=(string 'off')`| (changed, warning)| `"off"` |
| `transform-origin=(symbol)`| (initial, warning)| `<null>` |
| `transform-origin=(function)`| (initial, warning)| `<null>` |
| `transform-origin=(null)`| (initial, warning)| `<null>` |
| `transform-origin=(undefined)`| (initial, warning)| `<null>` |

## `transformOrigin` (on `<svg>` inside `<div>`)
| Test Case | Flags | Result |
| --- | --- | --- |
| `transformOrigin=(string)`| (changed)| `"a string"` |
| `transformOrigin=(empty string)`| (changed)| `<empty string>` |
| `transformOrigin=(array with string)`| (changed)| `"string"` |
| `transformOrigin=(empty array)`| (changed)| `<empty string>` |
| `transformOrigin=(object)`| (changed)| `"result of toString()"` |
| `transformOrigin=(numeric string)`| (changed)| `"42"` |
| `transformOrigin=(-1)`| (changed)| `"-1"` |
| `transformOrigin=(0)`| (changed)| `"0"` |
| `transformOrigin=(integer)`| (changed)| `"1"` |
| `transformOrigin=(NaN)`| (changed, warning)| `"NaN"` |
| `transformOrigin=(float)`| (changed)| `"99.99"` |
| `transformOrigin=(true)`| (initial, warning)| `<null>` |
| `transformOrigin=(false)`| (initial, warning)| `<null>` |
| `transformOrigin=(string 'true')`| (changed)| `"true"` |
| `transformOrigin=(string 'false')`| (changed)| `"false"` |
| `transformOrigin=(string 'on')`| (changed)| `"on"` |
| `transformOrigin=(string 'off')`| (changed)| `"off"` |
| `transformOrigin=(symbol)`| (initial, warning)| `<null>` |
| `transformOrigin=(function)`| (initial, warning)| `<null>` |
| `transformOrigin=(null)`| (initial)| `<null>` |
| `transformOrigin=(undefined)`| (initial)| `<null>` |

## `type` (on `<button>` inside `<div>`)
| Test Case | Flags | Result |
| --- | --- | --- |
Expand Down
10 changes: 10 additions & 0 deletions fixtures/attribute-behavior/src/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,16 @@ const attributes = [
overrideStringValue:
'translate(-10,-20) scale(2) rotate(45) translate(5,10)',
},
{
name: 'transform-origin',
tagName: 'svg',
read: getSVGAttribute('transform-origin'),
},
{
name: 'transformOrigin',
tagName: 'svg',
read: getSVGAttribute('transform-origin'),
},
{name: 'type', tagName: 'button', overrideStringValue: 'reset'},
{
name: 'type',
Expand Down
1 change: 1 addition & 0 deletions packages/react-dom-bindings/src/shared/DOMProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ const capitalize = (token: string) => token[1].toUpperCase();
'text-anchor',
'text-decoration',
'text-rendering',
'transform-origin',
'underline-position',
'underline-thickness',
'unicode-bidi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ const possibleStandardNames = {
'text-rendering': 'textRendering',
to: 'to',
transform: 'transform',
transformorigin: 'transformOrigin',
'transform-origin': 'transformOrigin',
typeof: 'typeof',
u1: 'u1',
u2: 'u2',
Expand Down

0 comments on commit 28fcae0

Please sign in to comment.