[Project_owners] global namespace conflicts?

Mook mook.moz at gmail.com
Mon Jun 5 12:31:14 EDT 2006


On 6/2/06, Eric H. Jung <eric.jung at yahoo.com> wrote:
> Hi,
>
> Can variables defined in files in the components/ directory of a XPI conflict with variables defined by FF/Moz/NS/Flock and/or other extension? For example, the gQueryInterface function below as well as the CI, CC, and CR variables. My feeling it "no", it can't, but I want to make sure.
>
> components/MyXPCOMObject.js:
>
> const CI = Components.interfaces, CC = Components.classes, CR = Components.results;
<snip>

Components run in their own JS scope; there is no | window | object.
And since XUL windows actually store global variables as properties of
the | window | object, you can't conflict :)

In fact, each .js file gets its own scope; that makes JS components
nice in the sense that you no longer have to worry about conflicting
with other extensions (which is a rather annoying problem when your JS
runs in the window).

-- 
Mook
mook.moz at gmail


More information about the Project_owners mailing list