Conversions between JavaScript objects and Maps.
Review URL: https://chromiumcodereview.appspot.com//10870030 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11208 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -38573,15 +38573,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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user