0

我使用了一个使用 requirejs 的外部库我不知道它是如何工作的,但是 FileError 在其他浏览器或 FF8 的全局范围内,但在 FF 14/15 中说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;
});

当然,如果我 window.FileError = NativeFileSystem.FileError; 在函数定义之后添加它就可以正常工作。但我不想破解库 文件的完整来源在这里

4

1 回答 1

1

括号仅对错误代码常量依赖 FileError 类。

FileAPI 仍然是一个草案规范http://www.w3.org/TR/FileAPI/并且似乎在我们最初编写 NativeFileSystem 的时候他们已经将 FileError 更改为 DOMError。我们可以删除这个依赖并定义我们自己的等效 FileError 常量来删除依赖。我们试图在 FileAPI 之后对我们的 API 进行建模,但它一直是一个移动的目标。

于 2012-10-19T16:22:42.933 回答