Skip to content

Commit

Permalink
Checking for existence of environment specific features before using …
Browse files Browse the repository at this point in the history
…them during initialization to prevent breaking NodeJS by just being required/imported (Foliotek#657)
  • Loading branch information
ofzza authored and thedustinsmith committed Jun 4, 2019
1 parent 8986e13 commit 84a7e81
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions croppie.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
!function(a){function b(a,b){return function(){a.apply(b,arguments)}}function c(a){if("object"!==typeof this)throw new TypeError("Promises must be constructed via new");if("function"!==typeof a)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],i(a,b(e,this),b(f,this))}function d(a){var b=this;return null===this._state?void this._deferreds.push(a):void k(function(){var c=b._state?a.onFulfilled:a.onRejected;if(null===c)return void(b._state?a.resolve:a.reject)(b._value);var d;try{d=c(b._value)}catch(e){return void a.reject(e)}a.resolve(d)})}function e(a){try{if(a===this)throw new TypeError("A promise cannot be resolved with itself.");if(a&&("object"===typeof a||"function"===typeof a)){var c=a.then;if("function"===typeof c)return void i(b(c,a),b(e,this),b(f,this))}this._state=!0,this._value=a,g.call(this)}catch(d){f.call(this,d)}}function f(a){this._state=!1,this._value=a,g.call(this)}function g(){for(var a=0,b=this._deferreds.length;b>a;a++)d.call(this,this._deferreds[a]);this._deferreds=null}function h(a,b,c,d){this.onFulfilled="function"===typeof a?a:null,this.onRejected="function"===typeof b?b:null,this.resolve=c,this.reject=d}function i(a,b,c){var d=!1;try{a(function(a){d||(d=!0,b(a))},function(a){d||(d=!0,c(a))})}catch(e){if(d)return;d=!0,c(e)}}var j=setTimeout,k="function"===typeof setImmediate&&setImmediate||function(a){j(a,1)},l=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)};c.prototype["catch"]=function(a){return this.then(null,a)},c.prototype.then=function(a,b){var e=this;return new c(function(c,f){d.call(e,new h(a,b,c,f))})},c.all=function(){var a=Array.prototype.slice.call(1===arguments.length&&l(arguments[0])?arguments[0]:arguments);return new c(function(b,c){function d(f,g){try{if(g&&("object"===typeof g||"function"===typeof g)){var h=g.then;if("function"===typeof h)return void h.call(g,function(a){d(f,a)},c)}a[f]=g,0===--e&&b(a)}catch(i){c(i)}}if(0===a.length)return b([]);for(var e=a.length,f=0;f<a.length;f++)d(f,a[f])})},c.resolve=function(a){return a&&"object"===typeof a&&a.constructor===c?a:new c(function(b){b(a)})},c.reject=function(a){return new c(function(b,c){c(a)})},c.race=function(a){return new c(function(b,c){for(var d=0,e=a.length;e>d;d++)a[d].then(b,c)})},c._setImmediateFn=function(a){k=a},"undefined"!==typeof module&&module.exports?module.exports=c:a.Promise||(a.Promise=c)}(this);
}

if ( typeof window.CustomEvent !== "function" ) {
if (typeof window !== 'undefined' && typeof window.CustomEvent !== "function") {
(function(){
function CustomEvent ( event, params ) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
Expand All @@ -36,7 +36,7 @@
}());
}

if (!HTMLCanvasElement.prototype.toBlob) {
if (typeof HTMLCanvasElement !== 'undefined' && !HTMLCanvasElement.prototype.toBlob) {
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
value: function (callback, type, quality) {
var binStr = atob( this.toDataURL(type, quality).split(',')[1] ),
Expand All @@ -54,7 +54,7 @@
/* End Polyfills */

var cssPrefixes = ['Webkit', 'Moz', 'ms'],
emptyStyles = document.createElement('div').style,
emptyStyles = typeof document !== 'undefined' ? document.createElement('div').style : {},
EXIF_NORM = [1,8,3,6],
EXIF_FLIP = [2,7,4,5],
CSS_TRANS_ORG,
Expand Down Expand Up @@ -1493,7 +1493,7 @@
delete self.elements;
}

if (window.jQuery) {
if (typeof window !== 'undefined' && window.jQuery) {
var $ = window.jQuery;
$.fn.croppie = function (opts) {
var ot = typeof opts;
Expand Down

0 comments on commit 84a7e81

Please sign in to comment.