eligrey / Blob.js

An HTML5 Blob implementation
Other
1.15k stars 605 forks source link

Compatibility with the new Blob() #3

Closed minj closed 11 years ago

minj commented 11 years ago

You are redefining window.URL.createObjectURL which causes it to fail when given a Blob object in browsers that support it

minj commented 11 years ago

I work around it by prepending this to the declaration:

var BlobBuilder = (typeof (Blob) == 'function') && (function() {
    "use strict";
    var FakeBlobBuilder = function() {
        this.data = [];
    };
    var FBB_proto = FakeBlobBuilder.prototype;
    FBB_proto.append = function(data) {
        this.data.push(data);
    };
    FBB_proto.getBlob = function(type) {
        if (!arguments.length) {
            type = null;
        }
        return new Blob(this.data, { type: type });
    };
    FBB_proto.toString = function() {
        return "[object BlobBuilder]";
    };
    return FakeBlobBuilder;
})()

Although, in all likeliness the whole polyfill should be rewritten according to Blob() api

eligrey commented 11 years ago

I will get on updating BlobBuilder.js for the new API next week (or you can submit a pull request if you'd like to help). I'm very busy with finals this week.

gawry commented 11 years ago

Is there any updates in this problem?

eligrey commented 11 years ago

It will be fixed this weekend for sure.

eligrey commented 11 years ago

Fixed