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

Replaces .includes with a regex for a better IE compatibility #1096

Merged
merged 2 commits into from
Dec 8, 2019

Conversation

n1ghtmare
Copy link
Collaborator

This is to address: #76

@n1ghtmare n1ghtmare requested review from daynin and STRML December 7, 2019 21:43
Copy link
Collaborator

@STRML STRML left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would change the style a bit for readability

@@ -101,7 +101,7 @@ const layoutClassName = "react-grid-layout";
let isFirefox = false;
// Try...catch will protect from navigator not existing (e.g. node) or a bad implementation of navigator
try {
isFirefox = navigator.userAgent.toLowerCase().includes("firefox");
isFirefox = new RegExp("firefox").test(navigator.userAgent.toLowerCase());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isFirefox = new RegExp("firefox").test(navigator.userAgent.toLowerCase());
isFirefox = /firefox/i.test(navigator.userAgent);

@@ -721,7 +721,7 @@ export default class ReactGridLayout extends React.Component<Props, State> {
// to avoid unpredictable jumping of a dropping placeholder
if (
isFirefox &&
!e.nativeEvent.target.className.includes(layoutClassName)
!(new RegExp(layoutClassName).test(e.nativeEvent.target.className))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!(new RegExp(layoutClassName).test(e.nativeEvent.target.className))
e.nativeEvent.target.className.indexOf(layoutClassName) === -1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree about the readability and I've done the changes. Should be fine now.

@STRML STRML merged commit 92be169 into master Dec 8, 2019
@STRML STRML deleted the n1ghtmare-patch-1 branch December 8, 2019 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants