Skip to content

When setting a property inside a function the variable is not resolved properly #13

@migerh

Description

@migerh

Example:

brd=$board.setView([-4.35,2,4,-2],keepaspectratio=true);
O=point(0,0)<<name:'0'>>;
U=point(1,0)<<name:'1'>>;
X=line(O,U)<<withLabel:true,name:'x'>>;
P=point(2,1)<<name:'P'>>;
P.on('drag', function () {
    if(P.Y()>0) {
        U.color = 'green';
    } else {
        U.color = 'violet';
    }
});

translates to this:

function () {
var $oldscope$ = $jc$.scope;
$jc$.scope = $jc$.scopes[1];
var r = (function () {
 if (($jc$.resolve('P').Y() > 0)){
$jc$.setProp(U, 'color', 'green');
}
 else {
$jc$.setProp(U, 'color', 'violet');
}
}
)();
$jc$.scope = $oldscope$;
return r;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions