| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |