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