-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Ignore null, undefined, and NaN is dimension() #1449
Conversation
Add vjs.isNaN to have a better cross browser isNaN checker. Previously, only undefined was ignored, so, it tried setting the dimension using null and NaN as values. In most browsers this isn't a problem, but in particular on IE8, things break. With this PR, all three of those values will be ignored.
What I think we might want here is some type checking and errors? The undefined check there is just to choose between the setter and getter operations, not a type check. By adding null and isNaN checks there we'd be returning the dimension for those values instead of allow them to error however they would. What was trying to set null and isNaN for the dimension? |
I rememer having issues with null previously. The NaN was coming from IE8. |
I don't think we want a value other than undefined to count as a getter. It's the difference between What was causing IE8 to pass NaN as a dimension? No matter what we add here it's still just protection against code that's passing in bad values that it shouldn't be, and probably doesn't mean to be. If it's something in video.js that's trying to set NaN as a dimension, it's more important that we fix that first. Our guide for how this should be handled is the video element API. It looks like if you set a width of NaN or null on the video element, it just changes the value to zero. No error thrown. |
While the code that was calling should definitely be fixed, videojs's code shouldn't fail hard when it gets bad input. This was a quick attempt to mitigate that. |
No, you're right. I wasn't trying to ignore that part so sorry if that's how it came across. Would you want to update this to match how the video element works? And do you think that's a good way to make it work? |
Would you be interested in updating this today and getting it into the release? |
Working on it. |
When dimension() receives a NaN or null value for the number, it will treat it as zero. Updated tests to reflect that as well.
@heff updated. |
thanks! |
Add vjs.isNaN to have a better cross browser isNaN checker.
Previously, only undefined was ignored, so, it tried setting the
dimension using null and NaN as values. In most browsers this isn't a
problem, but in particular on IE8, things break.
With this PR, all three of those values will be ignored.