Don't break on SVG tags in scryRenderedDOMComponentsWithClass
Fixes #5076.
Ben Alpert committed
Oct 7, 2015 at 17:18 UTC
4bb83d237e2a9c20e50747f967eb0389de7125b1
1 file changed
+8
-5
src/test/ReactTestUtils.js
+8
-5
@@ -99,8 +99,6 @@ var ReactTestUtils = {
99
},
100
101
isDOMComponent: function(inst) {
102
- // TODO: Fix this heuristic. It's just here because composites can currently
103
- // pretend to be DOM components.
102
return !!(inst && inst.nodeType === 1 && inst.tagName);
103
},
104
@@ -186,9 +184,14 @@ var ReactTestUtils = {
184
}
185
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
186
if (ReactTestUtils.isDOMComponent(inst)) {
189
- var classList = ReactDOM.findDOMNode(inst).className.split(/\s+/);
190
- return classNames.every(function(className) {
191
- return classList.indexOf(className) !== -1;
187
+ var className = inst.className;
188
+ if (typeof className !== 'string') {
189
+ // SVG, probably.
190
+ className = inst.getAttribute('class') || '';
191
+ }
192
+ var classList = className.split(/\s+/);
193
+ return classNames.every(function(name) {
194
+ return classList.indexOf(name) !== -1;
195
});
196
}
197
return false;