-
Notifications
You must be signed in to change notification settings - Fork 119
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
Remove ternary within if else to see logic error better #63
Comments
An solution for issue -:chromium#63
so I replaced with if else . If its okay then I can replace others too waiting for your feedback . |
Although I would suggest finding a way to word your suggestions more constructively with the future and don't think ternary is an issue here, I agree that the braces of the However, we can make the code ever easier to maintain by making it more DRY. Since the function calls are the same, the most idiomatic choice could be to use nullish coalescing: (navigator.mediaDevices ?? navigator).getUserMedia(
{video: true}).then(
displayOutcome("camera", "success"),
displayOutcome("camera", "error")
) However, since we don't transpile the code we should stick to older syntax for maximum compatibility with older browser: (navigator.mediaDevices || navigator).getUserMedia(
{video: true}).then(
displayOutcome("camera", "success"),
displayOutcome("camera", "error")
) At that point, I would recommend reusing the calculation as well: var getUserMediaThis = navigator.mediaDevices || navigator; // Place below the existing `navigator.getUserMedia` fallback assignment.
var getUserMedia = getUserMediaThis.getUserMedia.bind(getUserMediaThis);
// …
getUserMedia(
{video: true}).then(
displayOutcome("camera", "success"),
displayOutcome("camera", "error")
) I'll leave the choice to @engedy. |
Common guys, don't use ternary operator, replace it within if else to see logic errors more faster, next error is too childish -_-
Example:
https://github.com/chromium/permission.site/blob/master/index.js#L108
Uncaught TypeError: navigator.getUserMedia is not a function
And same in lot of other places
The text was updated successfully, but these errors were encountered: