Skip to content

Commit 9fac2e4

Browse files
committed
UMD compatibility added
1 parent b7370fe commit 9fac2e4

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

jsStack.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
* License: Apache 2
55
* Author: https://elmah.io
66
*/
7-
(function() {
7+
8+
(function (root, factory) {
9+
if (typeof define === 'function' && define.amd) {
10+
// AMD
11+
define([], factory);
12+
} else if (typeof module === 'object' && module.exports) {
13+
// Node, CommonJS-like
14+
module.exports = factory();
15+
} else {
16+
// Browser globals (root is window)
17+
root.jsStack = factory();
18+
}
19+
}(typeof self !== 'undefined' ? self : this, function () {
820
'use strict';
921

1022
function jsStack(element, options) {
@@ -101,8 +113,11 @@
101113
}
102114

103115
// Expose the plugin globally
104-
window.jsStack = function(selector, options) {
116+
function jsStackLibrary(selector, options) {
105117
var elements = document.querySelectorAll(selector);
106118
initJsStack(Array.from(elements), options);
107-
};
108-
})();
119+
}
120+
121+
return jsStackLibrary;
122+
123+
}));

0 commit comments

Comments
 (0)