Skip to content

Commit

Permalink
Merge pull request #1222 from stealjs/1221-dynamic-clones
Browse files Browse the repository at this point in the history
Fix bug with supporting multiple contextual modules of one type
  • Loading branch information
matthewp committed Jul 3, 2017
2 parents 115a8f0 + 65abac0 commit 5e35152
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/system-extension-contextual.js
Expand Up @@ -17,7 +17,7 @@ addStealExtension(function (loader) {
if (definer) {
var localName = name + '/' + parentName;

if(!loader.has(name)) {
if(!loader.has(localName)) {
// `definer` could be a function or could be a moduleName
if (typeof definer === 'string') {
definer = pluginLoader['import'](definer);
Expand Down
5 changes: 5 additions & 0 deletions test/ext-steal-clone/multiple/first-test.js
@@ -0,0 +1,5 @@
var clone = require("steal-clone");

module.exports = function(){
return clone({}).import("./first")
}
1 change: 1 addition & 0 deletions test/ext-steal-clone/multiple/first.js
@@ -0,0 +1 @@
module.exports = {name: "first"};
18 changes: 18 additions & 0 deletions test/ext-steal-clone/multiple/index.html
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>clone tests</title>
</head>
<body>
<script>
window.done = window.parent.done;
window.assert = window.parent.assert;
</script>
<script type="text/javascript"
src="../../../steal.js"
data-config="../../config.js"
data-main="ext-steal-clone/multiple/test"></script>
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions test/ext-steal-clone/multiple/second-runs-tests.js
@@ -0,0 +1,5 @@
var clone = require("steal-clone");

module.exports = function(){
return clone({}).import('./second')
};
1 change: 1 addition & 0 deletions test/ext-steal-clone/multiple/second-test.js
@@ -0,0 +1 @@
module.exports = require("./second-runs-tests");
1 change: 1 addition & 0 deletions test/ext-steal-clone/multiple/second.js
@@ -0,0 +1 @@
module.exports = {name: "second"};
18 changes: 18 additions & 0 deletions test/ext-steal-clone/multiple/test.js
@@ -0,0 +1,18 @@
var doClone1 = require("./first-test");
var doClone2 = require("./second-test");

Promise.all([doClone1(), doClone2()]).then(function(){
if (typeof window !== "undefined" && window.assert) {
assert.ok(true, "promises resolved");
done();
} else {
console.log("worked");
}
}, function(){
if (typeof window !== "undefined" && window.assert) {
assert.ok(false, "promises failed");
done();
} else {
console.log("promises failed");
}
});
5 changes: 5 additions & 0 deletions test/steal_clone_test.js
Expand Up @@ -49,3 +49,8 @@ QUnit.test("works when using relative overrides", function(assert) {
QUnit.test("what happens within a cloned loader should not leak", function(assert) {
makeIframe("ext-steal-clone/leak/index.html", assert);
});


QUnit.test("multiple clones can work at different paths", function(assert) {
makeIframe("ext-steal-clone/multiple/index.html", assert);
});

0 comments on commit 5e35152

Please sign in to comment.