From: Daniel Ruf Date: Sun, 1 Jul 2018 21:58:09 +0000 (+0200) Subject: style: use typeof for checking undefined X-Git-Tag: v6.6.0~3^2~139^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F11368%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git style: use typeof for checking undefined --- diff --git a/js/foundation.core.js b/js/foundation.core.js index 637961628..8b7b88abe 100644 --- a/js/foundation.core.js +++ b/js/foundation.core.js @@ -150,7 +150,7 @@ var Foundation = { // Localize the search to all elements inside elem, as well as elem itself, unless elem === document var $elem = $(elem).find('[data-'+name+']').addBack('[data-'+name+']').filter(function () { - return typeof $(this).data("zfPlugin") === "undefined"; + return typeof $(this).data("zfPlugin") === 'undefined'; }); // For each plugin found, initialize it @@ -198,7 +198,7 @@ var Foundation = { var args = Array.prototype.slice.call(arguments, 1);//collect all the arguments, if necessary var plugClass = this.data('zfPlugin');//determine the class of plugin - if(plugClass !== undefined && plugClass[method] !== undefined){//make sure both the class and method exist + if(typeof plugClass !== 'undefined' && typeof plugClass[method] !== 'undefined'){//make sure both the class and method exist if(this.length === 1){//if there's only one, call it directly. plugClass[method].apply(plugClass, args); }else{ @@ -307,12 +307,12 @@ if (!Function.prototype.bind) { } // Polyfill to get the name of a function in IE9 function functionName(fn) { - if (Function.prototype.name === undefined) { + if (typeof Function.prototype.name === 'undefined') { var funcNameRegex = /function\s([^(]{1,})\(/; var results = (funcNameRegex).exec((fn).toString()); return (results && results.length > 1) ? results[1].trim() : ""; } - else if (fn.prototype === undefined) { + else if (typeof fn.prototype === 'undefined') { return fn.constructor.name; } else { diff --git a/js/foundation.dropdownMenu.js b/js/foundation.dropdownMenu.js index 27befd53d..4ad01d836 100644 --- a/js/foundation.dropdownMenu.js +++ b/js/foundation.dropdownMenu.js @@ -338,7 +338,7 @@ class DropdownMenu extends Plugin { var $toClose; if ($elem && $elem.length) { $toClose = $elem; - } else if (idx !== undefined) { + } else if (typeof idx !== 'undefined') { $toClose = this.$tabs.not(function(i, el) { return i === idx; }); diff --git a/js/foundation.equalizer.js b/js/foundation.equalizer.js index f87714af0..133355467 100644 --- a/js/foundation.equalizer.js +++ b/js/foundation.equalizer.js @@ -60,7 +60,7 @@ class Equalizer extends Plugin { }else{ this._events(); } - if((tooSmall !== undefined && tooSmall === false) || tooSmall === undefined){ + if((typeof tooSmall !== 'undefined' && tooSmall === false) || typeof tooSmall === 'undefined'){ if(imgs.length){ onImagesLoaded(imgs, this._reflow.bind(this)); }else{ diff --git a/js/foundation.magellan.js b/js/foundation.magellan.js index 68784a7f0..6c3eb41bd 100644 --- a/js/foundation.magellan.js +++ b/js/foundation.magellan.js @@ -175,7 +175,7 @@ class Magellan extends Plugin { // Get the new active link const $oldActive = this.$active; let activeHash = ''; - if(activeIdx !== undefined){ + if(typeof activeIdx !== 'undefined'){ this.$active = this.$links.filter('[href="#' + this.$targets.eq(activeIdx).data('magellan-target') + '"]'); if (this.$active.length) activeHash = this.$active[0].getAttribute('href'); }else{ diff --git a/js/foundation.util.imageLoader.js b/js/foundation.util.imageLoader.js index 9fe1d215f..469184701 100644 --- a/js/foundation.util.imageLoader.js +++ b/js/foundation.util.imageLoader.js @@ -17,7 +17,7 @@ function onImagesLoaded(images, callback){ images.each(function(){ // Check if image is loaded - if (this.complete && this.naturalWidth !== undefined) { + if (this.complete && typeof this.naturalWidth !== 'undefined') { singleImageLoaded(); } else { diff --git a/js/foundation.util.mediaQuery.js b/js/foundation.util.mediaQuery.js index e60c43789..e80f973ce 100644 --- a/js/foundation.util.mediaQuery.js +++ b/js/foundation.util.mediaQuery.js @@ -216,7 +216,7 @@ function parseStyleToObject(str) { // missing `=` should be `null`: // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters - val = val === undefined ? null : decodeURIComponent(val); + val = typeof val === 'undefined' ? null : decodeURIComponent(val); if (!ret.hasOwnProperty(key)) { ret[key] = val;