Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#146 closed defect (fixed)

Compressor does not handle nested functions with identical parameter names correctly

Reported by: follower+dojo@… Owned by: anonymous
Priority: high Milestone:
Component: BuildTools Version: 0.1
Keywords: Cc:
Blocked By: Blocking:

Description

The compressor/ShrinkSafe does not seem to handle nested functions that have identical parameter names in both the inner and function outer functions.

The simplest example is probably:

function(foo) {
    function(foo) {};
    foo;
};

which generates:

function(_1){
function(_1){
}
foo;
}

Notice how the reference to foo in the body of the outer function does not get converted and the parameters of both functions get the same replacement value _1.

This is the actual piece of code with which I first noticed the problem:

OLPanTool.prototype.handleMapMouseDown = function(event, map) {
    var pt = event.getCursorPosition();
    map.startPan(pt.x,pt.y);
    
    var realThis = this;

    OLWindowManager.getDocument().addEventListener('mousemove',
                                       function(event) {
                                           return realThis.drag(event, map);
                                       });

    OLWindowManager.getDocument().addEventListener('mouseup',
                                       function(event) {
                                           return realThis.release(event, map);
                                       });

    OLWindowManager.getDocument().addEventListener('mouseout',
                                       function(event) {   
                                           if (!event.getRelatedTarget()) {
                                               return realThis.release(event,
                                                                       map);
                                           }
                                       });

    map.setMapCursor(OLWindowManager.DRAGGING_CURSOR);
    event.stopPropagation();
};

Change History (3)

comment:1 Changed 14 years ago by alex

Milestone: 0.2release

comment:2 Changed 14 years ago by alex

Resolution: fixed
Status: newclosed

(In [2041]) updates to make the compressor even safer and make shortened names even smaller

fixes #177 fixes #146

comment:3 Changed 12 years ago by (none)

Milestone: 0.2release

Milestone 0.2release deleted

Note: See TracTickets for help on using tickets.