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

Side by Side Diff: lib/html/templates/html/dart2js/factoryprovider_Blob.darttemplate

Issue 11094082: Convert legacy 'native code' to JS-forms in dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class $FACTORYPROVIDER { 5 class $FACTORYPROVIDER {
6 static Blob createBlob([List blobParts = null, String type, String endings]) { 6 static Blob createBlob([List blobParts = null, String type, String endings]) {
7 // TODO: validate that blobParts is a JS Array and convert if not. 7 // TODO: validate that blobParts is a JS Array and convert if not.
8 // TODO: any coercions on the elements of blobParts, e.g. coerce a typed 8 // TODO: any coercions on the elements of blobParts, e.g. coerce a typed
9 // array to ArrayBuffer if it is a total view. 9 // array to ArrayBuffer if it is a total view.
10 if (type == null && endings == null) { 10 if (type == null && endings == null) {
11 return _create_1(blobParts); 11 return _create_1(blobParts);
12 } 12 }
13 var bag = _create_bag(); 13 var bag = _create_bag();
14 if (type != null) _bag_set(bag, 'type', type); 14 if (type != null) _bag_set(bag, 'type', type);
15 if (endings != null) _bag_set(bag, 'endings', endings); 15 if (endings != null) _bag_set(bag, 'endings', endings);
16 return _create_2(blobParts, bag); 16 return _create_2(blobParts, bag);
17 } 17 }
18 18
19 static _create_1(parts) native 'return new Blob(parts);'; 19 static _create_1(parts) => JS('Blob', 'new Blob(#)', parts);
20 static _create_2(parts, bag) native 'return new Blob(parts, bag);'; 20 static _create_2(parts, bag) => JS('Blob', 'new Blob(#, #)', parts, bag);
21 21
22 static _create_bag() native 'return {}'; 22 static _create_bag() => JS('var', '{}');
23 static _bag_set(bag, key, value) native 'bag[key] = value;'; 23 static _bag_set(bag, key, value) { JS('void', '#[#] = #', bag, key, value); }
24 } 24 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698