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

Unified Diff: lib/html/src/dart2js_Conversions.dart

Issue 10870030: Conversions between JavaScript objects and Maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | « lib/html/dart2js/html_dart2js.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/html/src/dart2js_Conversions.dart
diff --git a/lib/html/src/dart2js_Conversions.dart b/lib/html/src/dart2js_Conversions.dart
index e0e2ff2289a80ecb885b053eb6acb83d41b8d3d6..8c6ab8372dc430c03cc9b8252b4a473c23612619 100644
--- a/lib/html/src/dart2js_Conversions.dart
+++ b/lib/html/src/dart2js_Conversions.dart
@@ -84,15 +84,23 @@ _convertDartToNative_ImageData(ImageData imageData) {
/// Converts a JavaScript object with properties into a Dart Map.
+/// Not suitable for nested objects.
Map _convertNativeToDart_Dictionary(object) {
// TODO: Implement.
- return object;
+ var dict = {};
+ for (final key in JS('List', 'Object.getOwnPropertyNames(#)', object)) {
+ dict[key] = JS('var', '#[#]', object, key);
+ }
+ return dict;
}
-/// Converts a Dart map into a JavaScript object with properties.
+/// Converts a flat Dart map into a JavaScript object with properties.
_convertDartToNative_Dictionary(Map dict) {
- // TODO: Implement.
- return dict;
+ var object = JS('var', '{}');
+ dict.forEach((String key, value) {
+ JS('void', '#[#] = #', object, key, value);
+ });
+ return object;
}
« no previous file with comments | « lib/html/dart2js/html_dart2js.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698