OLD | NEW |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 part of html; |
| 6 |
| 7 /// @domName $DOMNAME |
| 8 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 9 $!MEMBERS |
| 10 $if DART2JS |
1 static Blob _create([List blobParts = null, String type, String endings]) { | 11 static Blob _create([List blobParts = null, String type, String endings]) { |
2 // TODO: validate that blobParts is a JS Array and convert if not. | 12 // TODO: validate that blobParts is a JS Array and convert if not. |
3 // TODO: any coercions on the elements of blobParts, e.g. coerce a typed | 13 // TODO: any coercions on the elements of blobParts, e.g. coerce a typed |
4 // array to ArrayBuffer if it is a total view. | 14 // array to ArrayBuffer if it is a total view. |
5 if (type == null && endings == null) { | 15 if (type == null && endings == null) { |
6 return _create_1(blobParts); | 16 return _create_1(blobParts); |
7 } | 17 } |
8 var bag = _create_bag(); | 18 var bag = _create_bag(); |
9 if (type != null) _bag_set(bag, 'type', type); | 19 if (type != null) _bag_set(bag, 'type', type); |
10 if (endings != null) _bag_set(bag, 'endings', endings); | 20 if (endings != null) _bag_set(bag, 'endings', endings); |
11 return _create_2(blobParts, bag); | 21 return _create_2(blobParts, bag); |
12 } | 22 } |
13 | 23 |
14 static _create_1(parts) => JS('Blob', 'new Blob(#)', parts); | 24 static _create_1(parts) => JS('Blob', 'new Blob(#)', parts); |
15 static _create_2(parts, bag) => JS('Blob', 'new Blob(#, #)', parts, bag); | 25 static _create_2(parts, bag) => JS('Blob', 'new Blob(#, #)', parts, bag); |
16 | 26 |
17 static _create_bag() => JS('var', '{}'); | 27 static _create_bag() => JS('var', '{}'); |
18 static _bag_set(bag, key, value) { JS('void', '#[#] = #', bag, key, value); } | 28 static _bag_set(bag, key, value) { JS('void', '#[#] = #', bag, key, value); } |
| 29 $endif |
| 30 } |
| 31 |
OLD | NEW |