Browse Source

deconflict-classes

gh-953
Rich-Harris 8 years ago
parent
commit
16da86e93c
  1. 6
      src/ast/nodes/ClassDeclaration.js
  2. 4
      test/function/deconflicts-classes/_config.js
  3. 2
      test/function/deconflicts-classes/a.js
  4. 2
      test/function/deconflicts-classes/b.js
  5. 4
      test/function/deconflicts-classes/main.js

6
src/ast/nodes/ClassDeclaration.js

@ -18,7 +18,7 @@ export default class ClassDeclaration extends Node {
}
getName () {
return this.id.name;
return this.name;
}
hasEffects () {
@ -26,7 +26,9 @@ export default class ClassDeclaration extends Node {
}
initialise ( scope ) {
scope.addDeclaration( this.id.name, this, false, false );
this.name = this.id.name;
scope.addDeclaration( this.name, this, false, false );
super.initialise( scope );
}

4
test/function/deconflicts-classes/_config.js

@ -0,0 +1,4 @@
module.exports = {
solo: true,
description: 'deconflicts top-level classes'
};

2
test/function/deconflicts-classes/a.js

@ -0,0 +1,2 @@
var Foo = function Foo () {};
export { Foo };

2
test/function/deconflicts-classes/b.js

@ -0,0 +1,2 @@
class Foo {};
export { Foo };

4
test/function/deconflicts-classes/main.js

@ -0,0 +1,4 @@
import { Foo as A } from './a.js';
import { Foo as B } from './b.js';
assert.notEqual( A, B );
Loading…
Cancel
Save