Skip to content

Commit

Permalink
Merge pull request #275 from gpbl/fixes-for-269
Browse files Browse the repository at this point in the history
Fixes for #269
  • Loading branch information
gpbl authored Mar 6, 2017
2 parents 9d592bf + cb4f395 commit ffc02af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
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

0 comments on commit ffc02af

Please sign in to comment.