0

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

4castle
  • 32,613
  • 11
  • 69
  • 106
Rolando Corratge Nieves
  • 1,233
  • 2
  • 10
  • 25
  • I found this https://github.com/jrburke/requirejs/wiki/Differences-between-the-simplified-CommonJS-wrapper-and-standard-AMD-define#wiki-exports says that Properties added to the `exports` object will be on the public interface of the module, no need to return any value. – Rolando Corratge Nieves Oct 19 '12 at 14:14
  • It's not very clear to me how you are trying to access the `FileError` object, maybe you can post an example of the code that actually throws the error. – Alex Ciminian Oct 19 '12 at 14:27
  • The problem is not the `FileError` implementation the code is more bigger, is that is must be defined in global scope and don't do in all browsers this a library made for chrome embedded from the adobe-bracket project but the requirejs is for all browser – Rolando Corratge Nieves Oct 19 '12 at 15:15

1 Answers1

1

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.