From 3b36d038542927253bb67e392cbb01674d8d2fb8 Mon Sep 17 00:00:00 2001 From: Airam Rguez Date: Thu, 26 Apr 2018 23:10:40 +0200 Subject: [PATCH] prevent removing attributes on custom component tags --- .../react-dom/src/__tests__/DOMPropertyOperations-test.js | 6 ++++++ packages/react-dom/src/shared/DOMProperty.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/packages/react-dom/src/__tests__/DOMPropertyOperations-test.js b/packages/react-dom/src/__tests__/DOMPropertyOperations-test.js index aabb3e995f864..08874222d594c 100644 --- a/packages/react-dom/src/__tests__/DOMPropertyOperations-test.js +++ b/packages/react-dom/src/__tests__/DOMPropertyOperations-test.js @@ -155,5 +155,11 @@ describe('DOMPropertyOperations', () => { expect(container.firstChild.getAttribute('value')).toBe('foo'); expect(container.firstChild.value).toBe('foo'); }); + + it('should not remove attributes for custom component tag', () => { + const container = document.createElement('div'); + ReactDOM.render(, container); + expect(container.firstChild.getAttribute('size')).toBe('5px'); + }); }); }); diff --git a/packages/react-dom/src/shared/DOMProperty.js b/packages/react-dom/src/shared/DOMProperty.js index dd2c8f6e3a429..b01c069dbad0c 100644 --- a/packages/react-dom/src/shared/DOMProperty.js +++ b/packages/react-dom/src/shared/DOMProperty.js @@ -157,6 +157,9 @@ export function shouldRemoveAttribute( ) { return true; } + if (isCustomComponentTag) { + return false; + } if (propertyInfo !== null) { switch (propertyInfo.type) { case BOOLEAN: