Skip to content

Commit

Permalink
Merge pull request #5081 from spicyj/svg-tu
Browse files Browse the repository at this point in the history
Don't break on SVG tags in scryRenderedDOMComponentsWithClass
  • Loading branch information
sophiebits committed Oct 8, 2015
2 parents e9796cc + 4bb83d2 commit 4fb39ce
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/test/ReactTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,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);
},

Expand Down Expand Up @@ -186,9 +184,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;
Expand Down

0 comments on commit 4fb39ce

Please sign in to comment.