Skip to content

Commit

Permalink
quick fix #29 - solves bug in node that is not present in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
uladkasach committed Mar 16, 2018
1 parent 4f385fa commit c088b67
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clientside-require",
"version": "3.9.2",
"version": "3.9.3",
"description": "require() modules, js, css, html, and json in the browser with as little effort as loading jquery",
"main": "src/index.js",
"bundle": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/content_loading/commonjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
var exports = await this.helpers.extract_exports_from_frame(frame);

// destroy the frame now that we have the exports
this.helpers.remove_frame(frame);
if(typeof process == "undefined") this.helpers.remove_frame(frame); // do not remove iframe if we are using in node context (meaning we are using jsdom). TODO (#29) - figure how to preserve the window object (specifically window.document) after iframe is removed from parent

// return the exports
return exports;
Expand Down
3 changes: 2 additions & 1 deletion test/utilities/content_loading/commonjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ describe('commonjs', function(){
it('should define window in the modules environment', async function(){
var commonjs_loader = require(process.env.src_root + "/utilities/content_loading/commonjs.js");
var exports = await commonjs_loader.promise_to_retreive_exports(test_paths.reference_window, "async");
assert.equal(typeof exports, "object", "window.clientside_require should be defined");
assert.equal(typeof exports, "object", "window should be defined");
assert.equal(typeof exports.document, "object", "window.document should be defined");
})
it("should define window.clientside_require in the modules environment", async function(){
var commonjs_loader = require(process.env.src_root + "/utilities/content_loading/commonjs.js");
Expand Down

0 comments on commit c088b67

Please sign in to comment.