Skip to content

Commit

Permalink
UMD compatibility added
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsharE committed Aug 27, 2024
1 parent b7370fe commit 9fac2e4
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions jsStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@
* License: Apache 2
* Author: https://elmah.io
*/
(function() {

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node, CommonJS-like
module.exports = factory();
} else {
// Browser globals (root is window)
root.jsStack = factory();
}
}(typeof self !== 'undefined' ? self : this, function () {
'use strict';

function jsStack(element, options) {
Expand Down Expand Up @@ -101,8 +113,11 @@
}

// Expose the plugin globally
window.jsStack = function(selector, options) {
function jsStackLibrary(selector, options) {
var elements = document.querySelectorAll(selector);
initJsStack(Array.from(elements), options);
};
})();
}

return jsStackLibrary;

}));

0 comments on commit 9fac2e4

Please sign in to comment.