Skip to content

Commit

Permalink
fix(Dimmer|Modal): fix compatibility with IE (#1861)
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter authored and levithomason committed Jul 16, 2017
1 parent 164f750 commit 6eec9ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/modules/Dimmer/Dimmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,19 @@ export default class Dimmer extends Component {
static Dimmable = DimmerDimmable

handlePortalMount = () => {
if (isBrowser) document.body.classList.add('dimmed', 'dimmable')
if (!isBrowser) return

// Heads up, IE doesn't support second argument in add()
document.body.classList.add('dimmed')
document.body.classList.add('dimmable')
}

handlePortalUnmount = () => {
if (isBrowser) document.body.classList.remove('dimmed', 'dimmable')
if (!isBrowser) return

// Heads up, IE doesn't support second argument in add()
document.body.classList.remove('dimmed')
document.body.classList.remove('dimmable')
}

handleClick = (e) => {
Expand Down
10 changes: 8 additions & 2 deletions src/modules/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ class Modal extends Component {

if (dimmer) {
debug('adding dimmer')
mountNode.classList.add('dimmable', 'dimmed')
mountNode.classList.add('dimmable')
mountNode.classList.add('dimmed')

if (dimmer === 'blurring') {
debug('adding blurred dimmer')
Expand All @@ -213,7 +214,12 @@ class Modal extends Component {
// If the dimmer value changes while the modal is open, then removing its
// current value could leave cruft classes previously added.
const mountNode = this.getMountNode()
mountNode.classList.remove('blurring', 'dimmable', 'dimmed', 'scrollable')

// Heads up, IE doesn't support second argument in remove()
mountNode.classList.remove('blurring')
mountNode.classList.remove('dimmable')
mountNode.classList.remove('dimmed')
mountNode.classList.remove('scrollable')

cancelAnimationFrame(this.animationRequestId)

Expand Down

0 comments on commit 6eec9ce

Please sign in to comment.