Skip to content

Distribution files pollute global namespace #1

@kwiskia

Description

@kwiskia

The distribution files arrow.js and parser.js create a lot of variables on the global namespace, or window when loaded when loaded via web browser.

Replication

  • Load a web application with arrows.
  • Open browser development console.
  • Variables that should be private are in the window namespace. E.g., _cancelerId, numannotations, etc.

Possible fix
Wrap distribution source in an IIFE, and manually attach public functions/variables to the window namespace.

(function() {
    "use strict";

    // ... code for arrows goes here ...

    window.Arrows = Arrows;
})();

Alternatively, the issue could be resolved by using AMD and CommonJS style definitions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions