Skip to content

Commit

Permalink
Fix tabIndex attribute for SVG (#11033)
Browse files Browse the repository at this point in the history
* Fix tabIndex attribute for SVG

* Update the attribute table
  • Loading branch information
gaearon authored Oct 2, 2017
1 parent fbdd43f commit fbd6b9d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
12 changes: 6 additions & 6 deletions fixtures/attribute-behavior/AttributeTableSnapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -10768,7 +10768,7 @@
| `tabIndex=(string 'false')`| (initial)| `<number: -1>` |
| `tabIndex=(string 'on')`| (initial)| `<number: -1>` |
| `tabIndex=(string 'off')`| (initial)| `<number: -1>` |
| `tabIndex=(symbol)`| (initial, warning)| `<number: -1>` |
| `tabIndex=(symbol)`| (initial, warning, ssr error, ssr mismatch)| `<number: -1>` |
| `tabIndex=(function)`| (initial, warning)| `<number: -1>` |
| `tabIndex=(null)`| (initial)| `<number: -1>` |
| `tabIndex=(undefined)`| (initial)| `<number: -1>` |
Expand All @@ -10781,19 +10781,19 @@
| `tabIndex=(array with string)`| (initial)| `<number: -1>` |
| `tabIndex=(empty array)`| (initial)| `<number: -1>` |
| `tabIndex=(object)`| (initial)| `<number: -1>` |
| `tabIndex=(numeric string)`| (initial, ssr mismatch)| `<number: -1>` |
| `tabIndex=(numeric string)`| (changed)| `<number: 42>` |
| `tabIndex=(-1)`| (initial)| `<number: -1>` |
| `tabIndex=(0)`| (initial, ssr mismatch)| `<number: -1>` |
| `tabIndex=(integer)`| (initial, ssr mismatch)| `<number: -1>` |
| `tabIndex=(0)`| (changed)| `<number: 0>` |
| `tabIndex=(integer)`| (changed)| `<number: 1>` |
| `tabIndex=(NaN)`| (initial, warning)| `<number: -1>` |
| `tabIndex=(float)`| (initial, ssr mismatch)| `<number: -1>` |
| `tabIndex=(float)`| (changed)| `<number: 99>` |
| `tabIndex=(true)`| (initial, warning)| `<number: -1>` |
| `tabIndex=(false)`| (initial, warning)| `<number: -1>` |
| `tabIndex=(string 'true')`| (initial)| `<number: -1>` |
| `tabIndex=(string 'false')`| (initial)| `<number: -1>` |
| `tabIndex=(string 'on')`| (initial)| `<number: -1>` |
| `tabIndex=(string 'off')`| (initial)| `<number: -1>` |
| `tabIndex=(symbol)`| (initial, warning)| `<number: -1>` |
| `tabIndex=(symbol)`| (initial, warning, ssr error, ssr mismatch)| `<number: -1>` |
| `tabIndex=(function)`| (initial, warning)| `<number: -1>` |
| `tabIndex=(null)`| (initial)| `<number: -1>` |
| `tabIndex=(undefined)`| (initial)| `<number: -1>` |
Expand Down
2 changes: 2 additions & 0 deletions src/renderers/dom/shared/HTMLDOMPropertyConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ var HTMLDOMPropertyConfig = {
// Style must be explicitly set in the attribute list. React components
// expect a style object
style: 0,
// Keep it in the whitelist because it is case-sensitive for SVG.
tabIndex: 0,

This comment has been minimized.

Copy link
@nhunzaker

nhunzaker Oct 3, 2017

Contributor

Thanks. Beat me to it!

// itemScope is for for Microdata support.
// See http://schema.org/docs/gs.html
itemScope: HAS_BOOLEAN_VALUE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,19 @@ describe('ReactDOMServerIntegration', () => {
);
});

itRenders('svg element with a tabIndex attribute', async render => {
let e = await render(<svg tabIndex="1" />);
expect(e.tabIndex).toBe(1);
});

itRenders(
'svg element with a badly cased tabIndex attribute',
async render => {
let e = await render(<svg tabindex="1" />, 1);
expect(e.tabIndex).toBe(1);
},
);

itRenders('a math element', async render => {
const e = await render(<math />);
expect(e.childNodes.length).toBe(0);
Expand Down

0 comments on commit fbd6b9d

Please sign in to comment.