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

Update code to ensure IE11 compatibility #406

Merged
merged 1 commit into from
Jun 15, 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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"webpack": "^2.6.1"
},
"dependencies": {
"object-assign": "^4.1.1",
"prop-types": "^15.5.10"
},
"precommit": "lint-staged",
Expand Down
3 changes: 2 additions & 1 deletion src/Day.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable jsx-a11y/no-static-element-interactions, react/forbid-prop-types */

import React, { Component } from 'react';
import assign from 'object-assign';
import defaultClassNames from './classNames';
import PropTypes from './PropTypes';

Expand Down Expand Up @@ -86,7 +87,7 @@ export default class Day extends Component {
Object.keys(modifiers)
.filter(modifier => !!modifiersStyles[modifier])
.forEach(modifier => {
style = Object.assign({}, style, modifiersStyles[modifier]);
style = assign({}, style, modifiersStyles[modifier]);
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/DayPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default class DayPicker extends Component {

focusPreviousDay(dayNode) {
const dayNodes = Helpers.getDayNodes(this.dayPicker, this.props.classNames);
const dayNodeIndex = [...dayNodes].indexOf(dayNode);
const dayNodeIndex = Helpers.nodeListToArray(dayNodes).indexOf(dayNode);

if (dayNodeIndex === 0) {
this.showPreviousMonth(() => this.focusLastDayOfMonth());
Expand All @@ -283,7 +283,7 @@ export default class DayPicker extends Component {

focusNextDay(dayNode) {
const dayNodes = Helpers.getDayNodes(this.dayPicker, this.props.classNames);
const dayNodeIndex = [...dayNodes].indexOf(dayNode);
const dayNodeIndex = Helpers.nodeListToArray(dayNodes).indexOf(dayNode);

if (dayNodeIndex === dayNodes.length - 1) {
this.showNextMonth(() => this.focusFirstDayOfMonth());
Expand All @@ -294,7 +294,7 @@ export default class DayPicker extends Component {

focusNextWeek(dayNode) {
const dayNodes = Helpers.getDayNodes(this.dayPicker, this.props.classNames);
const dayNodeIndex = [...dayNodes].indexOf(dayNode);
const dayNodeIndex = Helpers.nodeListToArray(dayNodes).indexOf(dayNode);
const isInLastWeekOfMonth = dayNodeIndex > dayNodes.length - 8;

if (isInLastWeekOfMonth) {
Expand All @@ -312,7 +312,7 @@ export default class DayPicker extends Component {

focusPreviousWeek(dayNode) {
const dayNodes = Helpers.getDayNodes(this.dayPicker, this.props.classNames);
const dayNodeIndex = [...dayNodes].indexOf(dayNode);
const dayNodeIndex = Helpers.nodeListToArray(dayNodes).indexOf(dayNode);
const isInFirstWeekOfMonth = dayNodeIndex <= 6;

if (isInFirstWeekOfMonth) {
Expand Down
4 changes: 4 additions & 0 deletions src/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,7 @@ export function getDayNodes(node, classNames) {
const selector = `.${dayQuery}:not(.${outsideDayQuery})`;
return node.querySelectorAll(selector);
}

export function nodeListToArray(nodeList) {
return Array.prototype.slice.call(nodeList, 0);
}