Ignore whitelisted attributes for native custom elements that use the is attribute.
Jeff Hicken committed
Jun 9, 2015 at 16:58 UTC
7256f0976ceb2b37b3a111201ee5151315586b32
2 files changed
+12
-2
src/renderers/dom/shared/ReactDOMComponent.js
+6
-2
@@ -296,6 +296,10 @@ function processChildContext(context, inst) {
296
return context;
297
}
298
299
+function isCustomComponent(tagName, props) {
300
+ return tagName.indexOf('-') >= 0 || props.is != null;
301
+}
302
+
303
/**
304
* Creates a new React class that is idempotent and capable of containing other
305
* React components. It accepts event listeners and DOM properties that are
@@ -446,7 +450,7 @@ ReactDOMComponent.Mixin = {
450
propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
451
}
452
var markup = null;
449
- if (this._tag != null && this._tag.indexOf('-') >= 0) {
453
+ if (this._tag != null && isCustomComponent(this._tag, props)) {
454
markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue);
455
} else {
456
markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
@@ -686,7 +690,7 @@ ReactDOMComponent.Mixin = {
690
} else if (lastProp) {
691
deleteListener(this._rootNodeID, propKey);
692
}
689
- } else if (this._tag.indexOf('-') >= 0) {
693
+ } else if (isCustomComponent(this._tag, nextProps)) {
694
BackendIDOperations.updateAttributeByID(
695
this._rootNodeID,
696
propKey,
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+6
@@ -331,6 +331,12 @@ describe('ReactDOMComponent', function() {
331
React.render(<div />, container);
332
expect(nodeValueSetter.mock.calls.length).toBe(1);
333
});
334
+
335
+ it('should ignore attribute whitelist for elements with the "is: attribute', function() {
336
+ var container = document.createElement('div');
337
+ React.render(<button is="test" cowabunga="chevynova"/>, container);
338
+ expect(container.firstChild.hasAttribute('cowabunga')).toBe(true);
339
+ });
340
});
341
342
describe('createOpenTagMarkup', function() {