Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] nodeHasId has issue with 0.14 in some cases #65

Merged
merged 1 commit into from
Dec 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/ShallowTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ export function parentsOfNode(node, root) {
}

export function nodeHasId(node, id) {
const maybeId = node && node._store && node._store.props && node._store.props.id;
return maybeId === id;
return propsOfNode(node).id === id;
}

export function nodeHasType(node, type) {
Expand Down
6 changes: 6 additions & 0 deletions src/__tests__/ShallowWrapper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ describe('shallow', () => {

describe('.find(selector)', () => {

it('should be able to match the root DOM element', () => {
const wrapper = shallow(<div id="ttt" className="ttt">hello</div>);
expect(wrapper.find('#ttt')).to.have.length(1);
expect(wrapper.find('.ttt')).to.have.length(1);
});

it('should find an element based on a class name', () => {
const wrapper = shallow(
<div>
Expand Down