Skip to content

Commit

Permalink
Fix for define(name, factory).
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Mar 5, 2018
1 parent d892280 commit 4001f0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ function isexports(name) {
}

function define(name, dependencies, factory) {
if (arguments.length < 3) factory = dependencies, dependencies = name;
if (arguments.length < 2) factory = dependencies, dependencies = [];
var n = arguments.length;
if (n < 2) factory = name, dependencies = [];
else if (n < 3) factory = dependencies, dependencies = typeof name === "string" ? [] : name;
queue.push(some.call(dependencies, isexports) ? function(require) {
var exports = {};
return Promise.all(map.call(dependencies, function(name) {
Expand Down
9 changes: 9 additions & 0 deletions test/test-cellauto.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<script src="/build/d3-require.js"></script>
<script>

d3.require("https://cdn.rawgit.com/sanojian/cellauto/a72966c7e422b4c66f8ad0e0de3a8633055c77be/dist/cellauto.js").then($ => {
console.log($);
});

</script>

0 comments on commit 4001f0f

Please sign in to comment.