aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Lihotzki <lukas@lihotzki.de>2020-10-03 03:46:15 +0200
committerLukas Lihotzki <lukas@lihotzki.de>2020-10-03 03:46:15 +0200
commit6611165bffdfb5b1096a755ca78488bfee8486c1 (patch)
tree2af4f644addedbeaecb164b72a7d33a28a3d9793
parentadd885c8744b9fbd6dc213c01c5355c4773603fe (diff)
do not pollute the global object
-rw-r--r--javascript/olm_prefix.js1
-rw-r--r--javascript/olm_suffix.js8
2 files changed, 7 insertions, 2 deletions
diff --git a/javascript/olm_prefix.js b/javascript/olm_prefix.js
index b33dfe9..ae2d9f9 100644
--- a/javascript/olm_prefix.js
+++ b/javascript/olm_prefix.js
@@ -1,3 +1,4 @@
+var Olm = (function() {
var olm_exports = {};
var onInitSuccess;
var onInitFail;
diff --git a/javascript/olm_suffix.js b/javascript/olm_suffix.js
index 3e2f664..d6f72b7 100644
--- a/javascript/olm_suffix.js
+++ b/javascript/olm_suffix.js
@@ -17,16 +17,20 @@ olm_exports['init'] = function(opts) {
return olmInitPromise;
};
+return olm_exports;
+
+})();
+
if (typeof(window) !== 'undefined') {
// We've been imported directly into a browser. Define the global 'Olm' object.
// (we do this even if module.exports was defined, because it's useful to have
// Olm in the global scope for browserified and webpacked apps.)
- window["Olm"] = olm_exports;
+ window["Olm"] = Olm;
}
if (typeof module === 'object') {
// Emscripten sets the module exports to be its module
// with wrapped c functions. Clobber it with our higher
// level wrapper class.
- module.exports = olm_exports;
+ module.exports = Olm;
}