Skip to content

Commit dcc854b

Browse files
airamrguezgaearon
authored andcommitted
prevent removing attributes on custom component tags (facebook#12702)
1 parent 045d4f1 commit dcc854b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

packages/react-dom/src/__tests__/DOMPropertyOperations-test.js

+6
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,11 @@ describe('DOMPropertyOperations', () => {
155155
expect(container.firstChild.getAttribute('value')).toBe('foo');
156156
expect(container.firstChild.value).toBe('foo');
157157
});
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+
});
158164
});
159165
});

packages/react-dom/src/shared/DOMProperty.js

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ export function shouldRemoveAttribute(
157157
) {
158158
return true;
159159
}
160+
if (isCustomComponentTag) {
161+
return false;
162+
}
160163
if (propertyInfo !== null) {
161164
switch (propertyInfo.type) {
162165
case BOOLEAN:

0 commit comments

Comments
 (0)