I've been reading up on with() and trying to figure out how to rewrite this piece of code.
_$createRootItemAreas: function() {
var areaSize = 50;
var sides = { y2: 0, x2: 0, y1: 'y2', x1: 'x2' };
for( side in sides ) {
var area = this.root._$getArea();
area.side = side;
if( sides [ side ] )
area[ side ] = area[ sides [ side ] ] - areaSize;
else
area[ side ] = areaSize;
with( area )
surface = ( x2 - x1 ) * ( y2 - y1 );
this._itemAreas.push( area );
}
},
Should it be:
area.surface = ( x2 - x1 ) * ( y2 - y1 );
or
area.surface = ( area.x2 - area.x1 ) * ( area.y2 - area.y1 );
area.surface = ( area.x2 - area.x1 ) * ( area.y2 - area.y1 );
is the solution. I found another version of the same code where somebody had already fixed the issue and thus provided the solution.
Thank you to @Bergi for the explaintion.