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

Fixes for #269 #275

Merged
merged 2 commits into from
Mar 6, 2017
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
22 changes: 11 additions & 11 deletions src/DayPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,17 @@ export default class DayPicker extends Component {
}

getDayNodes() {
const createQuery = classes => `.${classes.replace(/ /g, '.')}`;
const hasDefaultClassNames = () => this.props.classNames === classNames;
const getOutsideClassNames = (classes) => {
if (hasDefaultClassNames()) {
return `${classes.day}--${classes.outside}`;
}
return classes.outside;
};
const dayQuery = createQuery(this.props.classNames.day);
const outsideDayQuery = createQuery(getOutsideClassNames(this.props.classNames));
return this.dayPicker.querySelectorAll(`${dayQuery}:not(${outsideDayQuery})`);
let outsideClassName;
if (this.props.classNames === classNames) {
// When using CSS modules prefix the modifier as required by the BEM syntax
outsideClassName = `${this.props.classNames.day}--${this.props.classNames.outside}`;
} else {
outsideClassName = `${this.props.classNames.outside}`;
}
const dayQuery = this.props.classNames.day.replace(/ /g, '.');
const outsideDayQuery = outsideClassName.replace(/ /g, '.');
const selector = `.${dayQuery}:not(.${outsideDayQuery})`;
return this.dayPicker.querySelectorAll(selector);
}

getNextNavigableMonth() {
Expand Down
6 changes: 5 additions & 1 deletion test/daypicker/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ describe('DayPicker’s navigation', () => {
});
it('should not allow the next month when the last month is the last allowed one', () => {
const wrapper = shallow(
<DayPicker initialMonth={ new Date(2015, 7) } toMonth={ new Date(2015, 9) } numberOfMonths={ 3 } />, // eslint-disable-line max-len
<DayPicker
initialMonth={ new Date(2015, 7) }
toMonth={ new Date(2015, 9) }
numberOfMonths={ 3 }
/>,
);
expect(wrapper.instance().allowNextMonth()).to.be.false;
});
Expand Down