prevent removing attributes on custom component tags (#12702)
Airam committed
Apr 28, 2018 at 21:52 UTC
dcc854bcc3c940ca583565ce25200ca618c05bf0
2 files changed
+9
packages/react-dom/src/__tests__/DOMPropertyOperations-test.js
+6
@@ -155,5 +155,11 @@ describe('DOMPropertyOperations', () => {
155
expect(container.firstChild.getAttribute('value')).toBe('foo');
156
expect(container.firstChild.value).toBe('foo');
157
});
158
+
159
+ it('should not remove attributes for custom component tag', () => {
160
+ const container = document.createElement('div');
161
+ ReactDOM.render(<my-icon size="5px" />, container);
162
+ expect(container.firstChild.getAttribute('size')).toBe('5px');
163
+ });
164
});
165
});
packages/react-dom/src/shared/DOMProperty.js
+3
@@ -157,6 +157,9 @@ export function shouldRemoveAttribute(
157
) {
158
return true;
159
}
160
+ if (isCustomComponentTag) {
161
+ return false;
162
+ }
163
if (propertyInfo !== null) {
164
switch (propertyInfo.type) {
165
case BOOLEAN: