react-modal-bootstrap icon indicating copy to clipboard operation
react-modal-bootstrap copied to clipboard

IE8 does not have addEventListener and removeEventListner

Open viviancpy opened this issue 9 years ago • 0 comments

Can you change the Modal to replace addEventListener to attachEvent, and removeEventListener to detachEvent, so that the modal can work well on IE8?

       this.componentDidMount = function () {
        if(document.addEventListener){
            document.addEventListener('keydown', _this.handleKeyDown);
        }else{
            document.attachEvent('onkeydown', _this.handleKeyDown);
        }

      _this.handleBody();
      _this.handleParent();
    };

    this.componentWillUnmount = function () {
        if(document.removeEventListener){
            document.removeEventListener('keydown', _this.handleKeyDown);
        }else{
            document.detachEvent('onkeydown', _this.handleKeyDown);
        }
    };

viviancpy avatar Sep 13 '16 04:09 viviancpy