From 7256f0976ceb2b37b3a111201ee5151315586b32 Mon Sep 17 00:00:00 2001 From: Jeff Hicken Date: Tue, 9 Jun 2015 16:58:25 -0600 Subject: [PATCH] Ignore whitelisted attributes for native custom elements that use the is attribute. --- src/renderers/dom/shared/ReactDOMComponent.js | 8 ++++++-- .../dom/shared/__tests__/ReactDOMComponent-test.js | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js index eb5fefc0684f4..0e8a0667ca54f 100644 --- a/src/renderers/dom/shared/ReactDOMComponent.js +++ b/src/renderers/dom/shared/ReactDOMComponent.js @@ -296,6 +296,10 @@ function processChildContext(context, inst) { return context; } +function isCustomComponent(tagName, props) { + return tagName.indexOf('-') >= 0 || props.is != null; +} + /** * Creates a new React class that is idempotent and capable of containing other * React components. It accepts event listeners and DOM properties that are @@ -446,7 +450,7 @@ ReactDOMComponent.Mixin = { propValue = CSSPropertyOperations.createMarkupForStyles(propValue); } var markup = null; - if (this._tag != null && this._tag.indexOf('-') >= 0) { + if (this._tag != null && isCustomComponent(this._tag, props)) { markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue); } else { markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue); @@ -686,7 +690,7 @@ ReactDOMComponent.Mixin = { } else if (lastProp) { deleteListener(this._rootNodeID, propKey); } - } else if (this._tag.indexOf('-') >= 0) { + } else if (isCustomComponent(this._tag, nextProps)) { BackendIDOperations.updateAttributeByID( this._rootNodeID, propKey, diff --git a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js index 96cea367989c5..6bb3599e874c5 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js @@ -331,6 +331,12 @@ describe('ReactDOMComponent', function() { React.render(
, container); expect(nodeValueSetter.mock.calls.length).toBe(1); }); + + it('should ignore attribute whitelist for elements with the "is: attribute', function() { + var container = document.createElement('div'); + React.render(