Skip to content

Commit

Permalink
Use attachEvent/detachEvent for IE8 compability
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Mesnyankin committed Sep 30, 2016
1 parent 0b36224 commit 6c5c828
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,26 @@ const Select = React.createClass({
},

componentWillUnmount() {
document.removeEventListener('touchstart', this.handleTouchOutside);
if (!document.removeEventListener && document.detachEvent) {
document.detachEvent('ontouchstart', this.handleTouchOutside);
} else {
document.removeEventListener('touchstart', this.handleTouchOutside);
}
},

toggleTouchOutsideEvent(enabled) {
if (enabled) {
document.addEventListener('touchstart', this.handleTouchOutside);
if (!document.addEventListener && document.attachEvent) {
document.attachEvent('ontouchstart', this.handleTouchOutside);
} else {
document.addEventListener('touchstart', this.handleTouchOutside);
}
} else {
document.removeEventListener('touchstart', this.handleTouchOutside);
if (!document.removeEventListener && document.detachEvent) {
document.detachEvent('ontouchstart', this.handleTouchOutside);
} else {
document.removeEventListener('touchstart', this.handleTouchOutside);
}
}
},

Expand Down

0 comments on commit 6c5c828

Please sign in to comment.