Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making sure to actually set __CANJS_DEVTOOLS__ global #50

Merged
merged 1 commit into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions can-debug-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ testHelpers.dev.devOnlyTest("calls window.__CANJS_DEVTOOLS__.register if availab
testHelpers.dev.devOnlyTest("calls window.__CANJS_DEVTOOLS__.register if __CANJS_DEVTOOLS__ is set later", function(assert) {
var done = assert.async();
var fakeWindow = {};
var fakeDevtoolsGlobal = {
register: function(can) {
assert.ok("Symbol" in can, "can.Symbol passed");
assert.ok("Reflect" in can, "can.Reflect passed");
assert.ok("queues" in can, "can.queues passed");
assert.ok("getGraph" in can, "can.getGraph passed");
assert.ok("formatGraph" in can, "can.formatGraph passed");
assert.ok("mergeDeep" in can, "can.mergeDeep passed");

assert.equal(fakeWindow.__CANJS_DEVTOOLS__, fakeDevtoolsGlobal, "sets window.__CANJS_DEVTOOLS__");

done();
}
};

clone({
"can-globals": {
Expand All @@ -89,16 +103,6 @@ testHelpers.dev.devOnlyTest("calls window.__CANJS_DEVTOOLS__.register if __CANJS
})
.import("can-debug")
.then(function() {
fakeWindow.__CANJS_DEVTOOLS__ = {
register: function(can) {
assert.ok("Symbol" in can, "can.Symbol passed");
assert.ok("Reflect" in can, "can.Reflect passed");
assert.ok("queues" in can, "can.queues passed");
assert.ok("getGraph" in can, "can.getGraph passed");
assert.ok("formatGraph" in can, "can.formatGraph passed");
assert.ok("mergeDeep" in can, "can.mergeDeep passed");
done();
}
};
fakeWindow.__CANJS_DEVTOOLS__ = fakeDevtoolsGlobal;
});
});
15 changes: 10 additions & 5 deletions can-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,19 @@ var devtoolsCanModules = {
formatGraph: namespace.debug.formatGraph,
mergeDeep: mergeDeep
};
var devtoolsGlobalName = "__CANJS_DEVTOOLS__";

if (global.__CANJS_DEVTOOLS__) {
global.__CANJS_DEVTOOLS__.register(devtoolsCanModules);
if (global[devtoolsGlobalName]) {
global[devtoolsGlobalName].register(devtoolsCanModules);
} else {
Object.defineProperty(global, "__CANJS_DEVTOOLS__", {
Object.defineProperty(global, devtoolsGlobalName, {
set: function(devtoolsGlobal) {
Object.defineProperty(global, devtoolsGlobalName, {
value: devtoolsGlobal
});

devtoolsGlobal.register(devtoolsCanModules);
return devtoolsGlobal;
}
},
configurable: true
});
}