Skip to content

Commit

Permalink
Return _instance if public instance is null
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Dail authored and Brandon Dail committed May 6, 2016
1 parent 603f07a commit 2768a9a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions INTHEWILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Organizations
- [Product Hunt](https://github.com/producthunt)
- [Walmart Labs](https://github.com/walmartlabs)
- [Hudl](http://hudl.github.io/)
- [NET-A-PORTER](https://github.com/NET-A-PORTER)

Projects
----------
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ShallowWrapper/contains.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `.contains(nodeOrNodes) => Boolean`

Returns whether or not the current wrapper has a node anywhere in it's render tree that looks like
Returns whether or not the current wrapper has a node anywhere in its render tree that looks like
the one passed in.


Expand All @@ -13,7 +13,7 @@ render tree.

#### Returns

`Boolean`: whether or not the current wrapper has a node anywhere in it's render tree that looks
`Boolean`: whether or not the current wrapper has a node anywhere in its render tree that looks
like the one passed in.


Expand Down
2 changes: 1 addition & 1 deletion src/ReactWrapperComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function createWrapperComponent(node, options = {}) {
const component = this._reactInternalInstance._renderedComponent;
const inst = component.getPublicInstance();
if (inst === null) {
return component;
return component._instance;
}
return inst;
},
Expand Down
9 changes: 9 additions & 0 deletions test/ReactWrapper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ describeWithDOM('mount', () => {
expect(wrapper.find('.qoo').text()).to.equal('qux');
});

it('supports findDOMNode with stateless components', () => {
const Foo = ({ foo }) => (
<div>{foo}</div>
);

const wrapper = mount(<Foo foo="qux" />);
expect(wrapper.text()).to.equal('qux');
});

it('works with nested stateless', () => {
const TestItem = () => (
<div className="item">1</div>
Expand Down

0 comments on commit 2768a9a

Please sign in to comment.