mootools/Base — Issue #26: Accessors and Google Closure Compiler
Author: ibolmo
Created: 2011-10-10 15:12:43+00:00
State: open

@calyptus had mentioned that we should strive to be Google Closure Advanced compilation capable.

The Accessors API you can define [plural and singular](https://github.com/mootools/Base/blob/master/Source/Core/Accessor.js#L17-26) definitions and [plural and singular lookups](https://github.com/mootools/Base/blob/master/Source/Core/Accessor.js#L28-48).

The problem is that this dynamic behavior would be lost after compilation:

``` javascript

var CandyStore = new Accessor('Item');

var Candy = function(){};

var jello = new Candy;

var skittles = new Candy;

CandyStore.defineItem('jello', jello);

CandyStore.defineItems({

skittles: skittles,

snickers: new Candy

});
```

(potentially) to
```

var a = new A('Item');

var b = function(){};

var c = new b;

a.a('jello', jello); // a.a (CandyStore.defineItem) is undefined

a.b({ // a.b (CandyStore.defineItems) is undefined

d: c,

e: new b

});
```
For the above to work we would have to:

``` javascript

var a = new A('Item');

var b = function(){};

var c = new b;

a['defineItem']('jello', jello);

a['defineItems']({

d: c,

e: new b

});
```