-
Notifications
You must be signed in to change notification settings - Fork 27
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
Return String
should be nullable, no?
#309
Comments
This is similar to #181. The IDL claims the return type is non-nullable, but naturally it would be nice to coerce missing values to |
From what I observed in the idl specs, the behaviour isn't consistent. Some getters are non-nullable while some are defined nullable. I don't know yet what determines that though. But it would be nice to make this nullable as the users won't have to remember to check for the nullable case by using |
Some properties defined in `package:web/web.dart` are defined as non-nullable, while some browsers don't support them. In my case, `aspectRatio` is not defined for [Firefox](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings/aspectRatio#browser_compatibility). This seems to be a problem with the IDL itself being inconsistent (see dart-lang/web#309). Checking availability before accessing the fields seems to be an endorsed method: dart-lang/web#181 (comment)
Some properties defined in `package:web/web.dart` are defined as non-nullable, while some browsers don't support them. In my case, `aspectRatio` is not defined for [Firefox](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings/aspectRatio#browser_compatibility). This seems to be a problem with the IDL itself being inconsistent (see dart-lang/web#309). Checking availability before accessing the fields seems to be an endorsed method: dart-lang/web#181 (comment)
I think it's just a matter of whether the value is allowed to be null or not in most cases. IME, if a getter cast fails due to a null exception, it's usually because the browser/context doesn't set that field, but the IDL dictates it should be, which then requires feature detection. An example of why you might still want to use I do recognize there's friction with having to use |
Some properties defined in `package:web/web.dart` are defined as non-nullable, while some browsers don't support them. In my case, `aspectRatio` is not defined for [Firefox](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings/aspectRatio#browser_compatibility). This seems to be a problem with the IDL itself being inconsistent (see dart-lang/web#309). Checking availability before accessing the fields seems to be an endorsed method: dart-lang/web#181 (comment)
This is a super surprising bug that prevents easy migration. From the API I'd expect it to be returning empty value or throw an Exception, but instead we are getting Please fix this, or at minimum put up big warning signs in the documentation. |
Sorry - for clarification, you should be seeing an exception in Dart when the value is missing. Specifically, you should see a cast from null to
I'm okay adding a warning here for this getter that the code will throw if the value is missing or |
web/web/lib/src/dom/html.dart
Line 1281 in 6538aca
CC @srujzs
The text was updated successfully, but these errors were encountered: