Open jakemac53 opened 9 years ago
/cc @jacob314 @jmesserly - I recall we were having some discussions about this about a month ago
this should be solvable by changing the dart:js library. We don't want to wrap "undefined" in the Dart side of things though, so while we can pass undefined down, I would prefer that we continue to translate undefined to null when reading it back in Dart.
@sigmundch I agree. I think the cases where a JS api returns a value of null and undefined as different things are pretty rare. In that case you could always make a little wrapper js function which returns some other value for undefined.
Is there any workaround for that? indexeddb Index.count() and ObjectStore.count() on IE10/11/Edge12 seems to expect an undefined key, not a null key for counting all items
You can today create a js object which you use to represent undefined, and then wrap the functions on the js side, checking for that value and replacing it with undefined as necessary. Until we get real support I think that is the only option?
We could add a getter to js_util called "undefined". It will work great it in ddc and dart2js but in dartium it will be a bit wonky. Specifically in dart2js and dartium, it will work any time you would have used null but in dartium it will be strangely different from null. It will convert to undefined when passed to JS but otherwise it will look like an instance of some strange class (e.g. _JSUndefined).
FWIW, I'm fine with this. Since this is blocking people from using some major JS APIs (like Firebase, https://github.com/firebase/firebase-dart/pull/90) right now, I think it's worth it. _JSUndefined
seems like a good name to me.
Many apis on the JS side of things treat
null
andundefined
very differently. We need a way of explicitly passingundefined
via js interop.The easiest way is probably to define a top level const variable?