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

Side by Side Diff: sdk/lib/html/html_common/conversions_dart2js.dart

Issue 1355913002: isJavaScriptPromise needs to handle Promise not being defined (IE) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 part of html_common; 1 part of html_common;
2 2
3 /// Converts a JavaScript object with properties into a Dart Map. 3 /// Converts a JavaScript object with properties into a Dart Map.
4 /// Not suitable for nested objects. 4 /// Not suitable for nested objects.
5 Map convertNativeToDart_Dictionary(object) { 5 Map convertNativeToDart_Dictionary(object) {
6 if (object == null) return null; 6 if (object == null) return null;
7 var dict = {}; 7 var dict = {};
8 var keys = JS('JSExtendableArray', 'Object.getOwnPropertyNames(#)', object); 8 var keys = JS('JSExtendableArray', 'Object.getOwnPropertyNames(#)', object);
9 for (final key in keys) { 9 for (final key in keys) {
10 dict[key] = JS('var', '#[#]', object, key); 10 dict[key] = JS('var', '#[#]', object, key);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 bool isJavaScriptDate(value) => JS('bool', '# instanceof Date', value); 74 bool isJavaScriptDate(value) => JS('bool', '# instanceof Date', value);
75 bool isJavaScriptRegExp(value) => JS('bool', '# instanceof RegExp', value); 75 bool isJavaScriptRegExp(value) => JS('bool', '# instanceof RegExp', value);
76 bool isJavaScriptArray(value) => JS('bool', '# instanceof Array', value); 76 bool isJavaScriptArray(value) => JS('bool', '# instanceof Array', value);
77 bool isJavaScriptSimpleObject(value) { 77 bool isJavaScriptSimpleObject(value) {
78 var proto = JS('', 'Object.getPrototypeOf(#)', value); 78 var proto = JS('', 'Object.getPrototypeOf(#)', value);
79 return JS('bool', '# === Object.prototype', proto) || 79 return JS('bool', '# === Object.prototype', proto) ||
80 JS('bool', '# === null', proto); 80 JS('bool', '# === null', proto);
81 } 81 }
82 bool isImmutableJavaScriptArray(value) => 82 bool isImmutableJavaScriptArray(value) =>
83 JS('bool', r'!!(#.immutable$list)', value); 83 JS('bool', r'!!(#.immutable$list)', value);
84 bool isJavaScriptPromise(value) => JS('bool', r'# instanceof Promise', value); 84 bool isJavaScriptPromise(value) =>
85 JS('bool', r'typeof Promise != "undefined" && # instanceof Promise', value);
85 86
86 Future convertNativePromiseToDartFuture(promise) { 87 Future convertNativePromiseToDartFuture(promise) {
87 var completer = new Completer(); 88 var completer = new Completer();
88 var then = convertDartClosureToJS((result) => completer.complete(result), 1); 89 var then = convertDartClosureToJS((result) => completer.complete(result), 1);
89 var error = convertDartClosureToJS((result) => completer.completeError(result) , 1); 90 var error = convertDartClosureToJS((result) => completer.completeError(result) , 1);
90 var newPromise = JS('', '#.then(#).catch(#)', promise, then, error); 91 var newPromise = JS('', '#.then(#).catch(#)', promise, then, error);
91 return completer.future; 92 return completer.future;
92 } 93 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698