Browse Source

Merge branch 'retain-class-computed-property-symbols' of https://github.com/ochafik/rollup into ochafik-retain-class-computed-property-symbols

gh-669
Rich-Harris 9 years ago
parent
commit
8f270e3266
  1. 5
      src/ast/isReference.js
  2. 10
      test/form/computed-properties/_expected/amd.js
  3. 10
      test/form/computed-properties/_expected/cjs.js
  4. 11
      test/form/computed-properties/_expected/es6.js
  5. 10
      test/form/computed-properties/_expected/iife.js
  6. 10
      test/form/computed-properties/_expected/umd.js
  7. 9
      test/form/computed-properties/main.js

5
src/ast/isReference.js

@ -10,7 +10,10 @@ export default function isReference ( node, parent ) {
if ( !parent ) return true;
// TODO is this right?
if ( parent.type === 'MemberExpression' ) return parent.computed || node === parent.object;
if ( parent.type === 'MemberExpression' ||
parent.type === 'MethodDefinition' ) {
return parent.computed || node === parent.object;
}
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
if ( parent.type === 'Property' ) return parent.computed || node === parent.value;

10
test/form/computed-properties/_expected/amd.js

@ -1,9 +1,19 @@
define(['exports'], function (exports) { 'use strict';
var foo = 'foo';
var bar = 'bar';
var baz = 'baz';
var bam = 'bam';
var x = {[foo]: 'bar'};
class X {
[bar]() {}
get [baz]() {}
set [bam](value) {}
}
exports.x = x;
exports.X = X;
});

10
test/form/computed-properties/_expected/cjs.js

@ -1,7 +1,17 @@
'use strict';
var foo = 'foo';
var bar = 'bar';
var baz = 'baz';
var bam = 'bam';
var x = {[foo]: 'bar'};
class X {
[bar]() {}
get [baz]() {}
set [bam](value) {}
}
exports.x = x;
exports.X = X;

11
test/form/computed-properties/_expected/es6.js

@ -1,5 +1,14 @@
var foo = 'foo';
var bar = 'bar';
var baz = 'baz';
var bam = 'bam';
var x = {[foo]: 'bar'};
export { x };
class X {
[bar]() {}
get [baz]() {}
set [bam](value) {}
}
export { x, X };

10
test/form/computed-properties/_expected/iife.js

@ -2,9 +2,19 @@
'use strict';
var foo = 'foo';
var bar = 'bar';
var baz = 'baz';
var bam = 'bam';
var x = {[foo]: 'bar'};
class X {
[bar]() {}
get [baz]() {}
set [bam](value) {}
}
exports.x = x;
exports.X = X;
}((this.computedProperties = {})));

10
test/form/computed-properties/_expected/umd.js

@ -5,9 +5,19 @@
}(this, function (exports) { 'use strict';
var foo = 'foo';
var bar = 'bar';
var baz = 'baz';
var bam = 'bam';
var x = {[foo]: 'bar'};
class X {
[bar]() {}
get [baz]() {}
set [bam](value) {}
}
exports.x = x;
exports.X = X;
}));

9
test/form/computed-properties/main.js

@ -1,3 +1,12 @@
var foo = 'foo';
var bar = 'bar';
var baz = 'baz';
var bam = 'bam';
export var x = {[foo]: 'bar'};
export class X {
[bar]() {}
get [baz]() {}
set [bam](value) {}
}

Loading…
Cancel
Save