OLD | NEW |
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 bool isJavaScriptPromise(value) => | 84 bool isJavaScriptPromise(value) => |
85 JS('bool', r'typeof Promise != "undefined" && # instanceof Promise', value); | 85 JS('bool', r'typeof Promise != "undefined" && # instanceof Promise', value); |
86 | 86 |
87 Future convertNativePromiseToDartFuture(promise) { | 87 Future convertNativePromiseToDartFuture(promise) { |
88 var completer = new Completer(); | 88 var completer = new Completer(); |
89 var then = convertDartClosureToJS((result) => completer.complete(result), 1); | 89 var then = convertDartClosureToJS((result) => completer.complete(result), 1); |
90 var error = convertDartClosureToJS((result) => completer.completeError(result)
, 1); | 90 var error = convertDartClosureToJS((result) => completer.completeError(result)
, 1); |
91 var newPromise = JS('', '#.then(#).catch(#)', promise, then, error); | 91 var newPromise = JS('', '#.then(#).catch(#)', promise, then, error); |
92 return completer.future; | 92 return completer.future; |
93 } | 93 } |
| 94 |
| 95 /// Wrap a JS object with an instance of the matching dart:html class. Used only
in Dartium. |
| 96 wrap_jso(jsObject) => jsObject; |
| 97 |
| 98 /// Find the underlying JS object for a dart:html Dart object. |
| 99 unwrap_jso(dartClass_instance) => dartClass_instance; |
OLD | NEW |