Frage

I use a external library that uses requirejs I don't know how its work but FileError is in the global scope in other browser or in FF8 but in FF 14/15 says FileError not defined.

define(function (require, exports, module) {   
   "use strict";
    var Async = require("utils/Async");
    var NativeFileSystem = {
    /**
     * LOT OF CODE HERE
     * ...
     * ...
     * ...
    */       
    /** class: FileError
     *
     * Implementation of HTML file API error code return class. Note that we don't
     * actually define the error codes here--we rely on the browser's built-in FileError
     * class's constants. In other words, external clients of this API should always
     * use FileError.<constant-name>, not NativeFileSystem.FileError.<constant-name>.
     *
     * @constructor
     * @param {number} code The error code to return with this FileError. Must be
     * one of the codes defined in the FileError class.
     */
    NativeFileSystem.FileError = function (code) {
        this.code = code || 0;
    };
    /**
     *THIS FIX THE PROBLEM BUT IT A HACK
     *window.FileError = NativeFileSystem.FileError;
     */
    // Define public API
    exports.NativeFileSystem    = NativeFileSystem;
});

Of course if I add window.FileError = NativeFileSystem.FileError; after the function definition its work fine. But I don't want hack the library The full source of the file is here

War es hilfreich?

Lösung

Brackets relies on the FileError class only for the error code constants.

The FileAPI is still a draft spec http://www.w3.org/TR/FileAPI/ and it appears they have changed FileError to DOMError in the time since we originally wrote NativeFileSystem. We could remove this dependency and define our own equivalent FileError constants to remove the dependency. We were attempting to model our API after the FileAPI, but it's been a moving target.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top