mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
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:
1 parent
0acdefb7cc
commit
fb620be2b8
1 file changed
+8
-5
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user