Browse Source

expand deshadowed shorthand properties (fixes #575)

gh-669
Rich-Harris 9 years ago
parent
commit
faf18821b3
  1. 3
      src/Module.js
  2. 1
      test/function/deshadowed-shorthand-property/_config.js

3
src/Module.js

@ -526,7 +526,8 @@ export default class Module {
if ( keys( toDeshadow ).length ) { if ( keys( toDeshadow ).length ) {
statement.references.forEach( reference => { statement.references.forEach( reference => {
if ( !reference.rewritten && reference.name in toDeshadow ) { if ( !reference.rewritten && reference.name in toDeshadow ) {
magicString.overwrite( reference.start, reference.end, toDeshadow[ reference.name ], true ); const replacement = toDeshadow[ reference.name ];
magicString.overwrite( reference.start, reference.end, reference.isShorthandProperty ? `${reference.name}: ${replacement}` : replacement, true );
} }
}); });
} }

1
test/function/deshadowed-shorthand-property/_config.js

@ -1,4 +1,3 @@
module.exports = { module.exports = {
solo: true,
description: 'shorthand properties referencing deshadowed variables are expanded' description: 'shorthand properties referencing deshadowed variables are expanded'
}; };

Loading…
Cancel
Save