LivelyKernel / lively.ast

Parsing JS code into ASTs and tools to query and transform these trees.
4 stars 0 forks source link

Ensure keys of shorthand properties are not renamed while capturing #4

Closed levjj closed 8 years ago

levjj commented 8 years ago

Currently, shorthand properties are incorrectly replaced as seen below:

var x = 23,
    y = {x};

// =>

var _rec.x = 23;
    _rec.y = { _rec.x };

The resulting AST is not correct anymore because you cannot use a property expression as key. This PR ensures that the key and value of short-hand properties is split up and only the value gets replaced by the capturing expression.