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. 18
      test/form/computed-properties/_expected/amd.js
  3. 12
      test/form/computed-properties/_expected/cjs.js
  4. 11
      test/form/computed-properties/_expected/es6.js
  5. 20
      test/form/computed-properties/_expected/iife.js
  6. 24
      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;

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

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

12
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'};
exports.x = x;
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 };

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

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

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

@ -1,13 +1,23 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.computedProperties = {})));
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.computedProperties = {})));
}(this, function (exports) { 'use strict';
var foo = 'foo';
var foo = 'foo';
var bar = 'bar';
var baz = 'baz';
var bam = 'bam';
var x = {[foo]: 'bar'};
var x = {[foo]: 'bar'};
exports.x = x;
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