Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/renderers/dom/fiber/ReactDOMFiberComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,10 @@ var ReactDOMFiberComponent = {
var extraAttributeNames: Set<string> = new Set();
var attributes = domElement.attributes;
for (var i = 0; i < attributes.length; i++) {
// TODO: Do we need to lower case this to get case insensitive matches?
var name = attributes[i].name;
// Downcase to work around IE Edge, which reports some SVG attributes
// in all-caps. See:
// https://github.com/facebook/react/pull/10394#issuecomment-320523369
var name = attributes[i].name.toLowerCase();
switch (name) {
// Built-in attributes are whitelisted
// TODO: Once these are gone from the server renderer, we don't need
Expand Down Expand Up @@ -1024,7 +1026,7 @@ var ReactDOMFiberComponent = {
DOMProperty.isCustomAttribute(propKey)
) {
// $FlowFixMe - Should be inferred as not undefined.
extraAttributeNames.delete(propKey);
extraAttributeNames.delete(propKey.toLowerCase());
serverValue = DOMPropertyOperations.getValueForAttribute(
domElement,
propKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,12 @@ describe('ReactDOMServerIntegration', () => {
const e = await render(<div className={null} />);
expect(e.hasAttribute('className')).toBe(false);
});

itRenders('no lower case classname', async render => {
const e = await render(<div classname="test" />, 1);
expect(e.hasAttribute('className')).toBe(false);
expect(e.hasAttribute('class')).toBe(false);
});
});

describe('htmlFor property', function() {
Expand Down Expand Up @@ -789,6 +795,11 @@ describe('ReactDOMServerIntegration', () => {
expect(e.getAttribute('data-foo')).toBe('bar');
});

itRenders('unknown data- attributes with casing', async render => {
const e = await render(<div data-myAttribute="test" />, 0);
expect(e.getAttribute('data-myAttribute')).toBe('test');
});

itRenders('no unknown data- attributes with null value', async render => {
const e = await render(<div data-foo={null} />);
expect(e.hasAttribute('data-foo')).toBe(false);
Expand Down