forked from reactjs/react-modal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[change] Track open body className appropriately
- Loading branch information
Showing
9 changed files
with
100 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
const modals = []; | ||
const modals = {}; | ||
|
||
export function add(element) { | ||
if (modals.indexOf(element) === -1) { | ||
modals.push(element); | ||
export function add(bodyClass) { | ||
// Set variable and default if none | ||
if (!modals[bodyClass]) { | ||
modals[bodyClass] = 0; | ||
} | ||
modals[bodyClass] += 1; | ||
} | ||
|
||
export function remove(element) { | ||
const index = modals.indexOf(element); | ||
if (index === -1) { | ||
return; | ||
export function remove(bodyClass) { | ||
if (modals[bodyClass]) { | ||
modals[bodyClass] -= 1; | ||
} | ||
modals.splice(index, 1); | ||
} | ||
|
||
export function count() { | ||
return modals.length; | ||
export function count(bodyClass) { | ||
return modals[bodyClass]; | ||
} | ||
|
||
export function totalCount() { | ||
return Object.keys(modals).reduce((acc, curr) => acc + modals[curr], 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import ExecutionEnvironment from 'exenv'; | ||
|
||
const EE = ExecutionEnvironment; | ||
|
||
const SafeHTMLElement = EE.canUseDOM ? window.HTMLElement : {}; | ||
|
||
export default SafeHTMLElement; |