From 1e5ecb03764e8c907a475c15443f84b43365b510 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 2 Oct 2017 17:45:50 +0100 Subject: [PATCH 1/2] Fix tabIndex attribute for SVG --- src/renderers/dom/shared/HTMLDOMPropertyConfig.js | 2 ++ .../__tests__/ReactDOMServerIntegration-test.js | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/renderers/dom/shared/HTMLDOMPropertyConfig.js b/src/renderers/dom/shared/HTMLDOMPropertyConfig.js index 6b99daf81cc..3571ad955cb 100644 --- a/src/renderers/dom/shared/HTMLDOMPropertyConfig.js +++ b/src/renderers/dom/shared/HTMLDOMPropertyConfig.js @@ -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, // itemScope is for for Microdata support. // See http://schema.org/docs/gs.html itemScope: HAS_BOOLEAN_VALUE, diff --git a/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js b/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js index 8d99590f27f..642e99a0e06 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js @@ -1243,6 +1243,19 @@ describe('ReactDOMServerIntegration', () => { ); }); + itRenders('svg element with a tabIndex attribute', async render => { + let e = await render(); + expect(e.tabIndex).toBe(1); + }); + + itRenders( + 'svg element with a badly cased tabIndex attribute', + async render => { + let e = await render(, 1); + expect(e.tabIndex).toBe(1); + }, + ); + itRenders('a math element', async render => { const e = await render(); expect(e.childNodes.length).toBe(0); From c07972786f22b1f595b68b75c3072e14c16a99e5 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 2 Oct 2017 18:49:07 +0100 Subject: [PATCH 2/2] Update the attribute table --- .../attribute-behavior/AttributeTableSnapshot.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fixtures/attribute-behavior/AttributeTableSnapshot.md b/fixtures/attribute-behavior/AttributeTableSnapshot.md index be65028e1dc..b3dc123cdd6 100644 --- a/fixtures/attribute-behavior/AttributeTableSnapshot.md +++ b/fixtures/attribute-behavior/AttributeTableSnapshot.md @@ -10768,7 +10768,7 @@ | `tabIndex=(string 'false')`| (initial)| `` | | `tabIndex=(string 'on')`| (initial)| `` | | `tabIndex=(string 'off')`| (initial)| `` | -| `tabIndex=(symbol)`| (initial, warning)| `` | +| `tabIndex=(symbol)`| (initial, warning, ssr error, ssr mismatch)| `` | | `tabIndex=(function)`| (initial, warning)| `` | | `tabIndex=(null)`| (initial)| `` | | `tabIndex=(undefined)`| (initial)| `` | @@ -10781,19 +10781,19 @@ | `tabIndex=(array with string)`| (initial)| `` | | `tabIndex=(empty array)`| (initial)| `` | | `tabIndex=(object)`| (initial)| `` | -| `tabIndex=(numeric string)`| (initial, ssr mismatch)| `` | +| `tabIndex=(numeric string)`| (changed)| `` | | `tabIndex=(-1)`| (initial)| `` | -| `tabIndex=(0)`| (initial, ssr mismatch)| `` | -| `tabIndex=(integer)`| (initial, ssr mismatch)| `` | +| `tabIndex=(0)`| (changed)| `` | +| `tabIndex=(integer)`| (changed)| `` | | `tabIndex=(NaN)`| (initial, warning)| `` | -| `tabIndex=(float)`| (initial, ssr mismatch)| `` | +| `tabIndex=(float)`| (changed)| `` | | `tabIndex=(true)`| (initial, warning)| `` | | `tabIndex=(false)`| (initial, warning)| `` | | `tabIndex=(string 'true')`| (initial)| `` | | `tabIndex=(string 'false')`| (initial)| `` | | `tabIndex=(string 'on')`| (initial)| `` | | `tabIndex=(string 'off')`| (initial)| `` | -| `tabIndex=(symbol)`| (initial, warning)| `` | +| `tabIndex=(symbol)`| (initial, warning, ssr error, ssr mismatch)| `` | | `tabIndex=(function)`| (initial, warning)| `` | | `tabIndex=(null)`| (initial)| `` | | `tabIndex=(undefined)`| (initial)| `` |