fixed this scope in harmony imports

This commit is contained in:
Tobias Koppers 2016-02-13 09:33:30 +01:00
parent 417fdea9b6
commit 84eb9a2741
3 changed files with 29 additions and 2 deletions

View File

@ -38,10 +38,10 @@ HarmonyImportSpecifierDependency.Template = function HarmonyImportSpecifierDepen
HarmonyImportSpecifierDependency.Template.prototype.apply = function(dep, source) {
var content;
if(dep.id === "default" && !(dep.importDependency.module.meta && dep.importDependency.module.meta.harmonyModule)) {
content = "/* harmony import */ " + dep.importedVar + "_default.a";
content = "(/* harmony import */0," + dep.importedVar + "_default.a)";
} else if(dep.id) {
var used = dep.importDependency.module.isUsed(dep.id);
content = "/* harmony import */ " + dep.importedVar + "[" + JSON.stringify(used) + "]";
content = "(/* harmony import */0," + dep.importedVar + "[" + JSON.stringify(used) + "])";
} else {
content = "/* harmony namespace import */ " + dep.importedVar;
}

View File

@ -0,0 +1,15 @@
"use strict";
function returnThis() {
return this;
}
var a = returnThis;
var b = returnThis;
export {
a,
b
}
export default returnThis;

View File

@ -0,0 +1,12 @@
"use strict";
import d, {a, b as B} from "./abc";
import * as abc from "./abc";
it("should have this undefined on imported functions", function() {
(typeof d()).should.be.eql("undefined");
(typeof a()).should.be.eql("undefined");
(typeof B()).should.be.eql("undefined");
abc.a().should.be.eql(abc);
});