]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
style: use typeof for checking undefined 11368/head
authorDaniel Ruf <daniel@daniel-ruf.de>
Sun, 1 Jul 2018 21:58:09 +0000 (23:58 +0200)
committerDaniel Ruf <daniel@daniel-ruf.de>
Sun, 1 Jul 2018 21:58:09 +0000 (23:58 +0200)
js/foundation.core.js
js/foundation.dropdownMenu.js
js/foundation.equalizer.js
js/foundation.magellan.js
js/foundation.util.imageLoader.js
js/foundation.util.mediaQuery.js

index 637961628101be75ecf65d85efdc592a44ec2829..8b7b88abe4aefe678ead3d307c9da8c02416ec0d 100644 (file)
@@ -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 {
index 27befd53d2286b726a2f57542561caa0f1af1762..4ad01d8360bd96daed70d09986caa8512f4d5bd8 100644 (file)
@@ -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;
       });
index f87714af0752da8ebd5c08588e00717f36573e67..13335546747b1e5df7fae9cb6e50b337b7432ad4 100644 (file)
@@ -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{
index 68784a7f00ec21bfccaec39d3201db0273e14004..6c3eb41bdfee402abb56d61ea688d2e68fbceb86 100644 (file)
@@ -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{
index 9fe1d215f99ba262757478e6913733780faf5fa8..46918470186feb75d497eb2e51cdb8e1863d6055 100644 (file)
@@ -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 {
index e60c437897c5ae241c1c654ba21e42f1a9abb931..e80f973ce5ca6b62de48b9249d795cc6fc93c5fc 100644 (file)
@@ -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;