Skip to content

Commit

Permalink
Expose API via CommonJS instead of a global variable, when supported (#…
Browse files Browse the repository at this point in the history
…38)

* Expose API via CommonJS instead of a global variable, when supported

* use double quotes :(

* bump verison number, this is a breaking change
  • Loading branch information
markasoftware authored and LeaVerou committed Jan 8, 2019
1 parent 7373709 commit 2be1637
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions multirange.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var supportsMultiple = self.HTMLInputElement && "valueLow" in HTMLInputElement.p

var descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value");

self.multirange = function(input) {
var multirange = function(input) {
if (supportsMultiple || input.classList.contains("multirange")) {
return;
}
Expand Down Expand Up @@ -76,11 +76,16 @@ multirange.init = function() {
[].slice.call(document.querySelectorAll("input[type=range][multiple]:not(.multirange)")).forEach(multirange);
}

if (document.readyState == "loading") {
document.addEventListener("DOMContentLoaded", multirange.init);
}
else {
multirange.init();
if (typeof module === "undefined") {
self.multirange = multirange;
if (document.readyState == "loading") {
document.addEventListener("DOMContentLoaded", multirange.init);
}
else {
multirange.init();
}
} else {
module.exports = multirange;
}

})();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "multirange",
"version": "1.0.0",
"version": "2.0.0",
"description": "A tiny polyfill for HTML5 multi-handle sliders",
"main": "multirange.js",
"scripts": {
Expand Down

0 comments on commit 2be1637

Please sign in to comment.