diff --git a/src/MountedTraversal.js b/src/MountedTraversal.js index 7b1f9da95..e8406c8fd 100644 --- a/src/MountedTraversal.js +++ b/src/MountedTraversal.js @@ -84,7 +84,6 @@ export function instHasType(inst, type) { } export function instHasProperty(inst, propKey, stringifiedPropValue) { - if (!isDOMComponent(inst)) return false; const node = getNode(inst); const nodeProps = propsOfNode(node); const descriptor = Object.getOwnPropertyDescriptor(nodeProps, propKey); diff --git a/test/ReactWrapper-spec.jsx b/test/ReactWrapper-spec.jsx index 503eee358..abb1aee94 100644 --- a/test/ReactWrapper-spec.jsx +++ b/test/ReactWrapper-spec.jsx @@ -384,6 +384,20 @@ describeWithDOM('mount', () => { }); + it('should find React Component based on a components prop via css selector', () => { + class Foo extends React.Component { + render() { return
; } + } + const wrapper = mount( +
+ +
+ ); + + expect(wrapper.find('[bar]')).to.have.length(1); + expect(wrapper.find('Foo[bar="baz"]')).to.have.length(1); + }); + it('should not find components with invalid attributes', () => { // Invalid attributes aren't valid JSX, so manual instantiation is necessary const wrapper = mount( diff --git a/test/ShallowWrapper-spec.jsx b/test/ShallowWrapper-spec.jsx index 47b570f10..6ec13313f 100644 --- a/test/ShallowWrapper-spec.jsx +++ b/test/ShallowWrapper-spec.jsx @@ -481,6 +481,20 @@ describe('shallow', () => { expect(wrapper.find('[data-foo]')).to.have.length(1); }); + it('should find a React Component based on a components prop via css selector', () => { + class Foo extends React.Component { + render() { return
; } + } + const wrapper = shallow( +
+ +
+ ); + + expect(wrapper.find('[bar]')).to.have.length(1); + expect(wrapper.find('Foo[bar="baz"]')).to.have.length(1); + }); + it('should find components with multiple matching react props', () => { function noop() {} const wrapper = shallow(