Permalink
Browse files

Ensure that loadFile's response is always forEachable

  • Loading branch information...
1 parent 0c7ff82 commit bdb52b5f6568f2df52b058ac1ede496d33f53c1b @kriszyp committed Aug 22, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 media.js
View
@@ -64,7 +64,14 @@ Media.optimumMedia = function(source, acceptTypeHeader){
if("*/*" == type || mediaType == type){;
checkMedia({
serialize: function(){
- return exports.loadFile(alternate);
+ return {
+ // loadFile could return a promise
+ forEach: function(each){
+ return when(exports.loadFile(alternate), function(file){
+ file.forEach(each);
+ });
+ }
+ };
},
getQuality: function(){
return +(alternate.q || 0.5);

0 comments on commit bdb52b5

Please sign in to comment.