-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assign globals in mock-dom module, instead of attaching everything to…
… jQuery
- Loading branch information
Showing
6 changed files
with
69 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,17 @@ exports.createDom = function(callback) { | |
html: "", | ||
src: [axsSrc, jquerySrc, jqueryExtSrc], | ||
done: function(errors, window) { | ||
// Expose some fields from `window` onto the global namespace | ||
// | ||
// TODO: Currently we add fields here (see "Node") as we need | ||
// them, but this may prove tricky to maintain. | ||
global.__proto__ = { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jdan
Author
Owner
|
||
document: window.document, | ||
$: window.jQuery, | ||
axs: window.axs, | ||
Node: window.Node, | ||
}; | ||
|
||
// Overwrite the default module loader. | ||
// | ||
// Here we intercept `require()` calls to stub out the annotations | ||
|
@@ -61,17 +72,7 @@ exports.createDom = function(callback) { | |
} | ||
}; | ||
|
||
callback({ | ||
setHTML(html) { | ||
window.document.body.innerHTML = html; | ||
}, | ||
|
||
destroy() { | ||
window.close(); | ||
}, | ||
|
||
$: window.jQuery, | ||
}); | ||
callback(); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This seems kinda sketchy. I tend to avoid
__proto__
so my experience is limited, but I thought this sort of reassignment was discouraged? You know better than I do.I'm lacking a lot of context here, but is it possible to avoid using
__proto__
altogether?global = window
sounds too easy... but... something?