Merge pull request #5081 from spicyj/svg-tu

Don't break on SVG tags in scryRenderedDOMComponentsWithClass
(cherry picked from commit 4fb39ce984)
This commit is contained in:
Ben Alpert authored and Paul O’Shannessy committed 2015-10-28 12:42:15 -07:00
1 parent 0acdefb7cc
commit fb620be2b8
1 file changed
+8 -5
+8 -5
View File
@@ -98,8 +98,6 @@ var ReactTestUtils = {
},
isDOMComponent: function(inst) {
// TODO: Fix this heuristic. It's just here because composites can currently
// pretend to be DOM components.
return !!(inst && inst.nodeType === 1 && inst.tagName);
},
@@ -185,9 +183,14 @@ var ReactTestUtils = {
}
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
if (ReactTestUtils.isDOMComponent(inst)) {
var classList = ReactDOM.findDOMNode(inst).className.split(/\s+/);
return classNames.every(function(className) {
return classList.indexOf(className) !== -1;
var className = inst.className;
if (typeof className !== 'string') {
// SVG, probably.
className = inst.getAttribute('class') || '';
}
var classList = className.split(/\s+/);
return classNames.every(function(name) {
return classList.indexOf(name) !== -1;
});
}
return false;