Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Unified Diff: sdk/lib/js/dart2js/js_dart2js.dart

Issue 437733002: Fix inconsistency with null vs undefined in dart:js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/lib/js/null_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/js/dart2js/js_dart2js.dart
diff --git a/sdk/lib/js/dart2js/js_dart2js.dart b/sdk/lib/js/dart2js/js_dart2js.dart
index 27fac2e1e9d2fb5a9ed64ce926cb0652556870cb..8e1b371f69cde75c37ddbdf5af83a8bb82c68d08 100644
--- a/sdk/lib/js/dart2js/js_dart2js.dart
+++ b/sdk/lib/js/dart2js/js_dart2js.dart
@@ -495,9 +495,10 @@ bool _isLocalObject(o) => JS('bool', '# instanceof Object', o);
final _dartProxyCtor = JS('', 'function DartObject(o) { this.o = o; }');
dynamic _convertToJS(dynamic o) {
- if (o == null) {
- return null;
- } else if (o is String || o is num || o is bool) {
+ // Note: we don't write `if (o == null) return null;` to make sure dart2js
+ // doesn't convert `return null;` into `return;` (which would make `null` be
+ // `undefined` in Javascprit). See dartbug.com/20305 for details.
+ if (o == null || o is String || o is num || o is bool) {
return o;
} else if (o is Blob || o is Event || o is KeyRange || o is ImageData
|| o is Node || o is TypedData || o is Window) {
« no previous file with comments | « no previous file | tests/lib/js/null_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698