-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Conversation
This is to address: #76
There was a problem hiding this 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
lib/ReactGridLayout.jsx
Outdated
@@ -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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isFirefox = new RegExp("firefox").test(navigator.userAgent.toLowerCase()); | |
isFirefox = /firefox/i.test(navigator.userAgent); |
lib/ReactGridLayout.jsx
Outdated
@@ -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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!(new RegExp(layoutClassName).test(e.nativeEvent.target.className)) | |
e.nativeEvent.target.className.indexOf(layoutClassName) === -1 |
There was a problem hiding this comment.
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.
This is to address: #76